re: #209 - to follow up on Leonardo Guizzetti 's comment, please see
and, if this is not what you mean, please clarify
Code:
help datetime##s4
help datetime##s4
. sysuse auto (1978 automobile data) . tempfile tboot . qui bootstrap, reps(500) saving(`tboot'): reg price mpg, level(50) . estat bootstrap, percentile Linear regression Number of obs = 74 Replications = 500 ------------------------------------------------------------------------------ | Observed Bootstrap price | coefficient Bias std. err. [50% conf. interval] -------------+---------------------------------------------------------------- mpg | -238.89435 -6.540619 56.911373 -283.3891 -206.8067 (P) _cons | 11253.061 133.0593 1356.8499 10512.26 12328.61 (P) ------------------------------------------------------------------------------ Key: P: Percentile . use `tboot' (bootstrap: regress) . sum, d _b[mpg] ------------------------------------------------------------- Percentiles Smallest 1% -380.3653 -436.6451 5% -344.9039 -410.6723 10% -324.1469 -385.3353 Obs 500 25% -283.3891 -385.0602 Sum of wgt. 500 50% -237.3672 Mean -245.435 Largest Std. dev. 56.91137 75% -206.8067 -121.5362 90% -175.8918 -111.9515 Variance 3238.904 95% -159.8261 -107.5473 Skewness -.2622398 99% -130.299 -100.4849 Kurtosis 2.846957 _b[_cons] ------------------------------------------------------------- Percentiles Smallest 1% 8331.229 7704.635 5% 9282.614 7916.47 10% 9701.941 8226.62 Obs 500 25% 10512.26 8312.646 Sum of wgt. 500 50% 11250.26 Mean 11386.12 Largest Std. dev. 1356.85 75% 12328.61 14624.41 90% 13168.51 14663.63 Variance 1841042 95% 13638.37 14861 Skewness .1261091 99% 14560.25 15460.15 Kurtosis 2.709669 . centile *, c(25 75) Binom. interp. Variable | Obs Percentile Centile [95% conf. interval] -------------+------------------------------------------------------------- _b_mpg | 500 25 -283.3945 -288.5923 -277.2365 | 75 -206.7666 -212.8225 -200.2001 _b_cons | 500 25 10512.16 10293.56 10656.54 | 75 12332.11 12182.53 12567.85
Immediate form of two-sample t test ttesti #obs1 #mean1 #sd1 #obs2 #mean2 #sd2 [, options2]
Immediate form of two-sample paired t test ttesti #obs #r #mean1 #sd1 #mean2 #sd2, paired [options]
clear webuse fuel summarize * Write the needed summary measures to the dataset quietly summarize mpg1 generate byte n = r(N) in 1 generate m1 = r(mean) in 1 generate sd1 = r(sd) in 1 quietly summarize mpg2 generate m2 = r(mean) in 1 generate sd2 = r(sd) in 1 quietly pwcorr mpg1 mpg2 generate r = r(rho) in 1 * Now compute the paired t-test from the summary data generate mdiff = m1-m2 generate sddiff = sqrt(sd1^2+sd2^2-2*r*sd1*sd2) generate sediff = sddiff/sqrt(n) generate tobs = mdiff/sediff generate byte df = n-1 generate pval = ttail(df,abs(tobs))*2 list mdiff-pval in 1 * Compare results to those from -ttest- ttest mpg1==mpg2
Comment