-----------------------------------------------------------------------------------------
       log:  /Users/baum/doc/Courses 2008-2009/EC771 S2009/771bstrap1.smcl
  log type:  smcl
 opened on:  25 Mar 2009, 22:41:50


. . . capture program drop muratio

. program define muratio, rclass 1. version 10.1 2. syntax varlist(min=2 max=2) 3. tempname ymu 4. summarize `1', meanonly 5. scalar `ymu' = r(mean) 6. summarize `2', meanonly 7. return scalar ratio = `ymu'/r(mean) 8. end

. . set seed 10101

. local reps 1000

. . webuse auto, clear (1978 Automobile Data)

. tabstat price, by(foreign) stat(n mean semean)

Summary for variables: price by categories of: foreign (Car type)

foreign | N mean se(mean) ---------+------------------------------ Domestic | 52 6072.423 429.4911 Foreign | 22 6384.682 558.9942 ---------+------------------------------ Total | 74 6165.257 342.8719 ----------------------------------------

. . g p_dom = price if foreign==0 (22 missing values generated)

. g p_for = price if foreign==1 (52 missing values generated)

. . muratio p_dom p_for

. return list

scalars: r(ratio) = .9510925132761489

. . bootstrap r(ratio), reps(`reps') saving(771bs2_9,replace): muratio p_dom p_for (running muratio on estimation sample)

Warning: Since muratio is not an estimation command or does not set e(sample), bootstrap has no way to determine which observations are used in calculating the statistics and so assumes that all observations are used. This means no observations will be excluded from the resampling because of missing values or other reasons.

If the assumption is not true, press Break, save the data, and drop the observations that are to be excluded. Be sure that the dataset in memory contains only the relevant data.

Bootstrap replications (1000) ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 .................................................. 50 .................................................. 100 .................................................. 150 .................................................. 200 .................................................. 250 .................................................. 300 .................................................. 350 .................................................. 400 .................................................. 450 .................................................. 500 .................................................. 550 .................................................. 600 .................................................. 650 .................................................. 700 .................................................. 750 .................................................. 800 .................................................. 850 .................................................. 900 .................................................. 950 .................................................. 1000

Bootstrap results Number of obs = 74 Replications = 1000

command: muratio p_dom p_for _bs_1: r(ratio)

------------------------------------------------------------------------------ | Observed Bootstrap Normal-based | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _bs_1 | .9510925 .1072875 8.86 0.000 .7408128 1.161372 ------------------------------------------------------------------------------

. . use 771bs2_9,clear (bootstrap: muratio)

. . histogram _bs_1, normal name(g771bs2_r, replace) xsize(9) ysize(7) /// > ti("Bootstrap distribution of ratio of means") (bin=29, start=.68787545, width=.02437044)

. . qui graph export 771bstrap1.pdf, replace

. . . log close log: /Users/baum/doc/Courses 2008-2009/EC771 S2009/771bstrap1.smcl log type: smcl closed on: 25 Mar 2009, 22:42:00 -----------------------------------------------------------------------------------------