library(ggpubr) A4Q1 <- read_excel(“A4Q1.xlsx”)``` ## Research Question
Is there a relationship between age and years of education?
ggscatter(
A4Q1,
x = "age",
y = "education",
add = "reg.line",
xlab = "Age",
ylab = "Years of Education"
)
shapiro.test(A4Q1$age)
##
## Shapiro-Wilk normality test
##
## data: A4Q1$age
## W = 0.99194, p-value = 0.5581
shapiro.test(A4Q1$education)
##
## Shapiro-Wilk normality test
##
## data: A4Q1$education
## W = 0.9908, p-value = 0.4385
cor.test(
A4Q1$age,
A4Q1$education,
method = "pearson"
)
##
## Pearson's product-moment correlation
##
## data: A4Q1$age and A4Q1$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
``` ## Interpretation
The scatterplot shows a positive relationship between age and years of education because the regression line slopes upward from left to right.
The Shapiro-Wilk tests showed that both variables were normally distributed (p > .05), so a Pearson correlation was appropriate.
The Pearson correlation showed a statistically significant positive relationship between age and years of education (r = 0.52, p < .001). This indicates that older individuals tended to have slightly more years of education.