Write down the R solutions of the following question.
Use the following data to construct a confidence interval for the true mean difference between scores of two independant groups. Use a 95% level of confidence. Group1: 65, 58, 78, 60, 68, 69, 66, 70, 53, 71, 63, 63
Group 2: 62, 53, 36, 34, 56, 50, 42, 57, 46, 68, 48, 42, 52, 53, 43
The following R code can be used.
> t.test(c(65,58,78,60,68,69,66,70,53,71,63,63),c(62,53,36,34,56,50,42,57,46,68,48,42,52,53,43),conf.level = .95)$conf.int
To make the code shorter, data can be entered first as follows.
> Group1=c(65,58,78,60,68,69,66,70,53,71,63,63)
> Group2=c(62,53,36,34,56,50,42,57,46,68,48,42,52,53,43)
Then the code becomes;
> t.test(Group1,Group2,conf.level = .95)$conf.int
The output of the code is
[1] 9.531687 22.201646
attr(,"conf.level")
[1] 0.95
The confidence interval for the difference in means is {9.531687,22.201646}.
Comments
Leave a comment