t.test(x, y, alternative = c(“two.sided”, “less”, “greater”), mu = 0, paired = FALSE, var.equal = TRUE, conf.level = 0.95)
A psychologist would like to determine whether there is a relationship between depression and aging. It is known that the general population averages μ = 40 on a standardized depression test. The psychologist obtains a sample of n = 9 individuals who are all more than 70 years old. The depression scores for this sample are as follows: 37, 50, 43, 41, 39, 45, 49, 44, 48. On the basis of this sample, is depression for elderly people significantly different from depression in the general population? Test with α = 0.01.
Reasoning: one sample t-test because we are comparing between a population and a sample, with unknown population variance or standard deviation. We perform two tailed test because we are looking at the “significant difference.”
# mu = 40
# depression scores: 37, 50, 43, 41, 39, 45, 49, 44, 48
# alpha = 0.01 meaning that conf.level = 1 - 0.01 = 0.99
depression <- c(37, 50, 43, 41, 39, 45, 49, 44, 48)
depression
## [1] 37 50 43 41 39 45 49 44 48
# one sample t-test
t.test(depression ,
alternative ="two.sided",
mu = 40,
conf.level = 0.99)
##
## One Sample t-test
##
## data: depression
## t = 2.6667, df = 8, p-value = 0.02851
## alternative hypothesis: true mean is not equal to 40
## 99 percent confidence interval:
## 38.96692 49.03308
## sample estimates:
## mean of x
## 44
# standard deviation for the depression score
sd(depression)
## [1] 4.5
Decision: Fail to reject because p-value > alpha (possibly made Type 2 error)
APA conclusion: A one sample t-test indicated that there is no significant difference in depression for elderly people (M=44,SD=4.5) compared to the general population, t(8) = 2.6667, p > 0.01, 99% CI = [38.97; 49.03].
Students who procrastinate usually experience higher levels of frustration, guilt, stress, and anxiety—in some cases leading to serious issues like depression. To evaluate this information, a psychologist matched depression scores of the two groups of students: those who usually study at the last minute (procrastination group) and those who study daily (non-procrastination group). The pairs of scores recorded are as below. Determine if there is a significant mean difference between the two groups. Test at 0.05 level of significance
Non-Procrastination: 4, 3, 2, 5, 3
Procrastination: 7, 9, 10, 12, 14
Reasoning: Dependent sample t-test (matched/paired) because they matched the scores. We perform two tailed test to look for “significant mean difference.”
# alpha = 0.05 -> conf.level = 1 - 0.05 = 0.95
# Non-Procrastination: 4, 3, 2, 5, 3
non_procrastination <- c(4, 3, 2, 5, 3)
non_procrastination
## [1] 4 3 2 5 3
# Procrastination: 7, 9, 10, 12, 14
procrastination <- c(7, 9, 10, 12, 14)
procrastination
## [1] 7 9 10 12 14
# dependent sample t-test
t.test(x = non_procrastination,
y = procrastination,
alternative = "two.sided",
paired = TRUE,
conf.level = 0.95)
##
## Paired t-test
##
## data: non_procrastination and procrastination
## t = -5.3688, df = 4, p-value = 0.005812
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -10.620042 -3.379958
## sample estimates:
## mean difference
## -7
# Difference score because we are doing dependent sample t-test
difference_score <- procrastination - non_procrastination
difference_score
## [1] 3 6 8 7 11
# sd different score
sd(difference_score)
## [1] 2.915476
Decision: Reject the Null
APA conclusion:
A dependent sample t-test indicated that there is a significant mean difference in depression scores between the procrastination and non-procrastination group (M=-7,SD=2.92), t(4)=-5.37, p < 0.05, 95%CI = [-10.62; -3.38]
You conducted a study showing that elderly people who own dogs are significantly less likely to visit their doctors than are those who do not own dogs. The following is your data, which you tested at alpha = 0.1
Non-dog owners: 12, 10, 9, 15, 6
Dog owners: 5, 8, 4, 6, 9
Reasoning: Independent sample t-test, one tailed test Left.
# alpha = 0.1 -> conf.level = 1 - 0.1 = 0.90
# Non-dog owners: 12, 10, 9, 15, 6
nonpet <- c(12, 10, 9, 15, 6)
nonpet
## [1] 12 10 9 15 6
# Dog owners: 5, 8, 4, 6, 9
pet <- c(5, 8, 4, 6, 9)
pet
## [1] 5 8 4 6 9
# independent sample t-test
t.test(x = nonpet,
y = pet,
alternative = "less",
paired = FALSE,
var.equal = TRUE,
conf.level = 0.90)
##
## Two Sample t-test
##
## data: nonpet and pet
## t = 2.2646, df = 8, p-value = 0.9733
## alternative hypothesis: true difference in means is less than 0
## 90 percent confidence interval:
## -Inf 6.467268
## sample estimates:
## mean of x mean of y
## 10.4 6.4
# sd for non-dog owner
sd(nonpet)
## [1] 3.361547
# sd for dog owners
sd(pet)
## [1] 2.073644
Decision: Fail to Reject
APA Conclusion:
A independent sample t-test indicated that elderly people who own dogs (M = 6.4, SD = 2.07) are NOT significantly less likely to visit their doctors than are those who do not own dogs (M = 10.4, SD = 3.36), t(8)=2.26, p > 0.1, 90%CI = [-inf; 6.47]