library(bruceR)
## Warning: package 'bruceR' was built under R version 4.3.3
##
## bruceR (v2024.6)
## Broadly Useful Convenient and Efficient R functions
##
## Packages also loaded:
## ✔ data.table ✔ emmeans
## ✔ dplyr ✔ lmerTest
## ✔ tidyr ✔ effectsize
## ✔ stringr ✔ performance
## ✔ ggplot2 ✔ interactions
##
## Main functions of `bruceR`:
## cc() Describe() TTEST()
## add() Freq() MANOVA()
## .mean() Corr() EMMEANS()
## set.wd() Alpha() PROCESS()
## import() EFA() model_summary()
## print_table() CFA() lavaan_summary()
##
## For full functionality, please install all dependencies:
## install.packages("bruceR", dep=TRUE)
##
## Online documentation:
## https://psychbruce.github.io/bruceR
##
## To use this package in publications, please cite:
## Bao, H.-W.-S. (2024). bruceR: Broadly useful convenient and efficient R functions (Version 2024.6) [Computer software]. https://CRAN.R-project.org/package=bruceR
set.wd()
## ✔ Set working directory to "C:/Users/psyuser/Desktop/ARWA analysis"
set.seed(6)
rm(list = ls())
library(tidyverse)
## Warning: package 'readr' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.5
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ data.table::between() masks dplyr::between()
## ✖ Matrix::expand() masks tidyr::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ data.table::first() masks dplyr::first()
## ✖ lubridate::hour() masks data.table::hour()
## ✖ lubridate::isoweek() masks data.table::isoweek()
## ✖ dplyr::lag() masks stats::lag()
## ✖ data.table::last() masks dplyr::last()
## ✖ lubridate::mday() masks data.table::mday()
## ✖ lubridate::minute() masks data.table::minute()
## ✖ lubridate::month() masks data.table::month()
## ✖ Matrix::pack() masks tidyr::pack()
## ✖ lubridate::quarter() masks data.table::quarter()
## ✖ lubridate::second() masks data.table::second()
## ✖ purrr::transpose() masks data.table::transpose()
## ✖ Matrix::unpack() masks tidyr::unpack()
## ✖ lubridate::wday() masks data.table::wday()
## ✖ lubridate::week() masks data.table::week()
## ✖ lubridate::yday() masks data.table::yday()
## ✖ lubridate::year() masks data.table::year()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
data <- read.csv("./data/EEG_RS_lanExp.csv")
# Select the relevant columns and drop rows with NA values
education_income_data <- data %>%
select(EEGID, FatherEducation, MotherEducation, Income) %>%
drop_na()
# Perform PCA
pca_result <- prcomp(education_income_data %>% select(-EEGID), scale. = TRUE)
# Extract the first principal component and add SubjectID
pca_scores <- education_income_data %>%
select(EEGID) %>%
mutate(EducationIncomeFactor = -pca_result$x[, 1]) # add minus so that higher scores indicate higher SES
# Merge the PCA scores back into the original data
data_income <- data %>%
left_join(pca_scores, by = "EEGID") %>%
# Reorder columns to move FatherEducation, MotherEducation, Income, and EducationIncomeFactor to the first four columns
select(EEGID, FatherEducation, MotherEducation, Income, EducationIncomeFactor, everything()) %>%
mutate(Age_EEG_yr = Age_EEG / 12) %>% # convert Age_EEG from months to years
# keep unique EEGID values
distinct(EEGID, .keep_all = TRUE)
## Warning in left_join(., pca_scores, by = "EEGID"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 20 of `x` matches multiple rows in `y`.
## ℹ Row 15 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
# output the data_income to csv
write.csv(data_income, file = "./data/EEG_RS_lanExp_income.csv", row.names = FALSE)
{r demography summary} # # Load the data # data_income <- read.csv("./data/EEG_RS_lanExp_income.csv") # # demo_info <- read.csv("./data/assessment-resting-state-v8-200-drop-duplicated.csv") # # # left join data_income with demo_info by selected column age gender # demo_data_summary <- data_income %>% # left_join(demo_info %>% select(EEGID, Gender), by = "EEGID", suffix = c("", "")) %>% # # keep unique EEGID values # distinct(EEGID, .keep_all = TRUE) %>% # summarise(count = n(), # mean_age = mean(Age_EEG_yr, na.rm = TRUE), # gender_count = list(table(Gender)) # ) # # knitr::kable(demo_data_summary) # #
# library(lme4)
library(tidyverse)
library(lmerTest)
library(conflicted)
data_income <- read.csv("./data/EEG_RS_lanExp_income.csv")
# Center the variables
data_income <- data_income %>%
mutate(
PW_c = scale(PW, center = TRUE, scale = FALSE),
CMOI_c = scale(CMOI, center = TRUE, scale = FALSE),
EMOI_c = scale(EMOI, center = TRUE, scale = FALSE),
Age_EEG_yr_c = scale(Age_EEG_yr, center = TRUE, scale = FALSE),
EducationIncomeFactor_c = scale(EducationIncomeFactor, center = TRUE, scale = FALSE)
)
# keep only the columns data for the analysis
data_income <- data_income %>%
select(CWR, CDICT, MATH, EWR, EDICT, PW_c, CMOI_c, EMOI_c, Age_EEG_yr_c, EducationIncomeFactor_c, FID, EEGID, Age_EEG_yr) %>%
drop_na()
demo_info <- read.csv("./data/assessment-resting-state-v8-200-drop-duplicated.csv")
# left join data_income with demo_info by selected column age gender
demo_data_summary <- data_income %>%
left_join(demo_info %>% select(EEGID, Gender), by = "EEGID", suffix = c("", "")) %>%
summarise(count = n(),
mean_age = mean(Age_EEG_yr, na.rm = TRUE),
gender_count = list(table(Gender))
)
knitr::kable(demo_data_summary)
count | mean_age | gender_count |
---|---|---|
118 | 8.274717 | 50, 68 |
# Fit separate models for each response variable
model_CWR <- lmerTest::lmer(CWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID), data = data_income)
model_CDICT <- lmerTest::lmer(CDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID), data = data_income)
model_MATH <- lmerTest::lmer(MATH ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID), data = data_income)
model_EWR <- lmerTest::lmer(EWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID), data = data_income)
model_EDICT <- lmerTest::lmer(EDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID), data = data_income)
# Print the model summaries
summary(model_CWR)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 1036.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.76701 -0.39568 0.04811 0.36401 2.58404
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 547.3 23.39
## Residual 173.3 13.16
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 80.4273 3.3199 58.9427 24.226 < 2e-16 ***
## PW_c 130.2937 70.8797 88.1357 1.838 0.0694 .
## Age_EEG_yr_c 20.1046 4.1854 60.4530 4.803 1.07e-05 ***
## EducationIncomeFactor_c 0.4703 2.0907 59.5016 0.225 0.8228
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c A_EEG_
## PW_c -0.038
## Ag_EEG_yr_c -0.240 0.084
## EdctnIncmF_ 0.096 0.025 -0.159
summary(model_CDICT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 745.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5835 -0.5180 0.1374 0.4822 1.6190
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 34.84 5.902
## Residual 15.60 3.950
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 27.4566 0.8628 59.2728 31.823 <2e-16 ***
## PW_c 42.9544 20.4571 96.2553 2.100 0.0384 *
## Age_EEG_yr_c 2.8901 1.0899 61.0322 2.652 0.0102 *
## EducationIncomeFactor_c 0.4581 0.5438 60.0074 0.842 0.4029
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c A_EEG_
## PW_c -0.042
## Ag_EEG_yr_c -0.241 0.091
## EdctnIncmF_ 0.095 0.030 -0.160
summary(model_MATH)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: MATH ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 671.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3140 -0.4167 -0.0048 0.4361 3.1104
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 14.722 3.837
## Residual 9.414 3.068
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.0322 0.5838 58.8520 18.897 < 2e-16 ***
## PW_c 19.7493 15.1894 103.6008 1.300 0.1964
## Age_EEG_yr_c 5.2988 0.7391 60.8434 7.170 1.2e-09 ***
## EducationIncomeFactor_c 0.8262 0.3683 59.7953 2.243 0.0286 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c A_EEG_
## PW_c -0.045
## Ag_EEG_yr_c -0.243 0.096
## EdctnIncmF_ 0.095 0.035 -0.163
summary(model_EWR)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 848.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3424 -0.4189 0.0176 0.3641 3.0878
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 97.18 9.858
## Residual 35.25 5.937
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 18.7700 1.4139 58.5991 13.275 < 2e-16 ***
## PW_c 39.5447 31.5048 91.0210 1.255 0.212621
## Age_EEG_yr_c 7.1370 1.7839 60.2102 4.001 0.000175 ***
## EducationIncomeFactor_c 5.2782 0.8907 59.2236 5.926 1.7e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c A_EEG_
## PW_c -0.039
## Ag_EEG_yr_c -0.241 0.087
## EdctnIncmF_ 0.096 0.027 -0.159
summary(model_EDICT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 685.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.39774 -0.42255 -0.05233 0.46708 2.58489
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 22.363 4.729
## Residual 8.757 2.959
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.8016 0.6827 58.4754 11.427 < 2e-16 ***
## PW_c 17.0368 15.5688 92.7257 1.094 0.276660
## Age_EEG_yr_c 3.1701 0.8617 60.1422 3.679 0.000502 ***
## EducationIncomeFactor_c 2.2884 0.4301 59.1389 5.320 1.67e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c A_EEG_
## PW_c -0.040
## Ag_EEG_yr_c -0.241 0.088
## EdctnIncmF_ 0.096 0.028 -0.160
# Fit the models with centered variables
moderate_CWR_MOI <- lmerTest::lmer(CWR ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_CDICT_MOI <- lmerTest::lmer(CDICT ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
# moderate_MATH_MOI <- lmerTest::lmer(MATH ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_EWR_MOI <- lmerTest::lmer(EWR ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_EDICT_MOI <- lmerTest::lmer(EDICT ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
# Print the model summaries
summary(moderate_CWR_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CWR ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 1021.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8123 -0.2936 0.1009 0.3505 2.5456
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 525.6 22.93
## Residual 172.2 13.12
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 80.6173 3.2574 59.2811 24.749 < 2e-16 ***
## PW_c 125.3698 70.7876 90.1044 1.771 0.0799 .
## CMOI_c 0.6985 3.6346 104.3676 0.192 0.8480
## Age_EEG_yr_c 19.4807 4.0937 61.6272 4.759 1.22e-05 ***
## PW_c:CMOI_c 161.8547 86.4475 82.6046 1.872 0.0647 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c CMOI_c A_EEG_
## PW_c -0.035
## CMOI_c -0.063 -0.103
## Ag_EEG_yr_c -0.236 0.085 0.065
## PW_c:CMOI_c 0.042 -0.038 0.117 -0.100
summary(moderate_CDICT_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CDICT ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 736
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5417 -0.5089 0.1164 0.4987 1.6244
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 35.69 5.974
## Residual 15.63 3.953
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 27.4109 0.8708 58.8752 31.479 < 2e-16 ***
## PW_c 43.4672 20.5919 95.8130 2.111 0.03739 *
## CMOI_c -0.6136 1.0088 100.0881 -0.608 0.54444
## Age_EEG_yr_c 3.0274 1.0971 61.5690 2.760 0.00761 **
## PW_c:CMOI_c -8.9707 25.3307 85.6083 -0.354 0.72410
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c CMOI_c A_EEG_
## PW_c -0.040
## CMOI_c -0.070 -0.080
## Ag_EEG_yr_c -0.238 0.092 0.074
## PW_c:CMOI_c 0.048 -0.033 0.080 -0.111
# summary(moderate_MATH_MOI)
summary(moderate_EWR_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EWR ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 848.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4497 -0.3124 -0.0676 0.3208 3.5412
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 143.70 11.988
## Residual 30.46 5.519
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 18.457 1.655 59.792 11.152 3.07e-16 ***
## PW_c 49.753 31.207 82.576 1.594 0.114691
## EMOI_c 7.001 1.628 107.922 4.299 3.77e-05 ***
## Age_EEG_yr_c 7.575 2.080 61.988 3.643 0.000553 ***
## PW_c:EMOI_c -12.022 34.991 73.027 -0.344 0.732144
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EMOI_c A_EEG_
## PW_c -0.026
## EMOI_c 0.058 0.150
## Ag_EEG_yr_c -0.233 0.063 -0.108
## PW_c:EMOI_c -0.025 0.024 0.129 0.060
summary(moderate_EDICT_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EDICT ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 680.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3577 -0.4310 -0.1055 0.4739 2.2149
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 29.641 5.444
## Residual 7.529 2.744
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.6828 0.7596 59.8593 10.114 1.43e-14 ***
## PW_c 20.5763 15.2329 85.9275 1.351 0.180312
## EMOI_c 3.5516 0.7687 104.8657 4.621 1.09e-05 ***
## Age_EEG_yr_c 3.3370 0.9560 62.2853 3.491 0.000891 ***
## PW_c:EMOI_c 7.6622 17.1774 75.0680 0.446 0.656835
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EMOI_c A_EEG_
## PW_c -0.029
## EMOI_c 0.061 0.133
## Ag_EEG_yr_c -0.235 0.068 -0.114
## PW_c:EMOI_c -0.028 0.021 0.111 0.066
For the CMOI and EMOI moderation effect, the results are as follows: For CWR, the moderation effect of CMOI is significant (p = .049) and PW significantly correlates with CWR (p = .01). For CDICT, the moderation effect of CMOI is insignificant (p = .45) but PW significantly correlates with CDICT (p = .01). For EWR, the moderation effect of EMOI is insignificant (p = .39) but PW significantly correlates with EWR (p = .038). For EDICT, the moderation effect of EMOI is also insignificant (p = .85) and PW insignificantly correlates with EDICT (p = .09).
# Fit the model with PW as predictor, EducationIncomeFactor as moderator, and Age_EEG_yr as covariate
moderate_CWR_EIF <- lmerTest::lmer(CWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_CDICT_EIF <- lmerTest::lmer(CDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_MATH_EIF <- lmerTest::lmer(MATH ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_EWR_EIF <- lmerTest::lmer(EWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID), data = data_income)
moderate_EDICT_EIF <- lmerTest::lmer(EDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID), data = data_income)
# Print the model summary
summary(moderate_CWR_EIF)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 1025.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6970 -0.4109 0.1054 0.3587 2.5371
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 570.3 23.88
## Residual 167.7 12.95
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 80.3205 3.3728 57.4033 23.814 < 2e-16 ***
## PW_c 105.7705 74.0061 91.3386 1.429 0.156
## EducationIncomeFactor_c 0.6947 2.1338 58.6788 0.326 0.746
## Age_EEG_yr_c 20.1128 4.2484 58.7177 4.734 1.43e-05 ***
## PW_c:EducationIncomeFactor_c -52.4964 51.1934 85.5225 -1.025 0.308
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EdcIF_ A_EEG_
## PW_c -0.025
## EdctnIncmF_ 0.092 -0.009
## Ag_EEG_yr_c -0.240 0.078 -0.157
## PW_c:EdcIF_ 0.031 0.314 -0.102 -0.003
summary(moderate_CDICT_EIF)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 737.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5213 -0.5286 0.1366 0.5290 1.5779
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 35.49 5.957
## Residual 15.49 3.936
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 27.4313 0.8693 58.8176 31.556 <2e-16 ***
## PW_c 37.9898 21.3614 101.1646 1.778 0.0783 .
## EducationIncomeFactor_c 0.5064 0.5510 60.3257 0.919 0.3617
## Age_EEG_yr_c 2.8969 1.0972 60.3548 2.640 0.0105 *
## PW_c:EducationIncomeFactor_c -11.5377 14.8792 95.3050 -0.775 0.4400
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EdcIF_ A_EEG_
## PW_c -0.028
## EdctnIncmF_ 0.090 -0.005
## Ag_EEG_yr_c -0.241 0.084 -0.158
## PW_c:EdcIF_ 0.039 0.289 -0.114 -0.007
summary(moderate_MATH_EIF)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: MATH ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 664.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.2954 -0.4154 -0.0051 0.4332 3.0914
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 14.788 3.845
## Residual 9.523 3.086
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.03246 0.58627 58.84552 18.818 < 2e-16
## PW_c 19.80276 15.82044 108.09700 1.252 0.2134
## EducationIncomeFactor_c 0.82583 0.37238 60.55230 2.218 0.0303
## Age_EEG_yr_c 5.29928 0.74147 60.56200 7.147 1.34e-09
## PW_c:EducationIncomeFactor_c 0.05258 11.09702 103.18896 0.005 0.9962
##
## (Intercept) ***
## PW_c
## EducationIncomeFactor_c *
## Age_EEG_yr_c ***
## PW_c:EducationIncomeFactor_c
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EdcIF_ A_EEG_
## PW_c -0.031
## EdctnIncmF_ 0.088 0.000
## Ag_EEG_yr_c -0.243 0.089 -0.160
## PW_c:EdcIF_ 0.047 0.263 -0.125 -0.013
summary(moderate_EWR_EIF)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 838.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.2980 -0.3948 0.0415 0.3732 3.0494
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 101.73 10.086
## Residual 33.68 5.803
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 18.7131 1.4370 57.1556 13.022 < 2e-16 ***
## PW_c 25.0594 32.6792 94.0713 0.767 0.445102
## EducationIncomeFactor_c 5.4100 0.9096 58.5042 5.948 1.62e-07 ***
## Age_EEG_yr_c 7.1261 1.8111 58.5411 3.935 0.000224 ***
## PW_c:EducationIncomeFactor_c -30.0991 22.6513 88.0355 -1.329 0.187347
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EdcIF_ A_EEG_
## PW_c -0.026
## EdctnIncmF_ 0.092 -0.008
## Ag_EEG_yr_c -0.240 0.080 -0.157
## PW_c:EdcIF_ 0.034 0.307 -0.106 -0.004
summary(moderate_EDICT_EIF)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 679.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.37373 -0.42130 -0.04549 0.47042 2.57367
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 22.547 4.748
## Residual 8.835 2.972
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.7973 0.6860 57.7736 11.366 2.31e-16 ***
## PW_c 16.2065 16.3720 98.3641 0.990 0.324655
## EducationIncomeFactor_c 2.2967 0.4346 59.2221 5.285 1.90e-06 ***
## Age_EEG_yr_c 3.1711 0.8653 59.2549 3.665 0.000531 ***
## PW_c:EducationIncomeFactor_c -1.9630 11.3818 92.3011 -0.172 0.863445
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EdcIF_ A_EEG_
## PW_c -0.027
## EdctnIncmF_ 0.091 -0.007
## Ag_EEG_yr_c -0.241 0.083 -0.158
## PW_c:EdcIF_ 0.037 0.296 -0.111 -0.006
For the CMOI and EMOI moderation effect, the results are as follows: For CWR, the moderation effect of CMOI is significant (p = .049) and PW significantly correlates with CWR (p = .01). For CDICT, the moderation effect of CMOI is insignificant (p = .45) but PW significantly correlates with CDICT (p = .01). For EWR, the moderation effect of EMOI is insignificant (p = .39) but PW significantly correlates with EWR (p = .038). For EDICT, the moderation effect of EMOI is also insignificant (p = .85) and PW insignificantly correlates with EDICT (p = .09).
And for CWR and CDICT, alpha power significantly correlate with then (p = .01 and p = .02, respectively). However, the moderation effect of Education Income Factor (EIF) is not significant for CWR and CDICT (both p > .05). Alpha power did not significantly correlate with MATH (p = .06) and the moderation effect of EIF is also insignificant (p = .65). Alpha power significantly correlate with then (p = .04 and p = .029, respectively). The moderation effect of EIF is insignificant for EWR and EDICT (both p > .05).
# Fit the models with centered variables
model_CWR_MOI <- lmerTest::lmer(CWR ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
model_CDICT_MOI <- lmerTest::lmer(CDICT ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
# moderate_MATH_MOI <- lmerTest::lmer(MATH ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
model_EWR_MOI <- lmerTest::lmer(EWR ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
model_EDICT_MOI <- lmerTest::lmer(EDICT ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID), data = data_income)
#summary
summary(model_CWR_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CWR ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 1035.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.75845 -0.39032 0.04702 0.36596 2.56982
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 543.9 23.32
## Residual 174.2 13.20
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 80.3647 3.3051 58.6149 24.315 < 2e-16 ***
## PW_c 130.3045 71.3364 90.1187 1.827 0.0711 .
## CMOI_c -0.1531 3.6528 109.0191 -0.042 0.9667
## Age_EEG_yr_c 20.2415 4.1359 60.0482 4.894 7.77e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c CMOI_c
## PW_c -0.033
## CMOI_c -0.069 -0.102
## Ag_EEG_yr_c -0.233 0.081 0.077
summary(model_CDICT_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: CDICT ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 744.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5549 -0.5153 0.1153 0.5038 1.6490
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 35.06 5.921
## Residual 15.62 3.952
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 27.4250 0.8636 60.4270 31.758 < 2e-16 ***
## PW_c 43.3201 20.5306 98.0083 2.110 0.03740 *
## CMOI_c -0.5839 1.0006 103.9409 -0.584 0.56078
## Age_EEG_yr_c 2.9839 1.0825 62.0628 2.756 0.00766 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c CMOI_c
## PW_c -0.039
## CMOI_c -0.075 -0.076
## Ag_EEG_yr_c -0.235 0.090 0.085
summary(model_EWR_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EWR ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 857.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4633 -0.3068 -0.0518 0.2963 3.5551
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 143.40 11.975
## Residual 30.07 5.484
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 18.443 1.652 59.757 11.165 2.95e-16 ***
## PW_c 50.025 31.032 83.401 1.612 0.110730
## EMOI_c 7.078 1.609 111.085 4.398 2.52e-05 ***
## Age_EEG_yr_c 7.616 2.072 61.476 3.675 0.000501 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EMOI_c
## PW_c -0.025
## EMOI_c 0.062 0.149
## Ag_EEG_yr_c -0.232 0.061 -0.117
summary(model_EDICT_MOI)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: EDICT ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID)
## Data: data_income
##
## REML criterion at convergence: 688.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3791 -0.4394 -0.1158 0.4763 2.2356
##
## Random effects:
## Groups Name Variance Std.Dev.
## FID (Intercept) 29.493 5.431
## Residual 7.463 2.732
## Number of obs: 118, groups: FID, 62
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.6924 0.7572 59.9808 10.159 1.18e-14 ***
## PW_c 20.4204 15.1688 87.0481 1.346 0.181732
## EMOI_c 3.5141 0.7613 108.1132 4.616 1.08e-05 ***
## Age_EEG_yr_c 3.3084 0.9512 61.8488 3.478 0.000931 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PW_c EMOI_c
## PW_c -0.028
## EMOI_c 0.065 0.132
## Ag_EEG_yr_c -0.234 0.067 -0.122
# Perform the likelihood ratio test
comparison_CWR <- anova(model_CWR_MOI, moderate_CWR_MOI)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_CWR)
## Data: data_income
## Models:
## model_CWR_MOI: CWR ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID)
## moderate_CWR_MOI: CWR ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_CWR_MOI 6 1071.1 1087.7 -529.55 1059.1
## moderate_CWR_MOI 7 1069.5 1088.9 -527.75 1055.5 3.6079 1 0.0575 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Perform the likelihood ratio test
comparison_CWR_EIF <- anova(model_CWR, moderate_CWR_EIF)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_CWR_EIF)
## Data: data_income
## Models:
## model_CWR: CWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## moderate_CWR_EIF: CWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_CWR 6 1071.0 1087.7 -529.52 1059.0
## moderate_CWR_EIF 7 1072.1 1091.5 -529.05 1058.1 0.9505 1 0.3296
# Perform the likelihood ratio test
comparison_CDICT <- anova(model_CDICT_MOI, moderate_CDICT_MOI)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_CDICT)
## Data: data_income
## Models:
## model_CDICT_MOI: CDICT ~ PW_c + CMOI_c + Age_EEG_yr_c + (1 | FID)
## moderate_CDICT_MOI: CDICT ~ PW_c * CMOI_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_CDICT_MOI 6 769.53 786.15 -378.77 757.53
## moderate_CDICT_MOI 7 771.42 790.82 -378.71 757.42 0.1086 1 0.7418
# Perform the likelihood ratio test
comparison_CDICT_EIF <- anova(model_CDICT, moderate_CDICT_EIF)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_CDICT_EIF)
## Data: data_income
## Models:
## model_CDICT: CDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## moderate_CDICT_EIF: CDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_CDICT 6 769.13 785.76 -378.57 757.13
## moderate_CDICT_EIF 7 770.55 789.94 -378.27 756.55 0.5866 1 0.4437
# Perform the likelihood ratio test
comparison_MATH_EIF <- anova(model_MATH, moderate_MATH_EIF)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_MATH_EIF)
## Data: data_income
## Models:
## model_MATH: MATH ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## moderate_MATH_EIF: MATH ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_MATH 6 692.39 709.02 -340.2 680.39
## moderate_MATH_EIF 7 694.39 713.79 -340.2 680.39 0 1 0.9945
# Perform the likelihood ratio test
comparison_EWR <- anova(model_EWR_MOI, moderate_EWR_MOI)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_EWR)
## Data: data_income
## Models:
## model_EWR_MOI: EWR ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID)
## moderate_EWR_MOI: EWR ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_EWR_MOI 6 886.80 903.43 -437.40 874.80
## moderate_EWR_MOI 7 888.68 908.08 -437.34 874.68 0.1219 1 0.727
# Perform the likelihood ratio test
comparison_EWR_EIF <- anova(model_EWR, moderate_EWR_EIF)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_EWR_EIF)
## Data: data_income
## Models:
## model_EWR: EWR ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## moderate_EWR_EIF: EWR ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_EWR 6 876.02 892.65 -432.01 864.02
## moderate_EWR_EIF 7 876.38 895.77 -431.19 862.38 1.6426 1 0.2
# Perform the likelihood ratio test
comparison_EDICT <- anova(model_EDICT_MOI, moderate_EDICT_MOI)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_EDICT)
## Data: data_income
## Models:
## model_EDICT_MOI: EDICT ~ PW_c + EMOI_c + Age_EEG_yr_c + (1 | FID)
## moderate_EDICT_MOI: EDICT ~ PW_c * EMOI_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_EDICT_MOI 6 712.01 728.63 -350.0 700.01
## moderate_EDICT_MOI 7 713.80 733.20 -349.9 699.80 0.2027 1 0.6526
# Perform the likelihood ratio test
comparison_EDICT_EIF <- anova(model_EDICT, moderate_EDICT_EIF)
## refitting model(s) with ML (instead of REML)
# Print the comparison results
print(comparison_EDICT_EIF)
## Data: data_income
## Models:
## model_EDICT: EDICT ~ PW_c + Age_EEG_yr_c + EducationIncomeFactor_c + (1 | FID)
## moderate_EDICT_EIF: EDICT ~ PW_c * EducationIncomeFactor_c + Age_EEG_yr_c + (1 | FID)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## model_EDICT 6 707.76 724.39 -347.88 695.76
## moderate_EDICT_EIF 7 709.74 729.13 -347.87 695.74 0.0231 1 0.8791