#Question 1: Age vs. Education
#Question 1
q1 <- read_excel("A4Q1.xlsx")
#Create scatterplot
ggscatter(
q1,
x = "age",
y = "education",
add = "reg.line",
xlab = "Age",
ylab = "Education"
)
#Relationship is linear, positive, moderate, and with no outliers.
#Descriptive statistics (mean, standard deviation, median)
#Age
mean(q1$age)
## [1] 35.32634
sd(q1$age)
## [1] 11.45344
median(q1$age)
## [1] 35.79811
#Education
mean(q1$education)
## [1] 13.82705
sd(q1$education)
## [1] 2.595901
median(q1$education)
## [1] 14.02915
#Histograms for age and education.
#Histogram for age
hist(q1$age,
main = "Age",
breaks = 20,
col = "lightblue",
border = "white",
cex.main = 1,
cex.axis = 1,
cex.lab = 1)
#Histogram for education
hist(q1$education,
main = "Education",
breaks = 20,
col = "lightcoral",
border = "white",
cex.main = 1,
cex.axis = 1,
)
# Test for normality
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
Normality Assessment:
A Shapiro-Wilk normality test was conducted for both variables.Age (p =
0.5581) and education (p = 0.4385) were both normally distributed (p
> 0.05). Therefore, the Pearson correlation test was selected.
# Pearson Correlation
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
Interpretation:
A pearson correlation task was conducted to examine the relationship
between age and years of education (M = 35.33, SD = 11.45) and education
level (M = 13.83, SD = 2.60). The results showed a statistically
significant positive relationship between age and education, r(148) =
.52, p < .001. This indicates a strong association. Older people
tended to have higher levels of education. As age increased, education
levels generally increased as well.