Comparing 2 populations
Placebo
go to see a doctor
Control group
Twin study
WSJ WSJ ad.
Twin study A D E A D E A D E A D E
Randomized principle B C F B C F A D E A D E A B C D E F
No control group study A D E A D E B C F B C F
matched sample/paired sample A D E A D E B C F B C F
A D E A D E B C F B C F Placebo - (single) blinded test
Double blinded test V V
V V
4.85, 4.56, 4.76, 4.14, 4.94, 4.99, 4.62, 3.43, , 4.57, 5.13, 6.35, 4.22, 5.03, 5.09, , 4.89, 5.14, 4.93, 5.04, 5.25, 5.17, 5.09 (%) Protein of milk produced two farms (artificial data)
1) 95% CI of 2) Tests with ( )
I. are known III. are unknown II. (unknown)
I. are known 95% CI of
I. are known Do test with 1.96 ± 1.645
II. (unknown)
95% CI of II. (unknown)
Do test with II. (unknown)
III. are unknown Satterthwaite’s approximated df
integer
95% CI of III. are unknown
Do test with
95% CI of
> x<-c(4.85,4.56,4.76,4.14,4.94,4.99,4.62,3.43,4.21) > y<-c(5.35,4.57,5.13,6.35,4.22,5.03,5.09,4.67,4.14, 4.89,5.14,4.93,5.04,5.25,5.17,5.09) > > t.test(x,y) Welch Two Sample t-test data: x and y t = , df = 16.71, p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y
> t.test(x,y,alternative="less") Welch Two Sample t-test data: x and y t = , df = 16.71, p-value = alternative hypothesis: true difference in means is less than 0 95 percent confidence interval: -Inf sample estimates: mean of x mean of y Satterthwaite’s approximated df is
> t.test(x,y,var.equal=T) Two Sample t-test data: x and y t = , df = 23, p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y Equal variance Compare df with the one obtained by Satterthwaite’s approximated df (16.71). 9 16
n, m are large
95% CI of
2) Tests with Assume, that is
Do test with
> head2 <- c( 560, 640) > toss2 <- c( 1000, 1000) > prop.test(head2, toss2) 2-sample test for equality of proportions …. data: head2 out of toss2 X-squared = , df = 1, p-value = alternative hypothesis: two.sided 95 percent confidence interval: sample estimates: prop 1 prop See Chi-square test for more general approach !! CaesarTolemy Head Tail || ? : :
> # > # H0 : all four coins have the same proportion showing head side > # H1 : at least one coin have different proportion to the others > # > > head4 <- c( 83, 90, 129, 70 ) > toss4 <- c( 86, 93, 136, 82 ) > prop.test(head4, toss4) 4-sample test for equality of proportions without continuity correction data: head4 out of toss4 X-squared = , df = 3, p-value = alternative hypothesis: two.sided sample estimates: prop 1 prop 2 prop 3 prop Coin 1Coin 2Coin 3Coin 4 Head Alive Tail33712Dead Total Total Hospital 1Hospital 2Hospital 3Hospital 4
Subject (case) variation + treatment effect
Consider the following study in which standing and supine systolic blood pressures were compared. This study was performed on twelve subjects. Their blood pressures were measured in both positions. Suggested null and alternative hypotheses could be: H 0 : There is no difference between the mean blood pressures in the two populations H 1 : There is a difference between the mean blood pressures in the two populations or equivalently H 0 : On average there is no difference between the blood pressures in the two populations H 1 : On average there is a difference between the blood pressures in the two populations Paired sample t-test
SubjectStandingSupineDifference Mean SD Blood pressures (mmHg) Subject (human) variation is much larger than the position variation
Paired sample t-test ( X ) ( O )
> x<-c(132,146,135,141,139,162,128,137,145,151,131,143) > y<-c(136,145,140,147,142,160,137,136,149,158,120,150) > > t.test(x,y) Welch Two Sample t-test data: x and y t = , df = , p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y > t.test(x,y,paired=T) Paired t-test data: x and y t = , df = 11, p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of the differences -2.5 ( X ) ( O )
Student’s sleep data Student (1908), The probable error of a mean. Biometrika, 6 -1, 1-25.
IDControlTreatment Student’s sleep data Data which show the effect of two soporific drugs (increase in hours of sleep compared to control) on 10 patients. R has this data.
Student’s sleep data > t.test(extra ~ group, paired=T, data = sleep) Paired t-test data: extra by group t = , df = 9, p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of the differences > t.test(extra ~ group, data = sleep) Welch Two Sample t-test data: extra by group t = , df = , p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean in group 1 mean in group ( X ) ( O ) In paired sample t-test, mean difference is more easily detected !
Student’s sleep data > stripchart(extra~group,pch=16, cex=1.4,col=c("red","blue"), ylim=c(0.5,2.5),data=sleep) > xsleep<-data.frame(diff=sleep$extra[11:20]-sleep$extra[1:10],group=factor("2-1")) > stripchart(diff~group,pch=16, cex=1.4,col="brown", ylim=c(0.5,1.5),data=xsleep) Do the blue and red groups have the same distributions ? Is the (population) mean of the distribution 0 ? group 2 – group 1
Thank you !!