12/27/2023 0 Comments Paired t test using r studioThe exercise for the reader is to explain why the paired samples gives a smaller p-value than the two sample test. The answer in the back of the book gives t=2.46 and P is approximately 0.017, so we are done. Remember this is a directional test, and we want just one tail. Now rather than checking a table of t critical values, use R to calculate the p-value. Good: this gives t=2.457468 which is the same as the output of t.test. The test statistic is the deviation (mean of differences minus hypothesized value) divided by the standard error of the mean: Now if don’t want R to do all the test calculations for you, you can use R more like a dumb spreadsheet. > t.test(x$p, x$b, mu=25, paired=T, alternative="greater") ![]() In other words, it is unlikely the observed difference happened by chance, so the mothers probably gained more than 25 grams of bone mineral content. Because p is smaller than alpha, we reject H 0. Next let’s do it the right way with a paired t-test, which gives p=0.02. > t.test(x$p, x$b, mu=25, paired=F, alternative="greater")Īlternative hypothesis: true difference in means is greater than 25 > # Remember, the two-sample test is inappropriate. Because R and the test have no concept of the context, they happily produce p=0.33, and because p is large, we would fail to reject H 0. Instead of using the paired t-test, use the two sample test. But first to illustrate the same point Peck and Devore make in the book, let’s see that “disregarding the paired nature of the samples results in a loss of information” (p497). In other words, we want a large p-value for the normality test.įinally we invoke Student’s t-test. Remember not to confuse the normality test with the t-test, and in the normality test, large values support the distribution is normal. The normality test gives p=0.13, which is large, so we do not reject the null hypothesis that the values are distributed normally. Next check the Shapiro-Wilk test of normality. There is some skew (one mother gained 336 grams), but mostly the plot show normality. All values are in grams of bone density.īecause n=10 is small, the distribution of the differences should be approximately normal. The column p stands for the second measurement (during postweaning period). The column b stands for the first measurement (during breastfeeding). The variable x is a data frame for mothers 1 through 10. Use a significance level of 0.05.įirst, state null hypothesis and the alternative hypothesis: The book asks, despite the calcium drain of breastfeeding and low calcium intake, did the mothers gain at least 25 grams of bone mineral content? The average mother’s age is 16 years old, so the mothers’ bodies are growing too. ![]() The total-body bone mineral content (TBBMC) of young mothers was measured during breast feeding and then in the postweaning period. This lab demonstrates how to conduct one sample, paired sample, and independent sample t-tests in R, and uses R as a tool to develop insight into the conceptual. ![]() The book Statistics: The Exploration & Analysis of Data (6th edition, p505) presents the longitudinal study “Bone mass is recovered from lactation to postweaning in adolescent mothers with low calcium intakes”. Let’s walk through using R and Student’s t-test to compare paired sample data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |