Is there a relationship between age and years of education?
q1 <- read_excel("A4Q1.xlsx")
head(q1)
## # A tibble: 6 × 2
## age education
## <dbl> <dbl>
## 1 42.0 13.2
## 2 38.0 12.6
## 3 16.4 10.3
## 4 33.8 16.2
## 5 33.4 14.0
## 6 14.3 11.4
A Pearson correlation was selected because age and years of education are continuous variables and both variables met the normality assumption.
shapiro.test(q1$age)
##
## Shapiro-Wilk normality test
##
## data: q1$age
## W = 0.99194, p-value = 0.5581
shapiro.test(q1$education)
##
## Shapiro-Wilk normality test
##
## data: q1$education
## W = 0.9908, p-value = 0.4385
The Shapiro-Wilk tests were not statistically significant for age and education, indicating that both variables were approximately normally distributed.
cor.test(q1$age, q1$education, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: q1$age and q1$education
## t = 7.4066, df = 148, p-value = 9.113e-12
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3924728 0.6279534
## sample estimates:
## cor
## 0.5200256
A Pearson correlation showed a statistically significant moderate positive relationship between age and years of education, r(148) = .52, p < .001. This means that, in this dataset, older participants tended to report more years of education.