[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: standard error obtained from ttest and linear regression |

Date |
Thu, 19 Feb 2004 17:07:06 -0000 |

The standard error for domestic cars reported by -ttest- depends only on the data for domestic cars. The standard error for the intercept of the regression depends on all the data. So you can't expect exactly the same value. Nick n.j.cox@durham.ac.uk Aijing Shang > By chance, I found the standard error of mean values obtained > from ttest is > different from linear regression. Please look at the > following example. > The data is auto.dta in STATA. > > . ttest price, by(foreign) > > Two-sample t test with equal variances > > -------------------------------------------------------------- > -------------- > -- > Group | Obs Mean Std. Err. Std. Dev. [95% Conf. > Interval] > ---------+---------------------------------------------------- > -------------- > -- > Domestic | 52 6072.423 429.4911 3097.104 5210.184 > 6934.662 > Foreign | 22 6384.682 558.9942 2621.915 5222.19 > 7547.174 > ---------+---------------------------------------------------- > -------------- > -- > combined | 74 6165.257 342.8719 2949.496 5481.914 > 6848.6 > ---------+---------------------------------------------------- > -------------- > -- > diff | -312.2587 754.4488 -1816.225 > 1191.708 > -------------------------------------------------------------- > -------------- > -- > Degrees of freedom: 72 > > Ho: mean(Domestic) - mean(Foreign) = diff = 0 > > Ha: diff < 0 Ha: diff != 0 > Ha: diff > 0 > t = -0.4139 t = -0.4139 > t = -0.4139 > P < t = 0.3401 P > |t| = 0.6802 P > > t = 0.6599 > > > . reg price foreign > > Source | SS df MS Number of obs = > 74 > -------------+------------------------------ F( 1, 72) = > 0.17 > Model | 1507382.66 1 1507382.66 Prob > F = > 0.6802 > Residual | 633558013 72 8799416.85 R-squared = > 0.0024 > -------------+------------------------------ Adj R-squared > = -0.0115 > Total | 635065396 73 8699525.97 Root MSE = > 2966.4 > > -------------------------------------------------------------- > -------------- > -- > price | Coef. Std. Err. t P>|t| [95% Conf. > Interval] > -------------+------------------------------------------------ > -------------- > -- > foreign | 312.2587 754.4488 0.41 0.680 -1191.708 > 1816.225 > _cons | 6072.423 411.363 14.76 0.000 5252.386 > 6892.46 > -------------------------------------------------------------- > -------------- > -- > > ttest and linear regression provide exactly the same estimates of mean > difference of price between domestic and foreign autos, which > is 312.2587 in > this example. As well as its standard error, which is > 754.4488. However, > look at _cons in the linear regression. In this example, the > coefficient of > _cons should be the mean price of domestic auto, since > varible "foreign" is > coded as 0 if the autos were from domestic, 1 if foreign. The > coefficient of > _cons is exactly the same as the mean value in ttest, which > is 6072.423. But > its standard error in ttest is 429.4911, whereas 411.363 in linear > regression. Can anybody tell me how this can happen? Thank > you very much in > advance. * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: standard error obtained from ttest and linear regression***From:*Roger Newson <roger.newson@kcl.ac.uk>

- Prev by Date:
**st: typo in -tabplot- help** - Next by Date:
**RE: Re: st: Is Stata used for spatial statistics/GIS?** - Previous by thread:
**st: typo in -tabplot- help** - Next by thread:
**st: RE: standard error obtained from ttest and linear regression** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |