library(readxl) library(ggpubr) library(readxl)
A4Q1 <- read_excel(“C:/Users/Jasmine/Desktop/Week 4 Corrections/A4Q1.xlsx”)
ggscatter( A4Q1, x = “age”, y = “education”, add = “reg.line”, xlab = “Independent Variable”, ylab = “Dependent Variable” )
mean(A4Q1\(age) sd(A4Q1\)age) median(A4Q1$age)
mean(A4Q1\(education) sd(A4Q1\)education) median(A4Q1$education)
hist(A4Q1$age, main = “age”, breaks = 20, col = “lightblue”, border = “white”, cex.main = 1, cex.axis = 1, cex.lab = 1)
hist(A4Q1$education, main = “Dependent Variable”, breaks = 20, col = “lightcoral”, border = “white”, cex.main = 1, cex.axis = 1, cex.lab = 1)
#Variable 1: Age #The first variable looks normally distributed. #The data is symmetrical.(skewness -0.16) #The data has a proper bell curve.(kurtosis 2.70)
#Variable 2: Education #The second variable looks normally distributed. #The data is symmetrical (skewness -0.26) #The data has a proper bell curve.(kurtosis 2.72)
shapiro.test(A4Q1\(age) shapiro.test(A4Q1\)education)
cor.test(A4Q1\(age, A4Q1\)education, method = “pearson”)
cor.test(A4Q1\(age, A4Q1\)education, method = “spearman”)
#A Pearson correlation was conducted to test the relationship between a #person’s age in years (M = 35.33, SD = 11.45) and a person’s years of #education (M = 13.83, SD = 2.60). #There was a statistically significant relationship between the two #variables, r(148) = .52, p < .001. #The relationship was positive and strong. #As age increased, years of education increased.