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

Re: st: two-sample vs. two-mean

From   Richard Goldstein <>
Subject   Re: st: two-sample vs. two-mean
Date   Tue, 08 Apr 2008 09:22:22 -0400

ttest mpg1=mpg2 gives a paired t-test

after stacking, ttest mpg, by(group) gives an unpaired t-test

if you replace the first t-test by

ttest mpg1=mpg2, unp

you will match the result after stack


Martin Weiss wrote:
Dear Statalisters,

Try this in Stata:

webuse fuel, clear
*two-sample mean comparison
noi ttest mpg1==mpg2
local pl1=r(p_l) local pu1=r(p_u)
local p1=r(p)

*two-group mean comparison
stack mpg1 mpg2, into(mpg) clear
rename _s group
noi ttest mpg, by(group)
local pl2=r(p_l) local pu2=r(p_u)
local p2=r(p)

noi di _newline
noi di in red "Results:" _newline
noi di in red "Test against H1: <" _column(23) round(`pl1', .001) " versus
" round(`pl2', .001) _newline noi di in red "Test against H1: >" _column(23) round(`pu1', .001) " versus
" round(`pu2', .001) _newline
noi di in red "Test against H1: !=" _column(23) round(`p1', .001) " versus "
round(`p2', .001) _newline

Then let me know how I can easily explain the difference between a
"two-sample mean" and a "two-group mean" comparison test.

Warm regards,
Martin Weiss

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen

Fon: 0049-7071-2978184




* For searches and help try:

*   For searches and help try:

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