[R] Homework help: t test hypothesis testing with summarized data?

Peter Dalgaard
Wed, 07 Nov 2007 23:50:15 -0000

Zembower, Kevin wrote:
> Is this how a t hypothesis test is done when I don't have the actual
> data, but just the summarized statistics:
>
>> #Homework 9.2.6 [1]
>> n<-31
>> xbar<-3.10
>> s_x<-1.469
>> m<-57
>> ybar<-2.43
>> s_y<-1.35
>> s_pooled<- (((n-1)*s_x^2) + ((m-1)*s_y^2)) / (n + m - 2)
>> s_pooled
>>
> [1] 1.939521
>
>> t_obs <- (xbar -  ybar) / (s_pooled * (sqrt(1/n + 1/m)))
>> t_obs
>>
> [1] 1.547951
>
>> qt(c(.025, .975), n+m-2)
>>
> [1] -1.987934  1.987934
>
>> # Therefore, fail to reject H0 at the 0.05 level of significance
>>
>>
>
> Or am I again overlooking a canned procedure or an easier calculation
> using the t distribution.
>
I don't know if someone told you last time, but there's an Internet code
of honor about helping with homework.... Don't expect more than hints.

You're on track but there's a mistake.

Here's a way of testing your result:

 > x <- scale(rnorm(31))*1.469+3.10
 > y <- scale(rnorm(57))*1.35+2.43
 > t.test(x,y, var.equal=TRUE)




> Thank you for your continued advice and help.
>
> -Kevin
>
> [1] An Introduction to Mathematical Statistics and its Applications,
> fourth ed., Larsen and Marx.
>
> Kevin Zembower
> Internet Services Group manager
> Center for Communication Programs
> Bloomberg School of Public Health
> Johns Hopkins University
> 111 Market Place, Suite 310
> Baltimore, Maryland  21202
> 410-659-6139
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907