-------------------------------------------------------------------------------
log: /Applications/Stata/771bs2.smcl
log type: smcl
opened on: 18 Jan 2004, 14:58:54
. set more off
. set seed 123456789
. local reps 1000
.
. capture program drop muratio
. program define muratio, rclass
1. version 8.0
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
.
. 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 "muratio p_dom p_for" r(ratio), reps(`reps') saving(771bs2) replace
command: muratio p_dom p_for
statistic: _bs_1 = r(ratio)
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 due to 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 the dataset in
memory contains only the relevant data.
Bootstrap statistics Number of obs = 74
Replications = 1000
------------------------------------------------------------------------------
Variable | Reps Observed Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | 1000 .9510925 .0004643 .1081351 .7388945 1.163291 (N)
| .75699 1.179357 (P)
| .7785801 1.20562 (BC)
------------------------------------------------------------------------------
Note: N = normal
P = percentile
BC = bias-corrected
.
. use 771bs2,clear
(bootstrap: muratio p_dom p_for)
. graph drop _all
. histogram _bs_1, normal name(g771bs2_r) xsize(9) ysize(7) ti("Bootstrap distr
> ibution of ratio of means")
(bin=29, start=.6723175, width=.02348913)
. graph export 771bs2.pdf, replace
(note: file 771bs2.pdf not found)
. log close
log: /Applications/Stata/771bs2.smcl
log type: smcl
closed on: 18 Jan 2004, 14:59:03
-------------------------------------------------------------------------------