#Question 1: Age vs. Education
# Load data
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
str(q1)
## tibble [150 × 2] (S3: tbl_df/tbl/data.frame)
## $ age : num [1:150] 42 38 16.4 33.8 33.4 ...
## $ education: num [1:150] 13.2 12.6 10.3 16.2 14 ...
summary(q1)
## age education
## Min. : 8.657 Min. : 6.196
## 1st Qu.:27.887 1st Qu.:12.024
## Median :35.798 Median :14.029
## Mean :35.326 Mean :13.827
## 3rd Qu.:42.549 3rd Qu.:15.851
## Max. :62.923 Max. :19.727
# 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 test was conducted to examine the relationship
between age and years of education. There was a moderate positive
correlation between age and years of education (\(r = 0.520, p < 0.001\)). This indicates
that as age increases, years of education tend to increase, and the
relationship is statistically significant.