Ankit:
as an aside to Andrew's excellent reply, you may want to consider -lincom- after -regress- (standard errors will differ from the one calculated via -ttest-, though. This very old Stata thread explains why):
as an aside to Andrew's excellent reply, you may want to consider -lincom- after -regress- (standard errors will differ from the one calculated via -ttest-, though. This very old Stata thread explains why):
Code:
use "C:\Program Files\Stata18\ado\base\a\auto.dta"
. ttest mpg if inlist(rep78, 1, 2), by(rep78) unequal
Two-sample t test with unequal variances
------------------------------------------------------------------------------
Group | Obs Mean Std. err. Std. dev. [95% conf. interval]
---------+--------------------------------------------------------------------
1 | 2 21 3 4.242641 -17.11861 59.11861
2 | 8 19.125 1.328768 3.758324 15.98296 22.26704
---------+--------------------------------------------------------------------
Combined | 10 19.5 1.166667 3.689324 16.86082 22.13918
---------+--------------------------------------------------------------------
diff | 1.875 3.281101 -19.43346 23.18346
------------------------------------------------------------------------------
diff = mean(1) - mean(2) t = 0.5715
H0: diff = 0 Satterthwaite's degrees of freedom = 1.42302
Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(T < t) = 0.6776 Pr(|T| > |t|) = 0.6447 Pr(T > t) = 0.3224
. lincom _b[1b.rep78]-_b[2.rep78]
( 1) 1b.rep78 - 2.rep78 = 0
------------------------------------------------------------------------------
mpg | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
(1) | 1.875 4.181884 0.45 0.655 -6.479274 10.22927
------------------------------------------------------------------------------
.

Comment