Predicting Math Anxiety
Outcome (Numerical): (Math anxiety) score_AMAS_total AMAS1 AMAS2 AMAS3 AMAS4)
Dichotomous Predictor: sex
Multi-categorical Predictor: sample
Predictor 1: (General trait anxiety) score_GAD GAD1 GAD2 GAD3 GAD4 GAD5 GAD6 GAD7
Predictor 2: (Math self-concept) score_SDQ_M SDQ_M1 SDQ_M2 SDQ_M3 SDQ_M4
Predictor 3: (Neuroticism) score_BFI_N BFI_N1 BFI_N2 BFI_N3 BFI_N4 BFI_N5 BFI_N6 BFI_N7 BFI_N8
# if the required packages were not installed, install the packages first
# remove the comment sign # and run the code
# install.packages("readr")
# install.packages("psych")
# install.packages("dplyr")
# install.packages("tidyr")
# install.packages("car")
# install.packages("lm.beta")
# install.packages("interactions")
# install.packages("emmeans")
# install.packages("ggeffects")
# install.packages("mediation")
# install.packages("lavaan")
# load the following packages
library(readr)
library(psych)
library(dplyr)
library(tidyr)
#library(car)
#library(lm.beta)
#library(emmeans)
#library(ggeffects)
#library(interactions)
library(mediation)
library(lavaan)
# turn off scientific notation
options(scipen = 999)
# examine the dataset
# take a look at the Console to see what object name is assigned to the dataset by R
AMATUS_dataset_processed
# Row-wise average
Anxiety_data <- AMATUS_dataset_processed %>%
dplyr::mutate(a_average = rowMeans(dplyr::select(., AMAS1, AMAS2, AMAS3, AMAS4, AMAS5, AMAS6, AMAS7, AMAS8, AMAS9)))
Anxiety_data
describe(Anxiety_data[, c("score_AMAS_total",
"score_GAD",
"score_SDQ_M",
"score_BFI_N",
"sex",
"sample")])
Anxiety_data1 <- Anxiety_data %>% drop_na("score_AMAS_total",
"score_GAD",
"score_SDQ_M",
"score_BFI_N",
"sex",
"sample")
Anxiety_data1
Anxiety_data2 <- Anxiety_data %>%
mutate(
sex_d = recode(sex, 'f' = 0,
'm' = 1),
ger_stu = recode(sample, 'german_students' = "1"),
ger_tea = recode(sample, 'german_teachers' = "2",),
bel_tea = recode(sample, 'belgian_teachers' = "3")
)
table(Anxiety_data2$sex, Anxiety_data2$sex_d)
0 1
f 820 0
m 0 286
table(Anxiety_data2$sample, Anxiety_data2$ger_stu)
1 belgian_teachers german_teachers
belgian_teachers 0 127 0
german_students 848 0 0
german_teachers 0 0 131
table(Anxiety_data2$sample, Anxiety_data2$ger_tea)
2 belgian_teachers german_students
belgian_teachers 0 127 0
german_students 0 0 848
german_teachers 131 0 0
table(Anxiety_data2$sample, Anxiety_data2$bel_tea)
3 german_students german_teachers
belgian_teachers 127 0 0
german_students 0 848 0
german_teachers 0 0 131
Anxiety_lm <- lm(score_AMAS_total ~ score_SDQ_M + score_GAD + score_BFI_N + sex_d + ger_stu,
data = Anxiety_data2)
summary(Anxiety_lm)
Call:
lm(formula = score_AMAS_total ~ score_SDQ_M + score_GAD + score_BFI_N +
sex_d + ger_stu, data = Anxiety_data2)
Residuals:
Min 1Q Median 3Q Max
-17.2076 -3.4000 -0.3279 3.0469 23.3077
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 27.23036 0.93261 29.198 < 0.0000000000000002 ***
score_SDQ_M -1.26723 0.04843 -26.168 < 0.0000000000000002 ***
score_GAD 0.24500 0.04541 5.396 0.0000000836 ***
score_BFI_N 0.14165 0.03144 4.505 0.0000073394 ***
sex_d -1.69373 0.35113 -4.824 0.0000016079 ***
ger_stubelgian_teachers 0.46216 0.47624 0.970 0.33204
ger_stugerman_teachers 1.28745 0.46584 2.764 0.00581 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.903 on 1099 degrees of freedom
Multiple R-squared: 0.4943, Adjusted R-squared: 0.4916
F-statistic: 179.1 on 6 and 1099 DF, p-value: < 0.00000000000000022
anova(Anxiety_lm)
Analysis of Variance Table
Response: score_AMAS_total
Df Sum Sq Mean Sq F value Pr(>F)
score_SDQ_M 1 21603.8 21603.8 898.501 < 0.00000000000000022 ***
score_GAD 1 2661.2 2661.2 110.681 < 0.00000000000000022 ***
score_BFI_N 1 683.7 683.7 28.436 0.0000001175 ***
sex_d 1 691.7 691.7 28.769 0.0000000994 ***
ger_stu 2 191.4 95.7 3.980 0.01896 *
Residuals 1099 26424.6 24.0
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1