User Tools

Site Tools


paired_sample_t-test
> data(anorexia, package="MASS")       # weight gain (lbs.) in anorexic women
> attach(anorexia)
> str(anorexia)
'data.frame':	72 obs. of  3 variables:
 $ Treat : Factor w/ 3 levels "CBT","Cont","FT": 2 2 2 2 2 2 2 2 2 2 ...
 $ Prewt : num  80.7 89.4 91.8 74 78.1 88.3 87.3 75.1 80.6 78.4 ...
 $ Postwt: num  80.2 80.1 86.4 86.3 76.1 78.1 75.1 86.7 73.5 84.6 ...
> ft = subset(anorexia, subset=(Treat=="FT"))         # just the family therapy threatment
> ft
   Treat Prewt Postwt
56    FT  83.8   95.2
57    FT  83.3   94.3
58    FT  86.0   91.5
59    FT  82.5   91.9
60    FT  86.7  100.3
61    FT  79.6   76.7
62    FT  76.9   76.8
63    FT  94.2  101.6
64    FT  73.4   94.9
65    FT  80.5   75.2
66    FT  81.6   77.8
67    FT  82.1   95.5
68    FT  77.6   90.7
69    FT  83.5   92.5
70    FT  89.9   93.8
71    FT  86.0   91.7
72    FT  87.3   98.0
> detach(anorexia)
> rm(anorexia)
> t.test(ft$Prewt, ft$Postwt, paired=T)

	Paired t-test

data:  ft$Prewt and ft$Postwt
t = -4.1849, df = 16, p-value = 0.0007003
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -10.94471  -3.58470
sample estimates:
mean of the differences 
              -7.264706 

> 
> t.test(ft$Postwt-ft$Prewt, mu=0, data=ft)

	One Sample t-test

data:  ft$Postwt - ft$Prewt
t = 4.1849, df = 16, p-value = 0.0007003
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
  3.58470 10.94471
sample estimates:
mean of x 
 7.264706 

>
paired_sample_t-test.txt · Last modified: 2017/05/17 13:04 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki