knitr::opts_chunk$set(echo = TRUE)
options(digits = 4)
library(haven); library(dplyr); library(tidyr) # for tidying data
library(hms) # for time variables
library(sjlabelled) # for codebook
library(psych) # for descriptives
library(ggplot2); library(corrplot); library(patchwork); library(interactions) # for visualizations
library(nlme); library(lmerTest) # for multilevel modelling
library(car); library(emmeans) # for anova
library(effectsize) # for eta squared
library(brms); library(bridgesampling) # for model comparisons
library(MuMIn) # for lme model r-square
library(performance) # for mlm icc
library(lavaan); library(semPlot) # for FA
options(contrasts = c("contr.sum", "contr.poly")) # to run type 3 sum of squares ANOVA
# read baseline 1 data
baseline1_data <- read_sav("C:/Users/v/Desktop/Stanford/Culture and Emotion Lab/EMAdata/NIMH Q1 071709.sav") %>%
dplyr::select(subnum, age, gender,
starts_with("svs"), starts_with("scs"), starts_with("Takada"), starts_with("ces")) %>% zap_label()
names(baseline1_data) <- gsub(x = names(baseline1_data), pattern = "cesd", replacement = "b1_cesd")
# read baseline 2 data
baseline_data <- read_sav("C:/Users/v/Desktop/Stanford/Culture and Emotion Lab/EMAdata/NIMH Q2 121508.sav") %>%
dplyr::select(subnum, ethnicity, tier, 'i$enth2':'i$sere2', 'aa$enth':'aa$sere', 'r$enth2':'r$sere2') %>%
zap_label() %>%
mutate(across(where(~"haven_labelled" %in% class(.)), ~as.numeric(.))) %>%
dplyr::filter(ethnicity == 0 | ethnicity == 3)
names(baseline_data) <- gsub(x = names(baseline_data), pattern = "\\$", replacement = ".")
names(baseline_data) <- gsub(x = names(baseline_data), pattern = "cesd", replacement = "b2_cesd")
baseline_data = merge(baseline1_data,
baseline_data,
by = "subnum")
# create ipsatized AVI items
baseline_data = baseline_data %>%
rowwise() %>%
dplyr::mutate(
ethnicity = factor(ethnicity,
levels = c(0, 3),
labels = c("EA","BC")),
# create intermediate variables for calculating ipsatize scores
rMean = mean(c_across(starts_with("r.")), na.rm = TRUE),
rSd = sd(c_across(starts_with("r.")), na.rm = TRUE),
iMean = mean(c_across(starts_with("i.")), na.rm = TRUE),
iSd = sd(c_across(starts_with("i.")), na.rm = TRUE),
aaMean = mean(c_across(starts_with("aa.")), na.rm = TRUE),
aaSd = sd(c_across(starts_with("aa.")), na.rm = TRUE)) %>%
dplyr::mutate( # create ipsatized item scores
across(starts_with("r."),
~ as.numeric((.x - rMean) / rSd),
.names = "{.col}_i"),
across(starts_with("i."),
~ as.numeric((.x - iMean) / iSd),
.names = "{.col}_i"),
across(starts_with("aa."),
~ as.numeric((.x - aaMean) / aaSd),
.names = "{.col}_i"))
# remove repeated subnum rows (for subnums 7046, 7047, 7425, 7428)
baseline_data = baseline_data %>%
dplyr::mutate(
remove = case_when(subnum == "7046" & is.na(age) ~ 1,
subnum == "7047" & is.na(age) ~ 1,
subnum == "7425" & is.na(age) ~ 1,
subnum == "7428" & is.na(age) ~ 1,
TRUE ~ 0)) %>%
dplyr::filter(remove == 0) %>%
dplyr::select(-remove) %>%
select(subnum, ethnicity, age, gender, tier, everything())
rm(baseline1_data)
# read daily data
daily_data <- read_sav("C:/Users/v/Desktop/Stanford/Culture and Emotion Lab/EMAdata/NIMH ES 101309.sav") %>%
zap_label() %>%
mutate(across(where(~"haven_labelled" %in% class(.)), ~as.numeric(.))) %>%
dplyr::filter(ethnicity == 0 | ethnicity == 3) %>%
dplyr::mutate(subnum = as.factor(subnum)) %>%
mutate_if(is.numeric, ~ifelse(. > 100, NA_real_, .))
daily_data <- daily_data[,colSums(is.na(daily_data)) != nrow(daily_data)]
# Create a list to store the subsets
subset_list <- list()
# Extract all variable names that match the pattern "D$SELF" followed by numbers
pattern_matches <- grep("D\\$SELF[0-9]+$", names(daily_data), value = TRUE)
# Extract the numeric parts from these matches and convert them to numeric
numeric_suffixes <- as.numeric(gsub("D\\$SELF", "", pattern_matches))
# Find the maximum value among these suffixes
last_number <- max(numeric_suffixes, na.rm = TRUE)
# Loop through 1 to last_number
for (i in 1:last_number) {
# Create column selection strings
start_col <- paste0("datetime", i)
end_col <- paste0("D$SELF", i)
# Subset the dataset
subset <- daily_data %>%
dplyr::select(subnum:syear, start_col:end_col)
# Store the subset in the list
subset_list[[i]] <- subset
}
# Rename variables and add a column for dataframe number
daily_data <- lapply(seq_along(subset_list), function(i) {
subset <- subset_list[[i]]
subset <- subset %>%
rename_all(~ gsub(paste0(i, "$"), "", .)) %>%
mutate(EMAno = i) %>%
dplyr::select(subnum, EMAno, age:syear, everything())
return(subset)
})
# Combine all the tibbles into one long dataframe
daily_data <- do.call(bind_rows, daily_data) %>%
dplyr::arrange(subnum, EMAno) %>%
dplyr::filter(datetime != "" & datetime != "." )
daily_data <- daily_data %>%
dplyr::mutate(
day = substr(datetime, 1, 3),
date = paste(substr(datetime, 5, 10),
substr(datetime, nchar(datetime) - 4 + 1, nchar(datetime))),
time = substr(datetime, 12, 19)) %>%
dplyr::select(subnum, EMAno, datetime, date, time, day, everything())
names(daily_data) <- gsub(x = names(daily_data), pattern = "\\$", replacement = ".")
daily_data <- daily_data %>%
dplyr::mutate(
R.RELAT = factor(R.RELAT,
levels = c(1,2,3,4,5,6,7,8,9,10,11),
labels = c("Family","Sig Other","Friend","Date",
"Supervisor","Supervisee","Coworker",
"Acquaitance","Just Met","stranger","Other")),
I.PARE = factor(I.PARE,
levels = c(1,2,3,4,5,6,7,8,9,10,11),
labels = c("Family","Sig Other","Friend","Date",
"Supervisor","Supervisee","Coworker",
"Acquaitance","Just Met","stranger","Other")),
R.A.PL = R.A.PL -4,
ethnicity = factor(ethnicity,
levels = c(0,3),
labels = c("EA","BC")),
time = hms(seconds = as.numeric(substr(time, 7, 8)),
minutes = as.numeric(substr(time, 4, 5)),
hours = as.numeric(substr(time, 1, 2))),
R.ACT = factor(R.ACT,
levels = c(1,2,3,4,5,6,7,8,9,10,11),
labels = c("Sleeping/Resting", "Eating/Drinking",
"Taking care of Personal Needs", "Taking care of Other's Needs",
"Studying", "Working","Exercising",
"Entertaining Self", "Entertaining Others",
"Errands/Chores", "Other")),
R.A.T = factor(R.A.T,
levels = c(1,2,3,4),
labels = c("Study", "Work", "Leisure", "Other")))
rm(subset, subset_list, end_col, start_col, i, last_number, pattern_matches, numeric_suffixes)
# make column for next ping negative affect intensity, next time of EMA, and time between EMA pings
daily_data <- daily_data %>% ungroup() %>%
group_by(subnum) %>%
dplyr::mutate(
next_dateOfEMA = dplyr::lead(date, n = 1L)) %>%
dplyr::mutate(
next_timeOfEMA = dplyr::lead(time, n = 1L),
next_secondsBetween = case_when(is.na(next_dateOfEMA) ~ NA,
next_dateOfEMA == date ~ next_timeOfEMA - time,
next_dateOfEMA != date ~ (hms(hours = 23, minutes = 59, seconds = 59) - time) +
(next_timeOfEMA - hms(00,00,00)))) %>%
dplyr::filter(next_secondsBetween > 60) %>% # remove EMA points which are less than 1 minute from previous EMA point
ungroup() %>%
group_by(subnum) %>%
dplyr::mutate(
next_dateOfEMA = dplyr::lead(date, n = 1L)) %>%
dplyr::mutate(
next_timeOfEMA = dplyr::lead(time, n = 1L),
next_secondsBetween = case_when(is.na(next_dateOfEMA) ~ NA,
next_dateOfEMA == date ~ next_timeOfEMA - time,
next_dateOfEMA != date ~ (hms(hours = 23, minutes = 59, seconds = 59) - time) +
(next_timeOfEMA - hms(00,00,00))),
next_social = dplyr::lead(R.RELAT, n = 1L),
next_presenceOfPeople = dplyr::lead(R.PEOP, n = 1L),
next_activity = dplyr::lead(R.ACT, n = 1L),
next_activityType = dplyr::lead(R.A.T, n = 1L)) %>%
dplyr::mutate(
next_hoursBetween = as.numeric(substr(next_secondsBetween, 1, length(next_secondsBetween)-6)) /60 /60,
change_Social = case_when(is.na(next_social) | is.na(R.RELAT) ~ NA_real_,
next_social != R.RELAT ~ 1,
TRUE ~ 0),
change_toAlone = case_when(is.na(next_presenceOfPeople) | is.na(R.PEOP) ~ NA_real_,
next_presenceOfPeople != R.PEOP & next_presenceOfPeople == 0 ~ 1,
TRUE ~ 0),
change_activity = case_when(is.na(next_activity) | is.na(R.ACT) ~ NA_real_,
next_activity != R.ACT ~ 1,
TRUE ~ 0),
change_activityType = case_when(is.na(next_activityType) | is.na(R.A.T) ~ NA_real_,
next_activityType != R.A.T ~ 1,
TRUE ~ 0)) %>%
dplyr::select(subnum:date,next_dateOfEMA, time, next_timeOfEMA, next_secondsBetween, next_hoursBetween, everything())
## there are some issues with the data, where some later EMAs have dates/ times that are earlier than the previous ping, and so remove them
## additionally, for subnum = 7046 and 7047, there are issues with the EMA data where each entry is repeated
## we will remove the duplicate rows, and replace "gender" and "school" as NA since it has different values for each duplicate EMA record
daily_data <- daily_data %>%
dplyr::filter(next_hoursBetween > 0 | is.na(next_hoursBetween)) %>%
dplyr::mutate(
gender = case_when(subnum == 7046 ~ NA_real_,
subnum == 7047 ~ NA_real_,
TRUE ~ gender),
school = case_when(subnum == 7046 ~ NA_real_,
subnum == 7047 ~ NA_real_,
TRUE ~ school))
## recreate EMAno variable, since some EMA instances were removed
daily_data <- daily_data %>% group_by(subnum) %>%
dplyr::mutate(EMAno = row_number(),
date2 = lubridate::mdy(date),
DAYno = as.integer(date2 - min(date2) + 1)) %>%
ungroup() %>%
dplyr::select(subnum, EMAno, DAYno, everything(), -date2)
exit_data <- read_sav("C:/Users/v/Desktop/Stanford/Culture and Emotion Lab/EMAdata/NIMH ES exit q_combined.sav") %>%
zap_label() %>%
mutate(across(where(~"haven_labelled" %in% class(.)), ~as.numeric(.))) %>%
dplyr::filter(ethnicity == 0 | ethnicity == 3) %>%
dplyr::select(subnum, ethnicity, tier, 'e_r$enth':'e_r$disg', 'e_a$enth':'e_a$disg', 'e_int$na', 'e_int$pa') %>%
dplyr::mutate(
ethnicity = factor(ethnicity,
levels = c(0, 3),
labels = c("EA","BC")))
names(exit_data) <- gsub(x = names(exit_data), pattern = "\\$", replacement = ".")
baseline_subnum <- baseline_data %>% select(subnum) %>% distinct()
daily_subnum <- daily_data %>% select(subnum) %>% distinct()
exit_subnum <- exit_data %>% select(subnum) %>% distinct()
didAll <- intersect(intersect(baseline_subnum$subnum, daily_subnum$subnum), exit_subnum$subnum)
# Filter data to contain only participants in didAll
baseline_data <- baseline_data %>% filter(subnum %in% didAll)
daily_data <- daily_data %>% filter(subnum %in% didAll)
exit_data <- exit_data %>% filter(subnum %in% didAll)
Cronbach Alphas (non-ipsatized items):
# avoided HAN
avoidedHAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.fear, aa.host, aa.nerv))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.fear, aa.host, aa.nerv))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided HAN")
## [1] "avoided HAN"
avoidedHAN_alpha
## $EA
## [1] 0.69
##
## $BC
## [1] 0.81
##
## $Combined
## [1] 0.81
# avoided NEG
avoidedNEG_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.sadx, aa.lone, aa.unha))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.sadx, aa.lone, aa.unha))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided NEG")
## [1] "avoided NEG"
avoidedNEG_alpha
## $EA
## [1] 0.76
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.81
# avoided LAN
avoidedLAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.slug, aa.slee, aa.dull))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.slug, aa.slee, aa.dull))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided LAN")
## [1] "avoided LAN"
avoidedLAN_alpha
## $EA
## [1] 0.75
##
## $BC
## [1] 0.74
##
## $Combined
## [1] 0.74
# overall avoided NA
avoidedNA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.fear, aa.host, aa.nerv,
aa.sadx, aa.lone, aa.unha,
aa.slug, aa.slee, aa.dull))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.fear, aa.host, aa.nerv,
aa.sadx, aa.lone, aa.unha,
aa.slug, aa.slee, aa.dull))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided NA")
## [1] "avoided NA"
avoidedNA_alpha
## $EA
## [1] 0.87
##
## $BC
## [1] 0.91
##
## $Combined
## [1] 0.91
# avoided HAP
avoidedHAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.enth, aa.exci, aa.elat))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.enth, aa.exci, aa.elat))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided HAP")
## [1] "avoided HAP"
avoidedHAP_alpha
## $EA
## [1] 0.66
##
## $BC
## [1] 0.67
##
## $Combined
## [1] 0.67
# avoided POS
avoidedPOS_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.happ, aa.sati, aa.cont))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.happ, aa.sati, aa.cont))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided POS")
## [1] "avoided POS"
avoidedPOS_alpha
## $EA
## [1] 0.86
##
## $BC
## [1] 0.78
##
## $Combined
## [1] 0.82
# avoided LAP
avoidedLAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.peac, aa.calm, aa.rela))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.peac, aa.calm, aa.rela))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided LAP")
## [1] "avoided LAP"
avoidedLAP_alpha
## $EA
## [1] 0.77
##
## $BC
## [1] 0.74
##
## $Combined
## [1] 0.76
# overall avoided PA
avoidedPA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.enth, aa.exci, aa.elat,
aa.happ, aa.sati, aa.cont,
aa.peac, aa.calm, aa.rela))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.enth, aa.exci, aa.elat,
aa.happ, aa.sati, aa.cont,
aa.peac, aa.calm, aa.rela))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided PA")
## [1] "avoided PA"
avoidedPA_alpha
## $EA
## [1] 0.88
##
## $BC
## [1] 0.87
##
## $Combined
## [1] 0.88
# ideal HAN
idealHAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.fear2, i.host2, i.nerv2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.fear2, i.host2, i.nerv2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal HAN")
## [1] "ideal HAN"
idealHAN_alpha
## $EA
## [1] 0.7
##
## $BC
## [1] 0.38
##
## $Combined
## [1] 0.56
# ideal NEG
idealNEG_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.sadx2, i.lone2, i.unha2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.sadx2, i.lone2, i.unha2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal NEG")
## [1] "ideal NEG"
idealNEG_alpha
## $EA
## [1] 0.73
##
## $BC
## [1] 0.75
##
## $Combined
## [1] 0.78
# ideal LAN
idealLAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.slug2, i.slee2, i.dull2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.slug2, i.slee2, i.dull2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal LAN")
## [1] "ideal LAN"
idealLAN_alpha
## $EA
## [1] 0.32
##
## $BC
## [1] 0.71
##
## $Combined
## [1] 0.67
# overall ideal NA
idealNA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.fear2, i.host2, i.nerv2,
i.sadx2, i.lone2, i.unha2,
i.slug2, i.slee2, i.dull2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.fear2, i.host2, i.nerv2,
i.sadx2, i.lone2, i.unha2,
i.slug2, i.slee2, i.dull2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal NA")
## [1] "ideal NA"
idealNA_alpha
## $EA
## [1] 0.83
##
## $BC
## [1] 0.79
##
## $Combined
## [1] 0.83
# ideal HAP
idealHAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.enth2, i.exci2, i.elat2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.enth2, i.exci2, i.elat2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal HAP")
## [1] "ideal HAP"
idealHAP_alpha
## $EA
## [1] 0.69
##
## $BC
## [1] 0.71
##
## $Combined
## [1] 0.71
# ideal POS
idealPOS_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.happ2, i.sati2, i.cont2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.happ2, i.sati2, i.cont2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal POS")
## [1] "ideal POS"
idealPOS_alpha
## $EA
## [1] 0.65
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.78
# ideal LAP
idealLAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.peac2, i.calm2, i.rela2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.peac2, i.calm2, i.rela2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal LAP")
## [1] "ideal LAP"
idealLAP_alpha
## $EA
## [1] 0.68
##
## $BC
## [1] 0.57
##
## $Combined
## [1] 0.62
# overall ideal PA
idealPA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.enth2, i.exci2, i.elat2,
i.happ2, i.sati2, i.cont2,
i.peac2, i.calm2, i.rela2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.enth2, i.exci2, i.elat2,
i.happ2, i.sati2, i.cont2,
i.peac2, i.calm2, i.rela2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal PA")
## [1] "ideal PA"
idealPA_alpha
## $EA
## [1] 0.73
##
## $BC
## [1] 0.84
##
## $Combined
## [1] 0.82
# actual HAN
actualHAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.fear2, r.host2, r.nerv2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.fear2, r.host2, r.nerv2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual HAN")
## [1] "actual HAN"
actualHAN_alpha
## $EA
## [1] 0.62
##
## $BC
## [1] 0.37
##
## $Combined
## [1] 0.51
# actual NEG
actualNEG_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.sadx2, r.lone2, r.unha2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.sadx2, r.lone2, r.unha2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual NEG")
## [1] "actual NEG"
actualNEG_alpha
## $EA
## [1] 0.64
##
## $BC
## [1] 0.61
##
## $Combined
## [1] 0.62
# actual LAN
actualLAN_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.slug2, r.slee2, r.dull2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.slug2, r.slee2, r.dull2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual LAN")
## [1] "actual LAN"
actualLAN_alpha
## $EA
## [1] 0.71
##
## $BC
## [1] 0.69
##
## $Combined
## [1] 0.7
# overall actual NA
actualNA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.fear2, r.host2, r.nerv2,
r.sadx2, r.lone2, r.unha2,
r.slug2, r.slee2, r.dull2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.fear2, r.host2, r.nerv2,
r.sadx2, r.lone2, r.unha2,
r.slug2, r.slee2, r.dull2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual NA")
## [1] "actual NA"
actualNA_alpha
## $EA
## [1] 0.78
##
## $BC
## [1] 0.78
##
## $Combined
## [1] 0.78
# actual HAP
actualHAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.enth2, r.exci2, r.elat2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.enth2, r.exci2, r.elat2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual HAP")
## [1] "actual HAP"
actualHAP_alpha
## $EA
## [1] 0.74
##
## $BC
## [1] 0.73
##
## $Combined
## [1] 0.72
# actual POS
actualPOS_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.happ2, r.sati2, r.cont2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.happ2, r.sati2, r.cont2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual POS")
## [1] "actual POS"
actualPOS_alpha
## $EA
## [1] 0.87
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.83
# actual LAP
actualLAP_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.peac2, r.calm2, r.rela2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.peac2, r.calm2, r.rela2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual LAP")
## [1] "actual LAP"
actualLAP_alpha
## $EA
## [1] 0.82
##
## $BC
## [1] 0.69
##
## $Combined
## [1] 0.75
# overall actual PA
actualPA_alpha <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.enth2, r.exci2, r.elat2,
r.happ2, r.sati2, r.cont2,
r.peac2, r.calm2, r.rela2))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.enth2, r.exci2, r.elat2,
r.happ2, r.sati2, r.cont2,
r.peac2, r.calm2, r.rela2))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual PA")
## [1] "actual PA"
actualPA_alpha
## $EA
## [1] 0.88
##
## $BC
## [1] 0.84
##
## $Combined
## [1] 0.85
Cronbach Alphas (ipsatized items):
# avoided HAN
avoidedHAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.fear_i, aa.host_i, aa.nerv_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.fear_i, aa.host_i, aa.nerv_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided HAN")
## [1] "avoided HAN"
avoidedHAN_alpha
## $EA
## [1] 0.69
##
## $BC
## [1] 0.81
##
## $Combined
## [1] 0.81
# avoided NEG
avoidedNEG_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.sadx_i, aa.lone_i, aa.unha_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.sadx_i, aa.lone_i, aa.unha_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided NEG")
## [1] "avoided NEG"
avoidedNEG_alpha
## $EA
## [1] 0.76
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.81
# avoided LAN
avoidedLAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.slug_i, aa.slee_i, aa.dull_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.slug_i, aa.slee_i, aa.dull_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided LAN")
## [1] "avoided LAN"
avoidedLAN_alpha
## $EA
## [1] 0.75
##
## $BC
## [1] 0.74
##
## $Combined
## [1] 0.74
# overall avoided NA
avoidedNA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.fear_i, aa.host_i, aa.nerv_i,
aa.sadx_i, aa.lone_i, aa.unha_i,
aa.slug_i, aa.slee_i, aa.dull_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.fear_i, aa.host_i, aa.nerv_i,
aa.sadx_i, aa.lone_i, aa.unha_i,
aa.slug_i, aa.slee_i, aa.dull_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided NA")
## [1] "avoided NA"
avoidedNA_alpha
## $EA
## [1] 0.87
##
## $BC
## [1] 0.91
##
## $Combined
## [1] 0.91
# avoided HAP
avoidedHAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.enth_i, aa.exci_i, aa.elat_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.enth_i, aa.exci_i, aa.elat_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided HAP")
## [1] "avoided HAP"
avoidedHAP_alpha
## $EA
## [1] 0.66
##
## $BC
## [1] 0.67
##
## $Combined
## [1] 0.67
# avoided POS
avoidedPOS_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.happ_i, aa.sati_i, aa.cont_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.happ_i, aa.sati_i, aa.cont_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided POS")
## [1] "avoided POS"
avoidedPOS_alpha
## $EA
## [1] 0.86
##
## $BC
## [1] 0.78
##
## $Combined
## [1] 0.82
# avoided LAP
avoidedLAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.peac_i, aa.calm_i, aa.rela_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.peac_i, aa.calm_i, aa.rela_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided LAP")
## [1] "avoided LAP"
avoidedLAP_alpha
## $EA
## [1] 0.77
##
## $BC
## [1] 0.74
##
## $Combined
## [1] 0.76
# overall avoided PA
avoidedPA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(aa.enth_i, aa.exci_i, aa.elat_i,
aa.happ_i, aa.sati_i, aa.cont_i,
aa.peac_i, aa.calm_i, aa.rela_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(aa.enth_i, aa.exci_i, aa.elat_i,
aa.happ_i, aa.sati_i, aa.cont_i,
aa.peac_i, aa.calm_i, aa.rela_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("avoided PA")
## [1] "avoided PA"
avoidedPA_alpha
## $EA
## [1] 0.88
##
## $BC
## [1] 0.87
##
## $Combined
## [1] 0.88
# ideal HAN
idealHAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.fear2_i, i.host2_i, i.nerv2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.fear2_i, i.host2_i, i.nerv2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( i.host2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' optionSome items ( i.host2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("ideal HAN")
## [1] "ideal HAN"
idealHAN_alpha
## $EA
## [1] 0.7
##
## $BC
## [1] 0.38
##
## $Combined
## [1] 0.56
# ideal NEG
idealNEG_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.sadx2_i, i.lone2_i, i.unha2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.sadx2_i, i.lone2_i, i.unha2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal NEG")
## [1] "ideal NEG"
idealNEG_alpha
## $EA
## [1] 0.73
##
## $BC
## [1] 0.75
##
## $Combined
## [1] 0.78
# ideal LAN
idealLAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.slug2_i, i.slee2_i, i.dull2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.slug2_i, i.slee2_i, i.dull2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( i.dull2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("ideal LAN")
## [1] "ideal LAN"
idealLAN_alpha
## $EA
## [1] 0.32
##
## $BC
## [1] 0.71
##
## $Combined
## [1] 0.67
# overall ideal NA
idealNA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.fear2_i, i.host2_i, i.nerv2_i,
i.sadx2_i, i.lone2_i, i.unha2_i,
i.slug2_i, i.slee2_i, i.dull2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.fear2_i, i.host2_i, i.nerv2_i,
i.sadx2_i, i.lone2_i, i.unha2_i,
i.slug2_i, i.slee2_i, i.dull2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( i.host2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' optionSome items ( i.host2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("ideal NA")
## [1] "ideal NA"
idealNA_alpha
## $EA
## [1] 0.83
##
## $BC
## [1] 0.79
##
## $Combined
## [1] 0.83
# ideal HAP
idealHAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.enth2_i, i.exci2_i, i.elat2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.enth2_i, i.exci2_i, i.elat2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal HAP")
## [1] "ideal HAP"
idealHAP_alpha
## $EA
## [1] 0.69
##
## $BC
## [1] 0.71
##
## $Combined
## [1] 0.71
# ideal POS
idealPOS_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.happ2_i, i.sati2_i, i.cont2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.happ2_i, i.sati2_i, i.cont2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("ideal POS")
## [1] "ideal POS"
idealPOS_alpha
## $EA
## [1] 0.65
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.78
# ideal LAP
idealLAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.peac2_i, i.calm2_i, i.rela2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.peac2_i, i.calm2_i, i.rela2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( i.rela2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' optionSome items ( i.rela2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("ideal LAP")
## [1] "ideal LAP"
idealLAP_alpha
## $EA
## [1] 0.68
##
## $BC
## [1] 0.57
##
## $Combined
## [1] 0.62
# overall ideal PA
idealPA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(i.enth2_i, i.exci2_i, i.elat2_i,
i.happ2_i, i.sati2_i, i.cont2_i,
i.peac2_i, i.calm2_i, i.rela2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(i.enth2_i, i.exci2_i, i.elat2_i,
i.happ2_i, i.sati2_i, i.cont2_i,
i.peac2_i, i.calm2_i, i.rela2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( i.sati2_i i.cont2_i i.peac2_i i.calm2_i i.rela2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' optionSome items ( i.enth2_i i.peac2_i i.calm2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' optionSome items ( i.enth2_i i.peac2_i i.calm2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("ideal PA")
## [1] "ideal PA"
idealPA_alpha
## $EA
## [1] 0.73
##
## $BC
## [1] 0.84
##
## $Combined
## [1] 0.82
# actual HAN
actualHAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.fear2_i, r.host2_i, r.nerv2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.fear2_i, r.host2_i, r.nerv2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
## Some items ( r.host2_i ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
print("actual HAN")
## [1] "actual HAN"
actualHAN_alpha
## $EA
## [1] 0.62
##
## $BC
## [1] 0.37
##
## $Combined
## [1] 0.51
# actual NEG
actualNEG_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.sadx2_i, r.lone2_i, r.unha2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.sadx2_i, r.lone2_i, r.unha2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual NEG")
## [1] "actual NEG"
actualNEG_alpha
## $EA
## [1] 0.64
##
## $BC
## [1] 0.61
##
## $Combined
## [1] 0.62
# actual LAN
actualLAN_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.slug2_i, r.slee2_i, r.dull2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.slug2_i, r.slee2_i, r.dull2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual LAN")
## [1] "actual LAN"
actualLAN_alpha
## $EA
## [1] 0.71
##
## $BC
## [1] 0.69
##
## $Combined
## [1] 0.7
# overall actual NA
actualNA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.fear2_i, r.host2_i, r.nerv2_i,
r.sadx2_i, r.lone2_i, r.unha2_i,
r.slug2_i, r.slee2_i, r.dull2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.fear2_i, r.host2_i, r.nerv2_i,
r.sadx2_i, r.lone2_i, r.unha2_i,
r.slug2_i, r.slee2_i, r.dull2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual NA")
## [1] "actual NA"
actualNA_alpha
## $EA
## [1] 0.78
##
## $BC
## [1] 0.78
##
## $Combined
## [1] 0.78
# actual HAP
actualHAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.enth2_i, r.exci2_i, r.elat2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.enth2_i, r.exci2_i, r.elat2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual HAP")
## [1] "actual HAP"
actualHAP_alpha
## $EA
## [1] 0.74
##
## $BC
## [1] 0.73
##
## $Combined
## [1] 0.72
# actual POS
actualPOS_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.happ2_i, r.sati2_i, r.cont2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.happ2_i, r.sati2_i, r.cont2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual POS")
## [1] "actual POS"
actualPOS_alpha
## $EA
## [1] 0.87
##
## $BC
## [1] 0.8
##
## $Combined
## [1] 0.83
# actual LAP
actualLAP_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.peac2_i, r.calm2_i, r.rela2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.peac2_i, r.calm2_i, r.rela2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual LAP")
## [1] "actual LAP"
actualLAP_alpha
## $EA
## [1] 0.82
##
## $BC
## [1] 0.69
##
## $Combined
## [1] 0.75
# overall actual PA
actualPA_alpha_ipsatized <- setNames(
lapply(c("EA", "BC", "Combined"),
function(x) {
if (x == "Combined") {
psych::alpha(baseline_data %>%
dplyr::select(r.enth2_i, r.exci2_i, r.elat2_i,
r.happ2_i, r.sati2_i, r.cont2_i,
r.peac2_i, r.calm2_i, r.rela2_i))$total$raw_alpha %>% round(2)
} else {
psych::alpha(baseline_data %>%
dplyr::filter(ethnicity == x) %>%
dplyr::select(r.enth2_i, r.exci2_i, r.elat2_i,
r.happ2_i, r.sati2_i, r.cont2_i,
r.peac2_i, r.calm2_i, r.rela2_i))$total$raw_alpha %>% round(2)
}
}),
c("EA", "BC", "Combined")
)
print("actual PA")
## [1] "actual PA"
actualPA_alpha
## $EA
## [1] 0.88
##
## $BC
## [1] 0.84
##
## $Combined
## [1] 0.85
Visualize distributions
baseline_data <- baseline_data %>%
dplyr::mutate(
# avoided affect
aa.HAP = mean(c(aa.enth, aa.exci, aa.elat), na.rm = TRUE),
aa.HAP_i = mean(c(aa.enth_i, aa.exci_i, aa.elat_i), na.rm = TRUE),
aa.POS = mean(c(aa.happ, aa.sati, aa.cont), na.rm = TRUE),
aa.POS_i = mean(c(aa.happ_i, aa.sati_i, aa.cont_i), na.rm = TRUE),
aa.LAP = mean(c(aa.peac, aa.calm, aa.rela), na.rm = TRUE),
aa.LAP_i = mean(c(aa.peac_i, aa.calm_i, aa.rela_i), na.rm = TRUE),
aa.PA = mean(c(aa.enth, aa.exci, aa.elat,
aa.peac, aa.calm, aa.rela,
aa.happ, aa.sati, aa.cont), na.rm = TRUE),
aa.PA_i = mean(c(aa.enth_i, aa.exci_i, aa.elat_i,
aa.peac_i, aa.calm_i, aa.rela_i,
aa.happ_i, aa.sati_i, aa.cont_i), na.rm = TRUE),
aa.HAN = mean(c(aa.fear, aa.host, aa.nerv), na.rm = TRUE),
aa.HAN_i = mean(c(aa.fear_i, aa.host_i, aa.nerv_i), na.rm = TRUE),
aa.NEG = mean(c(aa.sadx, aa.lone, aa.unha), na.rm = TRUE),
aa.NEG_i = mean(c(aa.sadx_i, aa.lone_i, aa.unha_i), na.rm = TRUE),
aa.LAN = mean(c(aa.slug, aa.slee, aa.dull), na.rm = TRUE),
aa.LAN_i = mean(c(aa.slug_i, aa.slee_i, aa.dull_i), na.rm = TRUE),
aa.NA = mean(c(aa.fear, aa.host, aa.nerv,
aa.sadx, aa.lone, aa.unha,
aa.slug, aa.slee, aa.dull), na.rm = TRUE),
aa.NA_i = mean(c(aa.fear_i, aa.host_i, aa.nerv_i,
aa.sadx_i, aa.lone_i, aa.unha_i,
aa.slug_i, aa.slee_i, aa.dull_i), na.rm = TRUE),
# ideal affect
i.HAP = mean(c(i.enth2, i.exci2, i.elat2), na.rm = TRUE),
i.HAP_i = mean(c(i.enth2_i, i.exci2_i, i.elat2_i), na.rm = TRUE),
i.POS = mean(c(i.happ2, i.sati2, i.cont2), na.rm = TRUE),
i.POS_i = mean(c(i.happ2_i, i.sati2_i, i.cont2_i), na.rm = TRUE),
i.LAP = mean(c(i.peac2, i.calm2, i.rela2), na.rm = TRUE),
i.LAP_i = mean(c(i.peac2_i, i.calm2_i, i.rela2_i), na.rm = TRUE),
i.PA = mean(c(i.enth2, i.exci2, i.elat2,
i.peac2, i.calm2, i.rela2,
i.happ2, i.sati2, i.cont2), na.rm = TRUE),
i.PA_i = mean(c(i.enth2_i, i.exci2_i, i.elat2_i,
i.peac2_i, i.calm2_i, i.rela2_i,
i.happ2_i, i.sati2_i, i.cont2_i), na.rm = TRUE),
i.HAN = mean(c(i.fear2, i.host2, i.nerv2), na.rm = TRUE),
i.HAN_i = mean(c(i.fear2_i, i.host2_i, i.nerv2_i), na.rm = TRUE),
i.NEG = mean(c(i.sadx2, i.lone2, i.unha2), na.rm = TRUE),
i.NEG_i = mean(c(i.sadx2_i, i.lone2_i, i.unha2_i), na.rm = TRUE),
i.LAN = mean(c(i.slug2, i.slee2, i.dull2), na.rm = TRUE),
i.LAN_i = mean(c(i.slug2_i, i.slee2_i, i.dull2_i), na.rm = TRUE),
i.NA = mean(c(i.fear2, i.host2, i.nerv2,
i.sadx2, i.lone2, i.unha2,
i.slug2, i.slee2, i.dull2), na.rm = TRUE),
i.NA_i = mean(c(i.fear2_i, i.host2_i, i.nerv2_i,
i.sadx2_i, i.lone2_i, i.unha2_i,
i.slug2_i, i.slee2_i, i.dull2_i), na.rm = TRUE),
# actual affect
r.HAN = mean(c(r.fear2, r.host2, r.nerv2), na.rm = TRUE),
r.HAN_i = mean(c(r.fear2_i, r.host2_i, r.nerv2_i), na.rm = TRUE),
r.NEG = mean(c(r.sadx2, r.lone2, r.unha2), na.rm = TRUE),
r.NEG_i = mean(c(r.sadx2_i, r.lone2_i, r.unha2_i), na.rm = TRUE),
r.LAN = mean(c(r.slug2, r.slee2, r.dull2), na.rm = TRUE),
r.LAN_i = mean(c(r.slug2_i, r.slee2_i, r.dull2_i), na.rm = TRUE),
r.NA = mean(c(r.fear2, r.host2, r.nerv2,
r.sadx2, r.lone2, r.unha2,
r.slug2, r.slee2, r.dull2), na.rm = TRUE),
r.NA_i = mean(c(r.fear2_i, r.host2_i, r.nerv2_i,
r.sadx2_i, r.lone2_i, r.unha2_i,
r.slug2_i, r.slee2_i, r.dull2_i), na.rm = TRUE),
r.HAP = mean(c(r.enth2, r.exci2, r.elat2), na.rm = TRUE),
r.HAP_i = mean(c(r.enth2_i, r.exci2_i, r.elat2_i), na.rm = TRUE),
r.POS = mean(c(r.happ2, r.sati2, r.cont2), na.rm = TRUE),
r.POS_i = mean(c(r.happ2_i, r.sati2_i, r.cont2_i), na.rm = TRUE),
r.LAP = mean(c(r.peac2, r.calm2, r.rela2), na.rm = TRUE),
r.LAP_i = mean(c(r.peac2_i, r.calm2_i, r.rela2_i), na.rm = TRUE),
r.PA = mean(c(r.enth2, r.exci2, r.elat2,
r.peac2, r.calm2, r.rela2,
r.happ2, r.sati2, r.cont2), na.rm = TRUE),
r.PA_i = mean(c(r.enth2_i, r.exci2_i, r.elat2_i,
r.peac2_i, r.calm2_i, r.rela2_i,
r.happ2_i, r.sati2_i, r.cont2_i), na.rm = TRUE)
) %>%
dplyr::mutate(
maxPositivity_i = i.PA_i - i.NA_i,
maxPositivity = i.PA - i.NA,
)
rm(actualHAN_alpha, actualLAN_alpha, actualNA_alpha, actualNEG_alpha,
avoidedHAN_alpha, avoidedLAN_alpha, avoidedNA_alpha, avoidedNEG_alpha,
idealHAN_alpha, idealLAN_alpha, idealNA_alpha, idealNEG_alpha)
Visualize distributions
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 914 rows containing non-finite values (`stat_bin()`).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1045 rows containing non-finite values (`stat_bin()`).
daily_data <-
daily_data %>%
group_by(subnum) %>%
dplyr::mutate(
R.mean = mean(c(R.ANXI, R.ENTH, R.HAPP, R.CALM, R.INAC, R.BORE, R.SADX, R.ANGR, R.ACTI, R.PLEA, R.EXCI, R.RELA), na.rm = TRUE),
R.sd = sd(c(R.ANXI, R.ENTH, R.HAPP, R.CALM, R.INAC, R.BORE, R.SADX, R.ANGR, R.ACTI, R.PLEA, R.EXCI, R.RELA), na.rm = TRUE)) %>%
ungroup() %>%
dplyr::mutate(
R.ANXI_i = (R.ANXI-R.mean)/R.sd,
R.ENTH_i = (R.ENTH-R.mean)/R.sd,
R.HAPP_i = (R.HAPP-R.mean)/R.sd,
R.CALM_i = (R.CALM-R.mean)/R.sd,
R.INAC_i = (R.INAC-R.mean)/R.sd,
R.BORE_i = (R.BORE-R.mean)/R.sd,
R.SADX_i = (R.SADX-R.mean)/R.sd,
R.ANGR_i = (R.ANGR-R.mean)/R.sd,
R.ACTI_i = (R.ACTI-R.mean)/R.sd,
R.PLEA_i = (R.PLEA-R.mean)/R.sd,
R.EXCI_i = (R.EXCI-R.mean)/R.sd,
R.RELA_i = (R.RELA-R.mean)/R.sd)
# calculate raw NA
daily_data <- daily_data %>%
ungroup() %>%
mutate(negAffIntensity = rowMeans(select(., R.ANXI, R.BORE, R.SADX, R.ANGR), na.rm = TRUE)) %>%
group_by(subnum) %>%
dplyr::mutate(avg_negAffIntensity_dev = mean(negAffIntensity, na.rm = TRUE)) %>%
dplyr::mutate(negAffIntensity_dev = negAffIntensity - avg_negAffIntensity_dev,
negAffIntensity_SD = sd(negAffIntensity, na.rm = TRUE)) %>%
ungroup()
# calculate ipsatized NA
daily_data <-
daily_data %>%
dplyr::mutate(
negAffIntensity_i = rowMeans(select(., R.ANXI_i, R.BORE_i, R.SADX_i, R.ANGR_i), na.rm = TRUE))%>%
group_by(subnum) %>%
dplyr::mutate(avg_negAffIntensity_i_dev = mean(negAffIntensity_i, na.rm = TRUE),
avg_R.ANXI_i_dev = mean(R.ANXI_i, na.rm = TRUE),
avg_R.BORE_i_dev = mean(R.BORE_i, na.rm = TRUE),
avg_R.SADX_i_dev = mean(R.SADX_i, na.rm = TRUE),
avg_R.ANGR_i_dev = mean(R.ANGR_i, na.rm = TRUE)) %>%
dplyr::mutate(negAffIntensity_i_dev = negAffIntensity_i - avg_negAffIntensity_i_dev,
R.ANXI_i_dev = R.ANXI_i - avg_R.ANXI_i_dev,
R.BORE_i_dev = R.BORE_i - avg_R.BORE_i_dev,
R.SADX_i_dev = R.SADX_i - avg_R.SADX_i_dev,
R.ANGR_i_dev = R.ANGR_i - avg_R.ANGR_i_dev
) %>%
ungroup()
# calculate lagged NA
daily_data <-
daily_data %>%
mutate(next_negAffIntensity = dplyr::lead(negAffIntensity, n = 1L), # raw
next_negAffIntensity_dev = dplyr::lead(negAffIntensity_dev, n = 1L), # gmc
next_negAffIntensity_i_dev = dplyr::lead(negAffIntensity_i_dev, n = 1L)) #ipsatized
Descriptives
daily_data <-
daily_data %>% group_by(subnum) %>%
dplyr::mutate(
avg_negAffIntensity = mean(negAffIntensity, na.rm = TRUE),
avg_negAffIntensity_i = mean(negAffIntensity_i, na.rm = TRUE))
print("European Americans (EA):")
## [1] "European Americans (EA):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
dplyr::select(negAffIntensity, negAffIntensity_i),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 2688 35.75 20.51 1.00 71.0 70.00 0.40
## negAffIntensity 2 2631 1.70 0.66 1.00 5.0 4.00 0.01
## negAffIntensity_i 3 2631 -0.57 0.61 -1.79 2.8 4.59 0.01
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_negAffIntensity, avg_negAffIntensity_i, negAffIntensity_SD),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 70 35.83 20.74 1.00 71.00 70.00 2.48
## avg_negAffIntensity 2 70 1.69 0.39 1.13 3.00 1.87 0.05
## avg_negAffIntensity_i 3 70 -0.58 0.35 -1.17 0.57 1.74 0.04
## negAffIntensity_SD 4 70 0.50 0.18 0.23 1.04 0.81 0.02
print("Beijing Chinese (BC):")
## [1] "Beijing Chinese (BC):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
dplyr::select(negAffIntensity, negAffIntensity_i),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 3784 119.48 27.96 72.00 167.00 95.00 0.45
## negAffIntensity 2 3742 1.67 0.70 1.00 5.00 4.00 0.01
## negAffIntensity_i 3 3742 -0.62 0.67 -2.14 3.54 5.68 0.01
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_negAffIntensity, avg_negAffIntensity_i, negAffIntensity_SD),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 96 119.50 27.86 72.00 167.00 95.00 2.84
## avg_negAffIntensity 2 96 1.67 0.37 1.06 2.80 1.75 0.04
## avg_negAffIntensity_i 3 96 -0.63 0.28 -1.14 0.03 1.16 0.03
## negAffIntensity_SD 4 96 0.57 0.19 0.13 1.44 1.31 0.02
Reliability, and ICC (Ipsatized Items)
negAffReliab_data_i = daily_data %>%
dplyr::select(subnum, ethnicity, EMAno, R.ANXI_i, R.BORE_i, R.SADX_i, R.ANGR_i) %>%
pivot_longer(cols = c(R.ANXI_i, R.BORE_i, R.SADX_i, R.ANGR_i),
names_to = "item",
values_to = "score")
# Within-persons reliability over EMA pings: RC = var(subnum:EMAno) / [var(subnum:EMAno) + var(error)]
# Full sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno), data = negAffReliab_data_i, REML = FALSE)
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff = var_person_day / (var_person_day + var_error/4)
RC_negAff
## [1] 0.5397
# EA sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno),
data = negAffReliab_data_i %>% dplyr::filter(ethnicity == "EA"), REML = FALSE,
control = lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e5)))
## boundary (singular) fit: see help('isSingular')
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff_EA = var_person_day / (var_person_day + var_error/4)
RC_negAff_EA
## [1] 0.4432
# BC sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno),
data = negAffReliab_data_i %>% dplyr::filter(ethnicity == "BC"), REML = FALSE,
control = lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e5)))
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff_BC = var_person_day / (var_person_day + var_error/4)
RC_negAff_BC
## [1] 0.5865
rm(negAffReliab_data, var_person_day, var_error)
## Warning in rm(negAffReliab_data, var_person_day, var_error): object
## 'negAffReliab_data' not found
# ICC tells you percentage of variance that is due to clustering; The larger the ICC the lower the variability is within the clusters and consequently the higher the variability is between the clusters
negAffReliab_data_i = daily_data %>%
dplyr::select(subnum, day, ethnicity, EMAno, negAffIntensity_i)
# Full sample
# run model to calcualte ICC
model <- lmer(negAffIntensity_i ~ 1 + (1 | subnum/day), data = negAffReliab_data_i, REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity_i ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data_i
##
## AIC BIC logLik deviance df.resid
## 11281 11308 -5636 11273 6369
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.655 -0.558 -0.169 0.380 6.354
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0439 0.210
## subnum (Intercept) 0.0840 0.290
## Residual 0.2930 0.541
## Number of obs: 6373, groups: day:subnum, 1155; subnum, 166
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -0.6035 0.0243 165.9242 -24.8 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.304
## Unadjusted ICC: 0.304
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.104
## subnum | 0.200
# EA sample
# run model to calcualte ICC
model <- lmer(negAffIntensity_i ~ 1 + (1 | subnum/day),
data = negAffReliab_data_i %>% dplyr::filter(ethnicity == "EA"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity_i ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data_i %>% dplyr::filter(ethnicity == "EA")
##
## AIC BIC logLik deviance df.resid
## 4025 4048 -2008 4017 2627
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.516 -0.571 -0.161 0.447 6.647
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0294 0.171
## subnum (Intercept) 0.1122 0.335
## Residual 0.2294 0.479
## Number of obs: 2631, groups: day:subnum, 486; subnum, 70
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -0.5761 0.0419 70.0973 -13.8 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.382
## Unadjusted ICC: 0.382
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.079
## subnum | 0.302
# BC sample
# run model to calcualte ICC
model <- lmer(negAffIntensity_i ~ 1 + (1 | subnum/day),
data = negAffReliab_data_i %>% dplyr::filter(ethnicity == "BC"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity_i ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data_i %>% dplyr::filter(ethnicity == "BC")
##
## AIC BIC logLik deviance df.resid
## 7140 7165 -3566 7132 3738
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.357 -0.550 -0.185 0.343 5.941
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0543 0.233
## subnum (Intercept) 0.0627 0.250
## Residual 0.3376 0.581
## Number of obs: 3742, groups: day:subnum, 669; subnum, 96
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -0.6234 0.0288 95.8793 -21.7 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.257
## Unadjusted ICC: 0.257
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.119
## subnum | 0.138
Reliability, and ICC (Non-ipsatized Items)
negAffReliab_data = daily_data %>%
dplyr::select(subnum, ethnicity, EMAno, R.ANXI, R.BORE, R.SADX, R.ANGR) %>%
pivot_longer(cols = c(R.ANXI, R.BORE, R.SADX, R.ANGR),
names_to = "item",
values_to = "score")
# Within-persons reliability over EMA pings: RC = var(subnum:EMAno) / [var(subnum:EMAno) + var(error)]
# Full sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno), data = negAffReliab_data, REML = FALSE)
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff = var_person_day / (var_person_day + var_error/4)
RC_negAff
## [1] 0.5335
# EA sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno),
data = negAffReliab_data %>% dplyr::filter(ethnicity == "EA"), REML = FALSE,
control = lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e5)))
## boundary (singular) fit: see help('isSingular')
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff_EA = var_person_day / (var_person_day + var_error/4)
RC_negAff_EA
## [1] 0.4333
# BC sample
# run model to get variances needed
model <- lmer(score ~ (1 | subnum) + (1 | EMAno) + (1 | subnum:EMAno),
data = negAffReliab_data %>% dplyr::filter(ethnicity == "BC"), REML = FALSE,
control = lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e5)))
var_comp <- as.data.frame(VarCorr(model))
var_person_day <- var_comp[which(var_comp$grp == "subnum:EMAno"), "vcov"]
var_error <- var_comp[which(var_comp$grp == "Residual"), "vcov"]
# calculate RC
RC_negAff_BC = var_person_day / (var_person_day + var_error/4)
RC_negAff_BC
## [1] 0.5964
rm(negAffReliab_data, var_person_day, var_error)
# ICC tells you percentage of variance that is due to clustering; The larger the ICC the lower the variability is within the clusters and consequently the higher the variability is between the clusters
negAffReliab_data = daily_data %>%
dplyr::select(subnum, day, ethnicity, EMAno, negAffIntensity)
# Full sample
# run model to calcualte ICC
model <- lmer(negAffIntensity ~ 1 + (1 | subnum/day), data = negAffReliab_data, REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data
##
## AIC BIC logLik deviance df.resid
## 11396 11423 -5694 11388 6369
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.178 -0.558 -0.172 0.388 6.426
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0442 0.210
## subnum (Intercept) 0.1280 0.358
## Residual 0.2956 0.544
## Number of obs: 6373, groups: day:subnum, 1155; subnum, 166
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.6785 0.0293 166.3135 57.3 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.368
## Unadjusted ICC: 0.368
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.095
## subnum | 0.274
# EA sample
# run model to calcualte ICC
model <- lmer(negAffIntensity ~ 1 + (1 | subnum/day),
data = negAffReliab_data %>% dplyr::filter(ethnicity == "EA"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data %>% dplyr::filter(ethnicity == "EA")
##
## AIC BIC logLik deviance df.resid
## 4379 4402 -2185 4371 2627
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.083 -0.587 -0.155 0.444 6.257
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0329 0.181
## subnum (Intercept) 0.1412 0.376
## Residual 0.2621 0.512
## Number of obs: 2631, groups: day:subnum, 486; subnum, 70
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.6943 0.0468 70.2507 36.2 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.399
## Unadjusted ICC: 0.399
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.075
## subnum | 0.324
# BC sample
# run model to calcualte ICC
model <- lmer(negAffIntensity ~ 1 + (1 | subnum/day),
data = negAffReliab_data %>% dplyr::filter(ethnicity == "BC"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: negAffIntensity ~ 1 + (1 | subnum/day)
## Data: negAffReliab_data %>% dplyr::filter(ethnicity == "BC")
##
## AIC BIC logLik deviance df.resid
## 6990 7014 -3491 6982 3738
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.105 -0.542 -0.186 0.340 6.173
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0522 0.229
## subnum (Intercept) 0.1181 0.344
## Residual 0.3191 0.565
## Number of obs: 3742, groups: day:subnum, 669; subnum, 96
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.6669 0.0374 96.0092 44.6 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.348
## Unadjusted ICC: 0.348
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.107
## subnum | 0.241
Descriptives and ICC
# calculate raw NA
daily_data <- daily_data %>%
ungroup() %>%
mutate(posAffIntensity = rowMeans(select(., R.ENTH, R.HAPP, R.CALM, R.PLEA, R.EXCI, R.RELA), na.rm = TRUE)) %>%
group_by(subnum) %>%
dplyr::mutate(avg_posAffIntensity_dev = mean(posAffIntensity, na.rm = TRUE)) %>%
dplyr::mutate(posAffIntensity_dev = posAffIntensity - avg_posAffIntensity_dev) %>%
ungroup()
# calculate ipsatized NA
daily_data <-
daily_data %>%
dplyr::mutate(
posAffIntensity_i = rowMeans(select(., R.ENTH_i, R.HAPP_i, R.CALM_i, R.PLEA_i, R.EXCI_i, R.RELA_i), na.rm = TRUE))%>%
group_by(subnum) %>%
dplyr::mutate(avg_posAffIntensity_i_dev = mean(posAffIntensity_i, na.rm = TRUE)) %>%
dplyr::mutate(posAffIntensity_i_dev = posAffIntensity_i - avg_posAffIntensity_i_dev) %>%
ungroup()
daily_data <-
daily_data %>% group_by(subnum) %>%
dplyr::mutate(
avg_posAffIntensity = mean(posAffIntensity, na.rm = TRUE),
avg_posAffIntensity_i = mean(posAffIntensity_i, na.rm = TRUE))
print("European Americans (EA):")
## [1] "European Americans (EA):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_posAffIntensity, avg_posAffIntensity_i),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 70 35.83 20.74 1.00 71.00 70.00 2.48
## avg_posAffIntensity 2 70 2.73 0.57 1.17 4.66 3.50 0.07
## avg_posAffIntensity_i 3 70 0.33 0.27 -0.60 0.75 1.35 0.03
print("Beijing Chinese (BC):")
## [1] "Beijing Chinese (BC):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_posAffIntensity, avg_posAffIntensity_i),
skew = FALSE)
## vars n mean sd min max range se
## subnum* 1 96 119.50 27.86 72.00 167.00 95.00 2.84
## avg_posAffIntensity 2 96 2.68 0.41 1.62 3.92 2.29 0.04
## avg_posAffIntensity_i 3 96 0.40 0.19 -0.06 0.77 0.83 0.02
Descriptives, and ICC
# calculate continuous variable indicating unpleasantness of current activity
daily_data <-
daily_data %>%
dplyr::mutate(R.A.PL = 0 - R.A.PL) %>%
group_by(subnum) %>%
dplyr::mutate(
avg_unpleasantActivity_dev = mean(R.A.PL, na.rm = TRUE)) %>%
dplyr::mutate(
unpleasantActivity_dev = R.A.PL - avg_unpleasantActivity_dev,
unpleasantActivity_SD = sd(R.A.PL, na.rm = TRUE)) %>%
ungroup()
print("European Americans (EA):")
## [1] "European Americans (EA):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
dplyr::select(R.A.PL, ethnicity), skew = FALSE)
## vars n mean sd min max range se
## R.A.PL 1 2594 -0.99 1.61 -3 3 6 0.03
## ethnicity* 2 2688 1.00 0.00 1 1 0 0.00
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_unpleasantActivity_dev, unpleasantActivity_SD),
skew = FALSE)
## vars n mean sd min max range se
## avg_unpleasantActivity_dev 1 70 -0.99 0.61 -2.78 0.82 3.60 0.07
## unpleasantActivity_SD 2 70 1.46 0.38 0.72 2.77 2.05 0.05
print("Beijing Chinese (BC):")
## [1] "Beijing Chinese (BC):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
dplyr::select(R.A.PL, ethnicity), skew = FALSE)
## vars n mean sd min max range se
## R.A.PL 1 3680 -1.03 1.25 -3 3 6 0.02
## ethnicity* 2 3784 2.00 0.00 2 2 0 0.00
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_unpleasantActivity_dev, unpleasantActivity_SD),
skew = FALSE)
## vars n mean sd min max range se
## avg_unpleasantActivity_dev 1 96 -1.03 0.53 -2.64 0.21 2.84 0.05
## unpleasantActivity_SD 2 96 1.10 0.32 0.45 2.06 1.61 0.03
rm(data_long)
# ICC tells you percentage of variance that is due to clustering; The larger the ICC the lower the variability is within the clusters and consequently the higher the variability is between the clusters
UnpleasantReliab_data = daily_data %>%
dplyr::select(subnum, day, ethnicity, EMAno, R.A.PL)
# ICC for subject/days
# Full sample
# run model to calcualte ICC
model <- lmer(R.A.PL ~ 1 + (1 | subnum/day), data = UnpleasantReliab_data, REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: R.A.PL ~ 1 + (1 | subnum/day)
## Data: UnpleasantReliab_data
##
## AIC BIC logLik deviance df.resid
## 21494 21521 -10743 21486 6270
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.370 -0.663 -0.074 0.550 4.036
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.109 0.330
## subnum (Intercept) 0.263 0.513
## Residual 1.625 1.275
## Number of obs: 6274, groups: day:subnum, 1154; subnum, 166
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -1.0107 0.0441 166.1519 -22.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.186
## Unadjusted ICC: 0.186
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.055
## subnum | 0.132
# EA sample
# run model to calcualte ICC
model <- lmer(R.A.PL ~ 1 + (1 | subnum/day),
data = UnpleasantReliab_data %>% dplyr::filter(ethnicity == "EA"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: R.A.PL ~ 1 + (1 | subnum/day)
## Data: UnpleasantReliab_data %>% dplyr::filter(ethnicity == "EA")
##
## AIC BIC logLik deviance df.resid
## 9634 9658 -4813 9626 2590
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.880 -0.744 -0.121 0.617 2.999
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.109 0.330
## subnum (Intercept) 0.298 0.546
## Residual 2.196 1.482
## Number of obs: 2594, groups: day:subnum, 486; subnum, 70
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -0.9896 0.0732 70.1717 -13.5 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.156
## Unadjusted ICC: 0.156
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.042
## subnum | 0.115
# BC sample
# run model to calcualte ICC
model <- lmer(R.A.PL ~ 1 + (1 | subnum/day),
data = UnpleasantReliab_data %>% dplyr::filter(ethnicity == "BC"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: R.A.PL ~ 1 + (1 | subnum/day)
## Data: UnpleasantReliab_data %>% dplyr::filter(ethnicity == "BC")
##
## AIC BIC logLik deviance df.resid
## 11626 11650 -5809 11618 3676
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.784 -0.667 -0.056 0.537 4.632
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.108 0.328
## subnum (Intercept) 0.236 0.486
## Residual 1.223 1.106
## Number of obs: 3680, groups: day:subnum, 668; subnum, 96
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -1.0263 0.0544 96.1334 -18.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.219
## Unadjusted ICC: 0.219
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.069
## subnum | 0.151
Descriptives and ICC
daily_data <-
daily_data %>% dplyr::mutate(
desireActivity = case_when(
is.na(D.ACT) ~ NA_real_,
D.ACT == 0 ~ 0,
!is.na(D.D.AC) ~ D.D.AC - 1,
TRUE ~ NA_real_))
daily_data <-
daily_data %>% group_by(subnum) %>%
dplyr::mutate(
avg_desireActivity_dev = mean(desireActivity, na.rm = TRUE)) %>%
dplyr::mutate(
desireActivity_dev = desireActivity - avg_desireActivity_dev) %>%
ungroup()
print("European Americans (EA):")
## [1] "European Americans (EA):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
dplyr::select(desireActivity, ethnicity),
skew = FALSE)
## vars n mean sd min max range se
## desireActivity 1 2582 0.76 1.31 0 4 4 0.03
## ethnicity* 2 2688 1.00 0.00 1 1 0 0.00
psych::describe(daily_data %>%
distinct(subnum, .keep_all = TRUE) %>% dplyr::filter(ethnicity == "EA") %>%
dplyr::select(avg_desireActivity_dev, ethnicity),
skew = FALSE)
## vars n mean sd min max range se
## avg_desireActivity_dev 1 70 0.74 0.51 0 2.47 2.47 0.06
## ethnicity* 2 70 1.00 0.00 1 1.00 0.00 0.00
print("Beijing Chinese (BC):")
## [1] "Beijing Chinese (BC):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
dplyr::select(desireActivity, ethnicity),
skew = FALSE)
## vars n mean sd min max range se
## desireActivity 1 3674 0.45 1.02 0 4 4 0.02
## ethnicity* 2 3784 2.00 0.00 2 2 0 0.00
psych::describe(daily_data %>%
distinct(subnum, .keep_all = TRUE) %>% dplyr::filter(ethnicity == "BC") %>%
dplyr::select(avg_desireActivity_dev, ethnicity),
skew = FALSE)
## vars n mean sd min max range se
## avg_desireActivity_dev 1 96 0.46 0.39 0 1.83 1.83 0.04
## ethnicity* 2 96 2.00 0.00 2 2.00 0.00 0.00
# ICC tells you percentage of variance that is due to clustering; The larger the ICC the lower the variability is within the clusters and consequently the higher the variability is between the clusters
DesireReliab_data = daily_data %>%
dplyr::select(subnum, day, ethnicity, EMAno, desireActivity)
# ICC for subject/days
# Full sample
# run model to calcualte ICC
model <- lmer(desireActivity ~ 1 + (1 | subnum/day), data = DesireReliab_data, REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: desireActivity ~ 1 + (1 | subnum/day)
## Data: DesireReliab_data
##
## AIC BIC logLik deviance df.resid
## 18902 18929 -9447 18894 6252
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.254 -0.527 -0.263 -0.074 3.549
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0797 0.282
## subnum (Intercept) 0.1763 0.420
## Residual 1.0792 1.039
## Number of obs: 6256, groups: day:subnum, 1154; subnum, 166
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.5775 0.0362 166.3540 16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.192
## Unadjusted ICC: 0.192
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.060
## subnum | 0.132
# EA sample
# run model to calcualte ICC
model <- lmer(desireActivity ~ 1 + (1 | subnum/day),
data = DesireReliab_data %>% dplyr::filter(ethnicity == "EA"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: desireActivity ~ 1 + (1 | subnum/day)
## Data: DesireReliab_data %>% dplyr::filter(ethnicity == "EA")
##
## AIC BIC logLik deviance df.resid
## 8490 8513 -4241 8482 2578
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.939 -0.605 -0.329 0.194 3.087
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0784 0.280
## subnum (Intercept) 0.2095 0.458
## Residual 1.4260 1.194
## Number of obs: 2582, groups: day:subnum, 486; subnum, 70
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.746 0.061 70.269 12.2 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.168
## Unadjusted ICC: 0.168
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.046
## subnum | 0.122
# BC sample
# run model to calcualte ICC
model <- lmer(desireActivity ~ 1 + (1 | subnum/day),
data = DesireReliab_data %>% dplyr::filter(ethnicity == "BC"), REML = FALSE)
summary(model)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: desireActivity ~ 1 + (1 | subnum/day)
## Data: DesireReliab_data %>% dplyr::filter(ethnicity == "BC")
##
## AIC BIC logLik deviance df.resid
## 10201 10226 -5096 10193 3670
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.041 -0.449 -0.243 -0.082 3.926
##
## Random effects:
## Groups Name Variance Std.Dev.
## day:subnum (Intercept) 0.0811 0.285
## subnum (Intercept) 0.1158 0.340
## Residual 0.8355 0.914
## Number of obs: 3674, groups: day:subnum, 668; subnum, 96
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.4557 0.0395 95.7003 11.5 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
icc(model)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.191
## Unadjusted ICC: 0.191
performance::icc(model, by_group = TRUE)
## # ICC by Group
##
## Group | ICC
## ------------------
## day:subnum | 0.079
## subnum | 0.112
Descriptives
daily_data <-
daily_data %>%
group_by(subnum) %>%
dplyr::mutate(
next_hoursBetween_withinDay = if_else(next_dateOfEMA == date, next_hoursBetween, NA_real_),
next_hoursBetween_NextDay = if_else(next_dateOfEMA != date, next_hoursBetween, NA_real_)) %>%
dplyr::mutate(
hours_from_first_ping =
case_when(
is.na(next_hoursBetween) ~ cumsum(replace_na(next_hoursBetween, 0)),
TRUE ~ cumsum(next_hoursBetween) - next_hoursBetween)) %>%
dplyr::mutate(
avg_next_hoursBetween_withinDay = mean(next_hoursBetween_withinDay, na.rm = TRUE),
avg_next_hoursBetween_NextDay = mean(next_hoursBetween_NextDay, na.rm = TRUE)) %>% ungroup()
print("Full Sample:")
## [1] "Full Sample:"
psych::describe(daily_data %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_next_hoursBetween_withinDay, avg_next_hoursBetween_NextDay),
skew = FALSE)
## vars n mean sd min max range se
## avg_next_hoursBetween_withinDay 1 166 2.17 0.23 1.82 4.24 2.42 0.02
## avg_next_hoursBetween_NextDay 2 166 14.69 0.96 8.33 18.12 9.80 0.07
print("European Americans (EA):")
## [1] "European Americans (EA):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "EA") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_next_hoursBetween_withinDay, avg_next_hoursBetween_NextDay),
skew = FALSE)
## vars n mean sd min max range se
## avg_next_hoursBetween_withinDay 1 70 2.26 0.30 1.93 4.24 2.31 0.04
## avg_next_hoursBetween_NextDay 2 70 14.90 1.31 8.33 18.12 9.80 0.16
print("Beijing Chinese (BC):")
## [1] "Beijing Chinese (BC):"
psych::describe(daily_data %>% dplyr::filter(ethnicity == "BC") %>%
distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(avg_next_hoursBetween_withinDay, avg_next_hoursBetween_NextDay),
skew = FALSE)
## vars n mean sd min max range se
## avg_next_hoursBetween_withinDay 1 96 2.11 0.14 1.82 2.76 0.94 0.01
## avg_next_hoursBetween_NextDay 2 96 14.53 0.55 13.39 15.91 2.52 0.06
ggplot() +
scale_fill_manual(values = c("EA" = "#F49070", "BC" = "#52B2CF")) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "BC"),
aes(x = next_hoursBetween, fill = ethnicity), alpha = 0.7) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "EA"),
aes(x = next_hoursBetween, fill = ethnicity), alpha = 0.7) +
theme_minimal() +
geom_vline(xintercept = 24, linetype = "dashed", size = 1) +
geom_vline(xintercept = 12, linetype = "dashed", size = 1) +
xlim(c(0,30)) +
ggtitle("Hours Between Experience Sampling Responses for All EMA Pairs") +
xlab("Hours") +
ylab("Count") +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 1))
ggplot() +
scale_fill_manual(values = c("EA" = "#F49070", "BC" = "#52B2CF")) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "BC"),
aes(x = next_hoursBetween_withinDay, fill = ethnicity), alpha = 0.7) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "EA"),
aes(x = next_hoursBetween_withinDay, fill = ethnicity), alpha = 0.7) +
theme_minimal() +
xlim(c(0,5)) +
ggtitle("Hours Between Experience Sampling Responses Within a Day for All Pairs of Data") +
xlab("Hours") +
ylab("Count") +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 1))
ggplot() +
scale_fill_manual(values = c("EA" = "#F49070", "BC" = "#52B2CF")) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "BC"),
aes(x = next_hoursBetween_NextDay, fill = ethnicity), alpha = 0.7) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "EA"),
aes(x = next_hoursBetween_NextDay, fill = ethnicity), alpha = 0.7) +
theme_minimal() +
geom_vline(xintercept = 24, linetype = "dashed", size = 1) +
geom_vline(xintercept = 12, linetype = "dashed", size = 1) +
xlim(c(0,30)) +
ylim(c(0, 100)) +
ggtitle("Hours Between EMA Pings Between Days for All EMA Pairs") +
xlab("Hours") +
ylab("Count") +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 1))
ggplot() +
scale_fill_manual(values = c("EA" = "#F49070", "BC" = "#52B2CF")) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "BC") %>% distinct(subnum, .keep_all = TRUE),
aes(x = avg_next_hoursBetween_withinDay, fill = ethnicity), alpha = 0.7) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "EA") %>% distinct(subnum, .keep_all = TRUE),
aes(x = avg_next_hoursBetween_withinDay, fill = ethnicity), alpha = 0.7) +
theme_minimal() +
xlim(c(0,5)) +
ylim(c(0, 40)) +
ggtitle("Average Hours Between EMA Pings Within Day for Each Participant") +
xlab("Hours") +
ylab("Count") +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 1))
ggplot() +
scale_fill_manual(values = c("EA" = "#F49070", "BC" = "#52B2CF")) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "BC") %>% distinct(subnum, .keep_all = TRUE),
aes(x = avg_next_hoursBetween_NextDay, fill = ethnicity), alpha = 0.7) +
geom_histogram(data = daily_data %>% dplyr::filter(ethnicity == "EA") %>% distinct(subnum, .keep_all = TRUE),
aes(x = avg_next_hoursBetween_NextDay, fill = ethnicity), alpha = 0.7) +
theme_minimal() +
xlim(c(5,16)) +
ylim(c(0, 15)) +
ggtitle("Average Hours Between EMA Pings Between Days for Each Participant") +
xlab("Hours") +
ylab("Count") +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 1))
##### data #####
data <-
merge(baseline_data %>%
dplyr::select(subnum:tier,
aa.HAN:r.PA_i, aa.PA, aa.PA_i, maxPositivity_i, maxPositivity),
daily_data %>%
dplyr::select(subnum:tier, -gender, -age,
hours_from_first_ping, next_hoursBetween,
unpleasantActivity_dev, avg_unpleasantActivity_dev,
negAffIntensity, avg_negAffIntensity,
negAffIntensity_dev, avg_negAffIntensity_dev,
negAffIntensity_i, avg_negAffIntensity_i,
negAffIntensity_i_dev, avg_negAffIntensity_i_dev,
R.ANXI_i, R.BORE_i, R.SADX_i, R.ANGR_i,
R.ANXI, R.BORE, R.SADX, R.ANGR,
avg_R.ANXI_i_dev, avg_R.BORE_i_dev, avg_R.SADX_i_dev, avg_R.ANGR_i_dev,
next_negAffIntensity, next_negAffIntensity_dev, next_negAffIntensity_i_dev,
posAffIntensity, avg_posAffIntensity,
posAffIntensity_dev, avg_posAffIntensity_dev,
posAffIntensity_i, avg_posAffIntensity_i,
posAffIntensity_i_dev, avg_posAffIntensity_i_dev,
posAffIntensity, avg_posAffIntensity,
posAffIntensity_dev, avg_posAffIntensity_dev,
posAffIntensity_i, avg_posAffIntensity_i,
posAffIntensity_i_dev, avg_posAffIntensity_i_dev,
avg_desireActivity_dev,
desireActivity, desireActivity_dev,
R.A.T, R.ACT),
by = "subnum", all = TRUE) %>%
dplyr::mutate(
ethnicity_EA = ethnicity.x,
issueEthn = if_else(ethnicity.x == ethnicity.y | is.na(ethnicity.y), 0, 1),
issueTier = if_else(tier.x == tier.y | is.na(tier.y), 0, 1)) %>%
dplyr::select(-ethnicity.x, -ethnicity.y, - tier.y)
data <- merge(data,
exit_data %>% dplyr::select(subnum:tier),
by = "subnum", all = TRUE) %>%
dplyr::select(
subnum, starts_with("issue"), starts_with("ethnicity"), starts_with("tier"),
everything()) %>%
dplyr::mutate(
issueEthn = case_when(issueEthn == 1 ~ 1,
is.na(ethnicity) ~ 0,
ethnicity != ethnicity_EA ~ 1,
TRUE ~ 0),
issueTier = case_when(issueTier == 1 ~ 1,
is.na(tier) ~ 0,
tier.x != tier ~ 1,
TRUE ~ 0),
gender = as.numeric(gender)) %>%
dplyr::select(-tier.x)
data = data %>% dplyr::mutate(
day = if_else(day != "Mon" & day != "Tue" & day != "Wed" & day != "Thu" & day != "Fri" & day != "Sat" & day != "Sun", NA_character_, day),
day = as.factor(day),
ethnicity = ethnicity_EA)
levels(data$ethnicity) <- c("European Americans", "Beijing Chinese")
contrasts(data$ethnicity) <- contr.treatment(levels(data$ethnicity), base = which(levels(data$ethnicity) == "European Americans"))
##### data desc #####
data_desc <- baseline_data %>% dplyr::select(subnum:tier,
starts_with("aa.") & !ends_with("_i"),
starts_with("aa.") & ends_with("_i"),
starts_with("i.") & !ends_with("_i"),
starts_with("i.") & ends_with("_i"),
starts_with("r.") & !ends_with("_i"),
starts_with("r.") & ends_with("_i"))
levels(data_desc$ethnicity) <- c("European Americans", "Beijing Chinese")
# descriptive statistics, L2
psych::describeBy(data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(subnum:tier, age, gender,
aa.HAN:r.PA_i),
group = "ethnicity")
##
## Descriptive statistics by group
## ethnicity: European Americans
## vars n mean sd median trimmed mad min max
## subnum 1 70 7263.26 176.41 7313.00 7260.77 246.11 7004.00 7577.00
## issueEthn 2 70 0.00 0.00 0.00 0.00 0.00 0.00 0.00
## issueTier 3 70 0.03 0.17 0.00 0.00 0.00 0.00 1.00
## ethnicity_EA* 4 70 1.00 0.00 1.00 1.00 0.00 1.00 1.00
## ethnicity* 5 70 1.00 0.00 1.00 1.00 0.00 1.00 1.00
## tier 6 70 0.37 0.49 0.00 0.34 0.00 0.00 1.00
## age 7 70 20.20 1.79 20.00 19.98 1.48 18.00 25.00
## gender 8 70 0.44 0.50 0.00 0.43 0.00 0.00 1.00
## aa.HAN 9 70 4.39 0.75 4.67 4.52 0.49 1.00 5.00
## aa.HAN_i 10 70 1.04 0.46 1.12 1.09 0.22 -1.05 1.94
## aa.NEG 11 70 4.39 0.84 4.67 4.56 0.49 1.00 5.00
## aa.NEG_i 12 70 1.02 0.50 1.15 1.11 0.31 -1.10 1.52
## aa.LAN 13 70 4.33 0.79 4.67 4.48 0.49 1.00 5.00
## aa.LAN_i 14 70 0.99 0.46 1.07 1.06 0.27 -1.10 1.60
## aa.NA 15 70 4.37 0.69 4.56 4.48 0.49 1.00 5.00
## aa.NA_i 16 70 1.02 0.39 1.10 1.08 0.15 -1.05 1.39
## i.HAP 17 70 3.46 0.69 3.33 3.49 0.99 2.00 5.00
## i.HAP_i 18 70 0.53 0.38 0.60 0.56 0.37 -0.50 1.20
## i.POS 19 70 4.36 0.61 4.42 4.44 0.62 2.33 5.00
## i.POS_i 20 70 1.16 0.34 1.20 1.19 0.24 -0.32 1.81
## i.LAP 21 70 3.98 0.69 4.00 4.02 0.49 2.00 5.00
## i.LAP_i 22 70 0.89 0.37 0.90 0.92 0.40 -0.25 1.49
## i.PA 23 70 3.93 0.48 4.00 3.96 0.33 2.56 4.78
## i.PA_i 24 70 0.86 0.17 0.90 0.87 0.12 0.11 1.17
## i.HAN 25 70 1.29 0.42 1.00 1.21 0.00 1.00 3.67
## i.HAN_i 26 70 -0.97 0.30 -0.99 -1.01 0.22 -1.29 0.97
## i.NEG 27 70 1.22 0.39 1.00 1.15 0.00 1.00 3.33
## i.NEG_i 28 70 -1.01 0.27 -1.09 -1.05 0.17 -1.39 0.65
## i.LAN 29 70 1.31 0.31 1.33 1.27 0.49 1.00 2.33
## i.LAN_i 30 70 -0.96 0.19 -0.96 -0.98 0.12 -1.23 -0.03
## i.NA 31 70 1.27 0.32 1.22 1.23 0.16 1.00 3.11
## i.NA_i 32 70 -0.98 0.21 -1.03 -1.01 0.10 -1.23 0.43
## r.HAN 33 70 1.96 0.52 2.00 1.92 0.49 1.00 4.00
## r.HAN_i 34 70 -0.63 0.57 -0.71 -0.68 0.53 -1.48 1.32
## r.NEG 35 70 2.16 0.62 2.00 2.13 0.49 1.00 4.00
## r.NEG_i 36 70 -0.41 0.68 -0.60 -0.47 0.66 -1.63 1.37
## r.LAN 37 70 2.63 0.67 2.67 2.60 0.99 1.67 4.33
## r.LAN_i 38 70 0.12 0.75 0.01 0.08 0.73 -1.22 1.74
## r.NA 39 70 2.25 0.47 2.22 2.22 0.49 1.33 3.44
## r.NA_i 40 70 -0.30 0.51 -0.42 -0.34 0.46 -1.15 1.04
## r.HAP 41 70 2.61 0.62 2.50 2.58 0.74 1.00 4.67
## r.HAP_i 42 70 0.08 0.54 0.04 0.06 0.47 -0.96 1.58
## r.POS 43 70 3.25 0.81 3.33 3.31 0.99 1.00 4.67
## r.POS_i 44 70 0.80 0.72 0.99 0.87 0.71 -1.02 2.14
## r.LAP 45 70 3.05 0.75 3.17 3.12 0.74 1.00 4.00
## r.LAP_i 46 70 0.55 0.68 0.72 0.61 0.68 -1.52 1.55
## r.PA 47 70 2.97 0.60 3.11 3.01 0.58 1.22 4.00
## r.PA_i 48 70 0.48 0.46 0.63 0.51 0.44 -0.76 1.20
## range skew kurtosis se
## subnum 573.00 0.03 -1.47 21.09
## issueEthn 0.00 NaN NaN 0.00
## issueTier 1.00 5.54 29.09 0.02
## ethnicity_EA* 0.00 NaN NaN 0.00
## ethnicity* 0.00 NaN NaN 0.00
## tier 1.00 0.52 -1.75 0.06
## age 7.00 0.90 0.31 0.21
## gender 1.00 0.23 -1.98 0.06
## aa.HAN 4.00 -2.48 7.34 0.09
## aa.HAN_i 2.99 -2.04 6.66 0.06
## aa.NEG 4.00 -2.18 5.52 0.10
## aa.NEG_i 2.62 -2.57 7.73 0.06
## aa.LAN 4.00 -2.32 6.63 0.09
## aa.LAN_i 2.70 -2.58 8.66 0.06
## aa.NA 4.00 -3.01 11.27 0.08
## aa.NA_i 2.44 -4.05 18.27 0.05
## i.HAP 3.00 -0.22 -0.54 0.08
## i.HAP_i 1.70 -0.61 -0.26 0.05
## i.POS 2.67 -1.03 0.80 0.07
## i.POS_i 2.13 -1.59 4.57 0.04
## i.LAP 3.00 -0.62 0.38 0.08
## i.LAP_i 1.74 -0.84 0.55 0.04
## i.PA 2.22 -0.54 0.05 0.06
## i.PA_i 1.06 -1.48 4.04 0.02
## i.HAN 2.67 2.80 12.16 0.05
## i.HAN_i 2.27 3.91 22.14 0.04
## i.NEG 2.33 2.66 10.32 0.05
## i.NEG_i 2.03 3.46 18.14 0.03
## i.LAN 1.33 1.12 1.56 0.04
## i.LAN_i 1.21 2.07 7.30 0.02
## i.NA 2.11 2.94 13.09 0.04
## i.NA_i 1.66 4.57 27.88 0.02
## r.HAN 3.00 0.97 1.81 0.06
## r.HAN_i 2.79 0.80 0.52 0.07
## r.NEG 3.00 0.63 0.30 0.07
## r.NEG_i 3.00 0.65 -0.53 0.08
## r.LAN 2.67 0.34 -0.81 0.08
## r.LAN_i 2.96 0.50 -0.81 0.09
## r.NA 2.11 0.51 -0.32 0.06
## r.NA_i 2.19 0.63 -0.53 0.06
## r.HAP 3.67 0.49 0.74 0.07
## r.HAP_i 2.54 0.28 -0.08 0.07
## r.POS 3.67 -0.62 0.14 0.10
## r.POS_i 3.16 -0.69 -0.21 0.09
## r.LAP 3.00 -0.70 -0.24 0.09
## r.LAP_i 3.07 -0.78 -0.03 0.08
## r.PA 2.78 -0.59 0.00 0.07
## r.PA_i 1.96 -0.67 -0.39 0.06
## ------------------------------------------------------------
## ethnicity: Beijing Chinese
## vars n mean sd median trimmed mad
## subnum 1 96 266812.47 112508.49 266811.50 266818.00 148303.74
## issueEthn 2 96 0.00 0.00 0.00 0.00 0.00
## issueTier 3 96 0.00 0.00 0.00 0.00 0.00
## ethnicity_EA* 4 96 2.00 0.00 2.00 2.00 0.00
## ethnicity* 5 96 2.00 0.00 2.00 2.00 0.00
## tier 6 96 0.50 0.50 0.50 0.50 0.74
## age 7 96 19.85 1.07 20.00 19.83 1.48
## gender 8 96 0.50 0.50 0.50 0.50 0.74
## aa.HAN 9 96 3.62 0.99 4.00 3.72 0.74
## aa.HAN_i 10 96 0.58 0.53 0.71 0.66 0.35
## aa.NEG 11 96 3.75 0.97 4.00 3.87 0.49
## aa.NEG_i 12 96 0.68 0.60 0.82 0.76 0.42
## aa.LAN 13 96 3.90 0.85 4.00 3.98 0.99
## aa.LAN_i 14 96 0.79 0.46 0.85 0.84 0.32
## aa.NA 15 96 3.76 0.86 4.00 3.85 0.66
## aa.NA_i 16 96 0.69 0.42 0.80 0.77 0.21
## i.HAP 17 96 3.17 0.70 3.00 3.13 0.49
## i.HAP_i 18 96 0.47 0.45 0.41 0.48 0.52
## i.POS 19 96 3.82 0.83 4.00 3.86 0.99
## i.POS_i 20 96 0.97 0.49 1.08 1.01 0.38
## i.LAP 21 96 3.76 0.65 3.67 3.76 0.49
## i.LAP_i 22 96 0.94 0.36 0.99 0.97 0.28
## i.PA 23 96 3.58 0.60 3.56 3.59 0.66
## i.PA_i 24 96 0.79 0.28 0.85 0.82 0.22
## i.HAN 25 96 1.57 0.34 1.67 1.55 0.49
## i.HAN_i 26 96 -0.81 0.24 -0.83 -0.81 0.20
## i.NEG 27 96 1.61 0.53 1.67 1.56 0.49
## i.NEG_i 28 96 -0.72 0.42 -0.80 -0.78 0.32
## i.LAN 29 96 1.60 0.56 1.67 1.54 0.49
## i.LAN_i 30 96 -0.73 0.45 -0.84 -0.79 0.30
## i.NA 31 96 1.59 0.38 1.56 1.57 0.49
## i.NA_i 32 96 -0.75 0.26 -0.78 -0.79 0.19
## r.HAN 33 96 1.79 0.44 1.67 1.76 0.49
## r.HAN_i 34 96 -0.71 0.41 -0.82 -0.74 0.35
## r.NEG 35 96 2.14 0.53 2.00 2.13 0.49
## r.NEG_i 36 96 -0.33 0.50 -0.41 -0.36 0.44
## r.LAN 37 96 2.34 0.61 2.33 2.30 0.49
## r.LAN_i 38 96 -0.10 0.63 -0.25 -0.15 0.56
## r.NA 39 96 2.09 0.43 2.00 2.09 0.33
## r.NA_i 40 96 -0.38 0.39 -0.43 -0.42 0.36
## r.HAP 41 96 2.72 0.71 2.67 2.66 0.49
## r.HAP_i 42 96 0.23 0.60 0.22 0.22 0.73
## r.POS 43 96 2.98 0.77 3.00 2.98 0.99
## r.POS_i 44 96 0.52 0.66 0.63 0.54 0.74
## r.LAP 45 96 3.21 0.69 3.33 3.20 0.49
## r.LAP_i 46 96 0.74 0.56 0.85 0.77 0.44
## r.PA 47 96 2.97 0.60 2.89 2.95 0.58
## r.PA_i 48 96 0.50 0.42 0.56 0.53 0.41
## min max range skew kurtosis se
## subnum 111041.00 422602.00 311561.00 0.00 -1.39 11482.85
## issueEthn 0.00 0.00 0.00 NaN NaN 0.00
## issueTier 0.00 0.00 0.00 NaN NaN 0.00
## ethnicity_EA* 2.00 2.00 0.00 NaN NaN 0.00
## ethnicity* 2.00 2.00 0.00 NaN NaN 0.00
## tier 0.00 1.00 1.00 0.00 -2.02 0.05
## age 18.00 23.00 5.00 0.29 0.06 0.11
## gender 0.00 1.00 1.00 0.00 -2.02 0.05
## aa.HAN 1.00 5.00 4.00 -0.86 -0.11 0.10
## aa.HAN_i -1.06 1.72 2.78 -1.39 1.74 0.05
## aa.NEG 1.00 5.00 4.00 -1.06 0.78 0.10
## aa.NEG_i -1.12 1.69 2.81 -1.26 1.34 0.06
## aa.LAN 1.00 5.00 4.00 -0.91 0.77 0.09
## aa.LAN_i -0.93 1.77 2.70 -1.26 2.47 0.05
## aa.NA 1.00 5.00 4.00 -1.10 0.93 0.09
## aa.NA_i -0.93 1.18 2.11 -2.31 5.63 0.04
## i.HAP 2.00 5.00 3.00 0.52 -0.34 0.07
## i.HAP_i -0.60 1.33 1.92 -0.03 -0.84 0.05
## i.POS 1.67 5.00 3.33 -0.46 -0.66 0.08
## i.POS_i -0.60 1.97 2.57 -0.87 0.63 0.05
## i.LAP 2.00 5.00 3.00 -0.14 -0.44 0.07
## i.LAP_i -0.60 1.72 2.32 -1.25 3.09 0.04
## i.PA 2.00 5.00 3.00 -0.09 -0.43 0.06
## i.PA_i -0.60 1.23 1.82 -1.76 5.50 0.03
## i.HAN 1.00 2.67 1.67 0.62 0.22 0.03
## i.HAN_i -1.42 0.31 1.73 0.83 4.10 0.02
## i.NEG 1.00 3.00 2.00 0.63 -0.04 0.05
## i.NEG_i -1.30 1.03 2.33 1.72 3.57 0.04
## i.LAN 1.00 3.67 2.67 1.05 1.44 0.06
## i.LAN_i -1.42 1.03 2.45 1.82 4.15 0.05
## i.NA 1.00 2.67 1.67 0.41 -0.46 0.04
## i.NA_i -1.11 0.49 1.60 1.88 5.08 0.03
## r.HAN 1.00 3.00 2.00 0.44 -0.17 0.04
## r.HAN_i -1.42 0.61 2.03 0.85 0.46 0.04
## r.NEG 1.00 4.00 3.00 0.37 0.91 0.05
## r.NEG_i -1.41 1.40 2.80 0.84 0.83 0.05
## r.LAN 1.00 4.00 3.00 0.48 0.26 0.06
## r.LAN_i -1.26 1.86 3.12 0.77 -0.09 0.06
## r.NA 1.00 3.44 2.44 0.21 0.61 0.04
## r.NA_i -1.03 0.78 1.81 0.99 0.72 0.04
## r.HAP 1.33 5.00 3.67 0.84 0.80 0.07
## r.HAP_i -0.99 1.46 2.45 0.09 -0.97 0.06
## r.POS 1.00 5.00 4.00 0.06 -0.43 0.08
## r.POS_i -0.90 1.79 2.69 -0.25 -0.87 0.07
## r.LAP 2.00 5.00 3.00 0.22 -0.23 0.07
## r.LAP_i -0.81 1.98 2.79 -0.52 -0.03 0.06
## r.PA 1.44 5.00 3.56 0.50 0.95 0.06
## r.PA_i -0.69 1.23 1.91 -0.58 -0.23 0.04
# test age differences
t.test(age ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
##
## Welch Two Sample t-test
##
## data: age by ethnicity
## t = 1.4, df = 104, p-value = 0.2
## alternative hypothesis: true difference in means between group European Americans and group Beijing Chinese is not equal to 0
## 95 percent confidence interval:
## -0.1302 0.8219
## sample estimates:
## mean in group European Americans mean in group Beijing Chinese
## 20.20 19.85
# test gender differences
temp <- data %>% distinct(subnum, .keep_all = TRUE)
chisq.test(
table(temp$ethnicity, temp$gender))
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: table(temp$ethnicity, temp$gender)
## X-squared = 0.33, df = 1, p-value = 0.6
rm(temp)
Let’s examine how many days on average participants carried the palm pilot for.
data <-
data %>%
group_by(subnum) %>%
dplyr::mutate(noOfDays = n_distinct(date)) %>% ungroup()
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(ethnicity, noOfDays))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 166 1.58 0.50 2 1.60 0 1 2 1 -0.31 -1.91
## noOfDays 2 166 8.07 1.26 8 7.82 0 7 14 7 2.38 7.15
## se
## ethnicity* 0.04
## noOfDays 0.10
# EA
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::filter(ethnicity == "European Americans") %>%
dplyr::select(ethnicity, noOfDays))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 70 1.0 0.00 1 1.00 0.00 1 1 0 NaN NaN
## noOfDays 2 70 8.4 1.65 8 8.07 1.48 7 14 7 1.8 3.07
## se
## ethnicity* 0.0
## noOfDays 0.2
# BC
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::filter(ethnicity == "Beijing Chinese") %>%
dplyr::select(ethnicity, noOfDays))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 96 2.00 0.00 2 2.00 0 2 2 0 NaN NaN
## noOfDays 2 96 7.82 0.81 8 7.71 0 7 11 4 1.75 5.12
## se
## ethnicity* 0.00
## noOfDays 0.08
Let’s examine how many pings on average participants responded to.
data <-
data %>%
group_by(subnum) %>%
dplyr::mutate(noOfEMA = max(EMAno)) %>% ungroup()
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(ethnicity, noOfEMA))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 166 1.58 0.50 2 1.60 0.00 1 2 1 -0.31 -1.91
## noOfEMA 2 166 38.99 3.79 39 38.78 2.97 27 58 31 0.88 4.76
## se
## ethnicity* 0.04
## noOfEMA 0.29
# total
nrow(data %>% dplyr::filter(ethnicity == "European Americans"))
## [1] 2688
nrow(data %>% dplyr::filter(ethnicity == "Beijing Chinese"))
## [1] 3784
# EA
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::filter(ethnicity == "European Americans") %>%
dplyr::select(ethnicity, noOfEMA))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 70 1.0 0.00 1 1.00 0.00 1 1 0 NaN NaN
## noOfEMA 2 70 38.4 4.41 38 38.32 2.97 27 49 22 0.12 0.67
## se
## ethnicity* 0.00
## noOfEMA 0.53
# BC
psych::describe(
data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::filter(ethnicity == "Beijing Chinese") %>%
dplyr::select(ethnicity, noOfEMA))
## vars n mean sd median trimmed mad min max range skew kurtosis
## ethnicity* 1 96 2.00 0.00 2 2.00 0.00 2 2 0 NaN NaN
## noOfEMA 2 96 39.42 3.23 39 39.09 1.48 34 58 24 2.56 11.68
## se
## ethnicity* 0.00
## noOfEMA 0.33
Activity type and unpleasantness of activity
## `summarise()` has grouped output by 'R.A.T'. You can override using the
## `.groups` argument.
## `summarise()` has grouped output by 'R.ACT'. You can override using the
## `.groups` argument.
print("Full Sample")
## [1] "Full Sample"
betweenData <- data %>% distinct(subnum, .keep_all = TRUE) %>% dplyr::select(aa.NA, aa.NA_i, aa.PA, aa.PA_i, i.NA, i.NA_i, i.PA, i.PA_i, r.PA, r.PA_i, r.NA, r.NA_i, maxPositivity, starts_with("avg_"))
cor(betweenData)
## aa.NA aa.NA_i aa.PA aa.PA_i i.NA
## aa.NA 1.000000 0.840702 -0.585043 -0.788415 -0.29494
## aa.NA_i 0.840702 1.000000 -0.758891 -0.847220 -0.18084
## aa.PA -0.585043 -0.758891 1.000000 0.792802 0.21583
## aa.PA_i -0.788415 -0.847220 0.792802 1.000000 0.09911
## i.NA -0.294944 -0.180835 0.215826 0.099115 1.00000
## i.NA_i -0.310214 -0.265992 0.226563 0.148919 0.81636
## i.PA 0.288330 0.185987 -0.249928 -0.155432 -0.62315
## i.PA_i 0.179727 0.070094 -0.161197 -0.119122 -0.61430
## r.PA 0.038512 -0.042909 -0.063242 0.001070 -0.11815
## r.PA_i -0.012633 -0.098930 -0.045383 0.021589 -0.15726
## r.NA 0.079085 0.182925 -0.018750 -0.074095 0.13410
## r.NA_i 0.016966 0.072947 0.041375 -0.011086 0.12723
## maxPositivity 0.321550 0.203239 -0.261060 -0.146786 -0.85572
## avg_unpleasantActivity_dev 0.069461 0.044409 -0.001662 -0.012779 -0.08216
## avg_negAffIntensity -0.025246 -0.026957 0.067316 0.045978 0.10918
## avg_negAffIntensity_dev -0.025246 -0.026957 0.067316 0.045978 0.10918
## avg_negAffIntensity_i 0.034623 0.030460 0.031071 0.033634 0.07359
## avg_negAffIntensity_i_dev 0.034623 0.030460 0.031071 0.033634 0.07359
## avg_R.ANXI_i_dev 0.188741 0.206112 -0.059382 -0.088111 -0.04207
## avg_R.BORE_i_dev -0.039955 -0.004001 0.027951 0.043690 0.14299
## avg_R.SADX_i_dev -0.060422 -0.061787 0.086266 0.104098 0.07214
## avg_R.ANGR_i_dev 0.026831 -0.054761 0.033001 0.059072 0.03369
## avg_posAffIntensity -0.004636 -0.038957 0.014899 -0.004439 -0.06370
## avg_posAffIntensity_dev -0.004636 -0.038957 0.014899 -0.004439 -0.06370
## avg_posAffIntensity_i -0.063363 -0.060092 0.007110 -0.020427 -0.04239
## avg_posAffIntensity_i_dev -0.063363 -0.060092 0.007110 -0.020427 -0.04239
## avg_desireActivity_dev 0.133975 0.151742 -0.083401 -0.005448 -0.16523
## i.NA_i i.PA i.PA_i r.PA r.PA_i
## aa.NA -0.310214 0.28833 0.17973 0.03851 -0.01263
## aa.NA_i -0.265992 0.18599 0.07009 -0.04291 -0.09893
## aa.PA 0.226563 -0.24993 -0.16120 -0.06324 -0.04538
## aa.PA_i 0.148919 -0.15543 -0.11912 0.00107 0.02159
## i.NA 0.816361 -0.62315 -0.61430 -0.11815 -0.15726
## i.NA_i 1.000000 -0.72259 -0.73039 -0.22459 -0.17139
## i.PA -0.722595 1.00000 0.76573 0.50210 0.33729
## i.PA_i -0.730387 0.76573 1.00000 0.35290 0.37150
## r.PA -0.224589 0.50210 0.35290 1.00000 0.85587
## r.PA_i -0.171388 0.33729 0.37150 0.85587 1.00000
## r.NA -0.025452 -0.04067 -0.11533 -0.53588 -0.69445
## r.NA_i 0.159761 -0.25360 -0.23219 -0.76247 -0.81654
## maxPositivity -0.840080 0.93793 0.77901 0.38458 0.29289
## avg_unpleasantActivity_dev -0.011265 -0.07738 -0.05987 -0.35868 -0.28340
## avg_negAffIntensity 0.057499 -0.06060 -0.04668 -0.20359 -0.25239
## avg_negAffIntensity_dev 0.057499 -0.06060 -0.04668 -0.20359 -0.25239
## avg_negAffIntensity_i 0.131501 -0.17665 -0.18916 -0.34805 -0.38183
## avg_negAffIntensity_i_dev 0.131501 -0.17665 -0.18916 -0.34805 -0.38183
## avg_R.ANXI_i_dev 0.007876 -0.08660 -0.11317 -0.27326 -0.30067
## avg_R.BORE_i_dev 0.167283 -0.11978 -0.17739 -0.25748 -0.30313
## avg_R.SADX_i_dev 0.068452 -0.15886 -0.16003 -0.23689 -0.26126
## avg_R.ANGR_i_dev 0.136906 -0.16772 -0.14235 -0.30319 -0.30588
## avg_posAffIntensity -0.166683 0.27885 0.23898 0.38468 0.34109
## avg_posAffIntensity_dev -0.166683 0.27885 0.23898 0.38468 0.34109
## avg_posAffIntensity_i -0.108766 0.17774 0.19913 0.38926 0.40796
## avg_posAffIntensity_i_dev -0.108766 0.17774 0.19913 0.38926 0.40796
## avg_desireActivity_dev -0.124223 0.09189 0.05790 -0.23861 -0.23747
## r.NA r.NA_i maxPositivity
## aa.NA 0.07909 0.01697 0.32155
## aa.NA_i 0.18292 0.07295 0.20324
## aa.PA -0.01875 0.04138 -0.26106
## aa.PA_i -0.07410 -0.01109 -0.14679
## i.NA 0.13410 0.12723 -0.85572
## i.NA_i -0.02545 0.15976 -0.84008
## i.PA -0.04067 -0.25360 0.93793
## i.PA_i -0.11533 -0.23219 0.77901
## r.PA -0.53588 -0.76247 0.38458
## r.PA_i -0.69445 -0.81654 0.29289
## r.NA 1.00000 0.81696 -0.08637
## r.NA_i 0.81696 1.00000 -0.22420
## maxPositivity -0.08637 -0.22420 1.00000
## avg_unpleasantActivity_dev 0.28225 0.29910 -0.01476
## avg_negAffIntensity 0.29025 0.29374 -0.08851
## avg_negAffIntensity_dev 0.29025 0.29374 -0.08851
## avg_negAffIntensity_i 0.30991 0.39290 -0.14950
## avg_negAffIntensity_i_dev 0.30991 0.39290 -0.14950
## avg_R.ANXI_i_dev 0.27627 0.34417 -0.03864
## avg_R.BORE_i_dev 0.17404 0.18634 -0.14265
## avg_R.SADX_i_dev 0.28239 0.35639 -0.13709
## avg_R.ANGR_i_dev 0.21550 0.31762 -0.12590
## avg_posAffIntensity -0.19821 -0.32369 0.21274
## avg_posAffIntensity_dev -0.19821 -0.32369 0.21274
## avg_posAffIntensity_i -0.35353 -0.44947 0.13639
## avg_posAffIntensity_i_dev -0.35353 -0.44947 0.13639
## avg_desireActivity_dev 0.28933 0.35068 0.13406
## avg_unpleasantActivity_dev avg_negAffIntensity
## aa.NA 0.069461 -0.02525
## aa.NA_i 0.044409 -0.02696
## aa.PA -0.001662 0.06732
## aa.PA_i -0.012779 0.04598
## i.NA -0.082163 0.10918
## i.NA_i -0.011265 0.05750
## i.PA -0.077380 -0.06060
## i.PA_i -0.059872 -0.04668
## r.PA -0.358681 -0.20359
## r.PA_i -0.283403 -0.25239
## r.NA 0.282251 0.29025
## r.NA_i 0.299098 0.29374
## maxPositivity -0.014761 -0.08851
## avg_unpleasantActivity_dev 1.000000 0.27606
## avg_negAffIntensity 0.276056 1.00000
## avg_negAffIntensity_dev 0.276056 1.00000
## avg_negAffIntensity_i 0.504650 0.73303
## avg_negAffIntensity_i_dev 0.504650 0.73303
## avg_R.ANXI_i_dev 0.412848 0.58192
## avg_R.BORE_i_dev 0.359119 0.50434
## avg_R.SADX_i_dev 0.348255 0.58107
## avg_R.ANGR_i_dev 0.391192 0.52317
## avg_posAffIntensity -0.536954 -0.11175
## avg_posAffIntensity_dev -0.536954 -0.11175
## avg_posAffIntensity_i -0.508975 -0.68027
## avg_posAffIntensity_i_dev -0.508975 -0.68027
## avg_desireActivity_dev 0.286135 0.23861
## avg_negAffIntensity_dev avg_negAffIntensity_i
## aa.NA -0.02525 0.03462
## aa.NA_i -0.02696 0.03046
## aa.PA 0.06732 0.03107
## aa.PA_i 0.04598 0.03363
## i.NA 0.10918 0.07359
## i.NA_i 0.05750 0.13150
## i.PA -0.06060 -0.17665
## i.PA_i -0.04668 -0.18916
## r.PA -0.20359 -0.34805
## r.PA_i -0.25239 -0.38183
## r.NA 0.29025 0.30991
## r.NA_i 0.29374 0.39290
## maxPositivity -0.08851 -0.14950
## avg_unpleasantActivity_dev 0.27606 0.50465
## avg_negAffIntensity 1.00000 0.73303
## avg_negAffIntensity_dev 1.00000 0.73303
## avg_negAffIntensity_i 0.73303 1.00000
## avg_negAffIntensity_i_dev 0.73303 1.00000
## avg_R.ANXI_i_dev 0.58192 0.77729
## avg_R.BORE_i_dev 0.50434 0.66189
## avg_R.SADX_i_dev 0.58107 0.79811
## avg_R.ANGR_i_dev 0.52317 0.77297
## avg_posAffIntensity -0.11175 -0.67331
## avg_posAffIntensity_dev -0.11175 -0.67331
## avg_posAffIntensity_i -0.68027 -0.95357
## avg_posAffIntensity_i_dev -0.68027 -0.95357
## avg_desireActivity_dev 0.23861 0.28084
## avg_negAffIntensity_i_dev avg_R.ANXI_i_dev
## aa.NA 0.03462 0.188741
## aa.NA_i 0.03046 0.206112
## aa.PA 0.03107 -0.059382
## aa.PA_i 0.03363 -0.088111
## i.NA 0.07359 -0.042073
## i.NA_i 0.13150 0.007876
## i.PA -0.17665 -0.086600
## i.PA_i -0.18916 -0.113171
## r.PA -0.34805 -0.273255
## r.PA_i -0.38183 -0.300671
## r.NA 0.30991 0.276267
## r.NA_i 0.39290 0.344165
## maxPositivity -0.14950 -0.038638
## avg_unpleasantActivity_dev 0.50465 0.412848
## avg_negAffIntensity 0.73303 0.581921
## avg_negAffIntensity_dev 0.73303 0.581921
## avg_negAffIntensity_i 1.00000 0.777287
## avg_negAffIntensity_i_dev 1.00000 0.777287
## avg_R.ANXI_i_dev 0.77729 1.000000
## avg_R.BORE_i_dev 0.66189 0.401306
## avg_R.SADX_i_dev 0.79811 0.471915
## avg_R.ANGR_i_dev 0.77297 0.402869
## avg_posAffIntensity -0.67331 -0.525258
## avg_posAffIntensity_dev -0.67331 -0.525258
## avg_posAffIntensity_i -0.95357 -0.750960
## avg_posAffIntensity_i_dev -0.95357 -0.750960
## avg_desireActivity_dev 0.28084 0.397218
## avg_R.BORE_i_dev avg_R.SADX_i_dev avg_R.ANGR_i_dev
## aa.NA -0.039955 -0.06042 0.02683
## aa.NA_i -0.004001 -0.06179 -0.05476
## aa.PA 0.027951 0.08627 0.03300
## aa.PA_i 0.043690 0.10410 0.05907
## i.NA 0.142991 0.07214 0.03369
## i.NA_i 0.167283 0.06845 0.13691
## i.PA -0.119778 -0.15886 -0.16772
## i.PA_i -0.177392 -0.16003 -0.14235
## r.PA -0.257483 -0.23689 -0.30319
## r.PA_i -0.303130 -0.26126 -0.30588
## r.NA 0.174037 0.28239 0.21550
## r.NA_i 0.186344 0.35639 0.31762
## maxPositivity -0.142654 -0.13709 -0.12590
## avg_unpleasantActivity_dev 0.359119 0.34826 0.39119
## avg_negAffIntensity 0.504337 0.58107 0.52317
## avg_negAffIntensity_dev 0.504337 0.58107 0.52317
## avg_negAffIntensity_i 0.661887 0.79811 0.77297
## avg_negAffIntensity_i_dev 0.661887 0.79811 0.77297
## avg_R.ANXI_i_dev 0.401306 0.47191 0.40287
## avg_R.BORE_i_dev 1.000000 0.28993 0.31447
## avg_R.SADX_i_dev 0.289933 1.00000 0.69272
## avg_R.ANGR_i_dev 0.314474 0.69272 1.00000
## avg_posAffIntensity -0.453669 -0.55115 -0.51682
## avg_posAffIntensity_dev -0.453669 -0.55115 -0.51682
## avg_posAffIntensity_i -0.642377 -0.77620 -0.73590
## avg_posAffIntensity_i_dev -0.642377 -0.77620 -0.73590
## avg_desireActivity_dev 0.227568 0.14317 0.08349
## avg_posAffIntensity avg_posAffIntensity_dev
## aa.NA -0.004636 -0.004636
## aa.NA_i -0.038957 -0.038957
## aa.PA 0.014899 0.014899
## aa.PA_i -0.004439 -0.004439
## i.NA -0.063700 -0.063700
## i.NA_i -0.166683 -0.166683
## i.PA 0.278850 0.278850
## i.PA_i 0.238984 0.238984
## r.PA 0.384683 0.384683
## r.PA_i 0.341093 0.341093
## r.NA -0.198215 -0.198215
## r.NA_i -0.323685 -0.323685
## maxPositivity 0.212736 0.212736
## avg_unpleasantActivity_dev -0.536954 -0.536954
## avg_negAffIntensity -0.111751 -0.111751
## avg_negAffIntensity_dev -0.111751 -0.111751
## avg_negAffIntensity_i -0.673307 -0.673307
## avg_negAffIntensity_i_dev -0.673307 -0.673307
## avg_R.ANXI_i_dev -0.525258 -0.525258
## avg_R.BORE_i_dev -0.453669 -0.453669
## avg_R.SADX_i_dev -0.551148 -0.551148
## avg_R.ANGR_i_dev -0.516821 -0.516821
## avg_posAffIntensity 1.000000 1.000000
## avg_posAffIntensity_dev 1.000000 1.000000
## avg_posAffIntensity_i 0.708469 0.708469
## avg_posAffIntensity_i_dev 0.708469 0.708469
## avg_desireActivity_dev -0.214778 -0.214778
## avg_posAffIntensity_i avg_posAffIntensity_i_dev
## aa.NA -0.06336 -0.06336
## aa.NA_i -0.06009 -0.06009
## aa.PA 0.00711 0.00711
## aa.PA_i -0.02043 -0.02043
## i.NA -0.04239 -0.04239
## i.NA_i -0.10877 -0.10877
## i.PA 0.17774 0.17774
## i.PA_i 0.19913 0.19913
## r.PA 0.38926 0.38926
## r.PA_i 0.40796 0.40796
## r.NA -0.35353 -0.35353
## r.NA_i -0.44947 -0.44947
## maxPositivity 0.13639 0.13639
## avg_unpleasantActivity_dev -0.50897 -0.50897
## avg_negAffIntensity -0.68027 -0.68027
## avg_negAffIntensity_dev -0.68027 -0.68027
## avg_negAffIntensity_i -0.95357 -0.95357
## avg_negAffIntensity_i_dev -0.95357 -0.95357
## avg_R.ANXI_i_dev -0.75096 -0.75096
## avg_R.BORE_i_dev -0.64238 -0.64238
## avg_R.SADX_i_dev -0.77620 -0.77620
## avg_R.ANGR_i_dev -0.73590 -0.73590
## avg_posAffIntensity 0.70847 0.70847
## avg_posAffIntensity_dev 0.70847 0.70847
## avg_posAffIntensity_i 1.00000 1.00000
## avg_posAffIntensity_i_dev 1.00000 1.00000
## avg_desireActivity_dev -0.38704 -0.38704
## avg_desireActivity_dev
## aa.NA 0.133975
## aa.NA_i 0.151742
## aa.PA -0.083401
## aa.PA_i -0.005448
## i.NA -0.165225
## i.NA_i -0.124223
## i.PA 0.091893
## i.PA_i 0.057904
## r.PA -0.238607
## r.PA_i -0.237473
## r.NA 0.289325
## r.NA_i 0.350680
## maxPositivity 0.134064
## avg_unpleasantActivity_dev 0.286135
## avg_negAffIntensity 0.238614
## avg_negAffIntensity_dev 0.238614
## avg_negAffIntensity_i 0.280843
## avg_negAffIntensity_i_dev 0.280843
## avg_R.ANXI_i_dev 0.397218
## avg_R.BORE_i_dev 0.227568
## avg_R.SADX_i_dev 0.143165
## avg_R.ANGR_i_dev 0.083487
## avg_posAffIntensity -0.214778
## avg_posAffIntensity_dev -0.214778
## avg_posAffIntensity_i -0.387038
## avg_posAffIntensity_i_dev -0.387038
## avg_desireActivity_dev 1.000000
print("European Americans")
## [1] "European Americans"
betweenData_EA <- data %>% distinct(subnum, .keep_all = TRUE) %>% dplyr::filter(ethnicity == "European Americans") %>% dplyr::select(aa.NA, aa.NA_i, aa.PA, aa.PA_i, i.NA, i.NA_i, i.PA, i.PA_i, r.PA, r.PA_i, r.NA, r.NA_i, maxPositivity, starts_with("avg_"))
cor(betweenData_EA)
## aa.NA aa.NA_i aa.PA aa.PA_i i.NA
## aa.NA 1.000000 0.866995 -0.732971 -0.88024 -0.11814
## aa.NA_i 0.866995 1.000000 -0.824637 -0.87660 -0.04398
## aa.PA -0.732971 -0.824637 1.000000 0.86171 0.16151
## aa.PA_i -0.880244 -0.876601 0.861705 1.00000 0.05519
## i.NA -0.118143 -0.043976 0.161506 0.05519 1.00000
## i.NA_i -0.064747 -0.030223 0.108035 0.04169 0.80002
## i.PA 0.140432 -0.005131 -0.146651 -0.09754 -0.46138
## i.PA_i 0.137480 0.002395 -0.163389 -0.17243 -0.56969
## r.PA -0.016745 0.001304 -0.080707 -0.02100 -0.09181
## r.PA_i -0.080192 -0.039710 -0.083862 0.01365 -0.16723
## r.NA 0.055125 0.039482 0.150785 -0.01167 0.28800
## r.NA_i 0.061474 0.048609 0.119857 -0.02907 0.22867
## maxPositivity 0.152736 0.016825 -0.177191 -0.09362 -0.78567
## avg_unpleasantActivity_dev 0.068848 0.053193 0.053673 -0.03768 0.05842
## avg_negAffIntensity 0.026566 0.030912 0.041026 -0.05940 0.27583
## avg_negAffIntensity_dev 0.026566 0.030912 0.041026 -0.05940 0.27583
## avg_negAffIntensity_i 0.019386 0.053552 0.023894 -0.07533 0.18751
## avg_negAffIntensity_i_dev 0.019386 0.053552 0.023894 -0.07533 0.18751
## avg_R.ANXI_i_dev -0.004281 0.065978 0.010580 -0.08045 0.19156
## avg_R.BORE_i_dev 0.093191 0.079771 0.017718 -0.04409 0.09614
## avg_R.SADX_i_dev -0.071949 -0.002897 0.105313 0.02182 0.18598
## avg_R.ANGR_i_dev 0.069488 0.035204 -0.066111 -0.12944 0.09435
## avg_posAffIntensity -0.016830 -0.107585 0.045569 0.09115 -0.03888
## avg_posAffIntensity_dev -0.016830 -0.107585 0.045569 0.09115 -0.03888
## avg_posAffIntensity_i -0.038954 -0.078730 -0.004143 0.08350 -0.14375
## avg_posAffIntensity_i_dev -0.038954 -0.078730 -0.004143 0.08350 -0.14375
## avg_desireActivity_dev 0.110679 0.162374 -0.067206 -0.13172 -0.02182
## i.NA_i i.PA i.PA_i r.PA r.PA_i
## aa.NA -0.06475 0.140432 0.137480 -0.016745 -0.08019
## aa.NA_i -0.03022 -0.005131 0.002395 0.001304 -0.03971
## aa.PA 0.10804 -0.146651 -0.163389 -0.080707 -0.08386
## aa.PA_i 0.04169 -0.097536 -0.172432 -0.021001 0.01365
## i.NA 0.80002 -0.461377 -0.569692 -0.091807 -0.16723
## i.NA_i 1.00000 -0.579967 -0.676282 -0.279290 -0.26227
## i.PA -0.57997 1.000000 0.793471 0.523129 0.41525
## i.PA_i -0.67628 0.793471 1.000000 0.388104 0.41884
## r.PA -0.27929 0.523129 0.388104 1.000000 0.89588
## r.PA_i -0.26227 0.415251 0.418837 0.895878 1.00000
## r.NA 0.23059 -0.169041 -0.279732 -0.537228 -0.69006
## r.NA_i 0.32856 -0.422356 -0.394251 -0.802050 -0.82634
## maxPositivity -0.77559 0.911353 0.817595 0.407369 0.36714
## avg_unpleasantActivity_dev 0.11143 -0.199583 -0.170946 -0.357286 -0.33572
## avg_negAffIntensity 0.22774 -0.131996 -0.070932 -0.296221 -0.37178
## avg_negAffIntensity_dev 0.22774 -0.131996 -0.070932 -0.296221 -0.37178
## avg_negAffIntensity_i 0.23708 -0.309998 -0.211329 -0.456704 -0.45661
## avg_negAffIntensity_i_dev 0.23708 -0.309998 -0.211329 -0.456704 -0.45661
## avg_R.ANXI_i_dev 0.25002 -0.332021 -0.230705 -0.389150 -0.38176
## avg_R.BORE_i_dev 0.08947 0.037281 0.002092 -0.139028 -0.19423
## avg_R.SADX_i_dev 0.14843 -0.329642 -0.239439 -0.396191 -0.39996
## avg_R.ANGR_i_dev 0.22262 -0.276687 -0.157445 -0.453285 -0.41180
## avg_posAffIntensity -0.14669 0.432250 0.293886 0.510441 0.40338
## avg_posAffIntensity_dev -0.14669 0.432250 0.293886 0.510441 0.40338
## avg_posAffIntensity_i -0.21598 0.326917 0.228779 0.476255 0.46643
## avg_posAffIntensity_i_dev -0.21598 0.326917 0.228779 0.476255 0.46643
## avg_desireActivity_dev 0.06790 -0.111928 -0.016448 -0.300170 -0.27368
## r.NA r.NA_i maxPositivity
## aa.NA 0.05513 0.06147 0.15274
## aa.NA_i 0.03948 0.04861 0.01683
## aa.PA 0.15079 0.11986 -0.17719
## aa.PA_i -0.01167 -0.02907 -0.09362
## i.NA 0.28800 0.22867 -0.78567
## i.NA_i 0.23059 0.32856 -0.77559
## i.PA -0.16904 -0.42236 0.91135
## i.PA_i -0.27973 -0.39425 0.81760
## r.PA -0.53723 -0.80205 0.40737
## r.PA_i -0.69006 -0.82634 0.36714
## r.NA 1.00000 0.86112 -0.25149
## r.NA_i 0.86112 1.00000 -0.40060
## maxPositivity -0.25149 -0.40060 1.00000
## avg_unpleasantActivity_dev 0.42405 0.40659 -0.16627
## avg_negAffIntensity 0.48556 0.45488 -0.22001
## avg_negAffIntensity_dev 0.48556 0.45488 -0.22001
## avg_negAffIntensity_i 0.46343 0.52257 -0.30316
## avg_negAffIntensity_i_dev 0.46343 0.52257 -0.30316
## avg_R.ANXI_i_dev 0.40375 0.49529 -0.32039
## avg_R.BORE_i_dev 0.18294 0.11636 -0.01861
## avg_R.SADX_i_dev 0.44570 0.49387 -0.31615
## avg_R.ANGR_i_dev 0.35540 0.43808 -0.23671
## avg_posAffIntensity -0.27202 -0.41648 0.31944
## avg_posAffIntensity_dev -0.27202 -0.41648 0.31944
## avg_posAffIntensity_i -0.45564 -0.53403 0.29465
## avg_posAffIntensity_i_dev -0.45564 -0.53403 0.29465
## avg_desireActivity_dev 0.29571 0.38191 -0.06792
## avg_unpleasantActivity_dev avg_negAffIntensity
## aa.NA 0.06885 0.02657
## aa.NA_i 0.05319 0.03091
## aa.PA 0.05367 0.04103
## aa.PA_i -0.03768 -0.05940
## i.NA 0.05842 0.27583
## i.NA_i 0.11143 0.22774
## i.PA -0.19958 -0.13200
## i.PA_i -0.17095 -0.07093
## r.PA -0.35729 -0.29622
## r.PA_i -0.33572 -0.37178
## r.NA 0.42405 0.48556
## r.NA_i 0.40659 0.45488
## maxPositivity -0.16627 -0.22001
## avg_unpleasantActivity_dev 1.00000 0.52211
## avg_negAffIntensity 0.52211 1.00000
## avg_negAffIntensity_dev 0.52211 1.00000
## avg_negAffIntensity_i 0.62376 0.80448
## avg_negAffIntensity_i_dev 0.62376 0.80448
## avg_R.ANXI_i_dev 0.53683 0.70089
## avg_R.BORE_i_dev 0.36469 0.49794
## avg_R.SADX_i_dev 0.51179 0.63275
## avg_R.ANGR_i_dev 0.48682 0.63579
## avg_posAffIntensity -0.56827 -0.34101
## avg_posAffIntensity_dev -0.56827 -0.34101
## avg_posAffIntensity_i -0.62911 -0.75548
## avg_posAffIntensity_i_dev -0.62911 -0.75548
## avg_desireActivity_dev 0.39524 0.28297
## avg_negAffIntensity_dev avg_negAffIntensity_i
## aa.NA 0.02657 0.01939
## aa.NA_i 0.03091 0.05355
## aa.PA 0.04103 0.02389
## aa.PA_i -0.05940 -0.07533
## i.NA 0.27583 0.18751
## i.NA_i 0.22774 0.23708
## i.PA -0.13200 -0.31000
## i.PA_i -0.07093 -0.21133
## r.PA -0.29622 -0.45670
## r.PA_i -0.37178 -0.45661
## r.NA 0.48556 0.46343
## r.NA_i 0.45488 0.52257
## maxPositivity -0.22001 -0.30316
## avg_unpleasantActivity_dev 0.52211 0.62376
## avg_negAffIntensity 1.00000 0.80448
## avg_negAffIntensity_dev 1.00000 0.80448
## avg_negAffIntensity_i 0.80448 1.00000
## avg_negAffIntensity_i_dev 0.80448 1.00000
## avg_R.ANXI_i_dev 0.70089 0.81466
## avg_R.BORE_i_dev 0.49794 0.56627
## avg_R.SADX_i_dev 0.63275 0.86928
## avg_R.ANGR_i_dev 0.63579 0.80774
## avg_posAffIntensity -0.34101 -0.77016
## avg_posAffIntensity_dev -0.34101 -0.77016
## avg_posAffIntensity_i -0.75548 -0.97406
## avg_posAffIntensity_i_dev -0.75548 -0.97406
## avg_desireActivity_dev 0.28297 0.34848
## avg_negAffIntensity_i_dev avg_R.ANXI_i_dev
## aa.NA 0.01939 -0.004281
## aa.NA_i 0.05355 0.065978
## aa.PA 0.02389 0.010580
## aa.PA_i -0.07533 -0.080452
## i.NA 0.18751 0.191557
## i.NA_i 0.23708 0.250016
## i.PA -0.31000 -0.332021
## i.PA_i -0.21133 -0.230705
## r.PA -0.45670 -0.389150
## r.PA_i -0.45661 -0.381758
## r.NA 0.46343 0.403753
## r.NA_i 0.52257 0.495291
## maxPositivity -0.30316 -0.320390
## avg_unpleasantActivity_dev 0.62376 0.536828
## avg_negAffIntensity 0.80448 0.700885
## avg_negAffIntensity_dev 0.80448 0.700885
## avg_negAffIntensity_i 1.00000 0.814658
## avg_negAffIntensity_i_dev 1.00000 0.814658
## avg_R.ANXI_i_dev 0.81466 1.000000
## avg_R.BORE_i_dev 0.56627 0.251953
## avg_R.SADX_i_dev 0.86928 0.642143
## avg_R.ANGR_i_dev 0.80774 0.499598
## avg_posAffIntensity -0.77016 -0.649425
## avg_posAffIntensity_dev -0.77016 -0.649425
## avg_posAffIntensity_i -0.97406 -0.797036
## avg_posAffIntensity_i_dev -0.97406 -0.797036
## avg_desireActivity_dev 0.34848 0.437441
## avg_R.BORE_i_dev avg_R.SADX_i_dev avg_R.ANGR_i_dev
## aa.NA 0.093191 -0.071949 0.06949
## aa.NA_i 0.079771 -0.002897 0.03520
## aa.PA 0.017718 0.105313 -0.06611
## aa.PA_i -0.044091 0.021820 -0.12944
## i.NA 0.096139 0.185984 0.09435
## i.NA_i 0.089472 0.148426 0.22262
## i.PA 0.037281 -0.329642 -0.27669
## i.PA_i 0.002092 -0.239439 -0.15744
## r.PA -0.139028 -0.396191 -0.45328
## r.PA_i -0.194232 -0.399955 -0.41180
## r.NA 0.182943 0.445705 0.35540
## r.NA_i 0.116360 0.493872 0.43808
## maxPositivity -0.018609 -0.316146 -0.23671
## avg_unpleasantActivity_dev 0.364687 0.511794 0.48682
## avg_negAffIntensity 0.497940 0.632750 0.63579
## avg_negAffIntensity_dev 0.497940 0.632750 0.63579
## avg_negAffIntensity_i 0.566265 0.869277 0.80774
## avg_negAffIntensity_i_dev 0.566265 0.869277 0.80774
## avg_R.ANXI_i_dev 0.251953 0.642143 0.49960
## avg_R.BORE_i_dev 1.000000 0.325157 0.34987
## avg_R.SADX_i_dev 0.325157 1.000000 0.64158
## avg_R.ANGR_i_dev 0.349870 0.641576 1.00000
## avg_posAffIntensity -0.404219 -0.711188 -0.57482
## avg_posAffIntensity_dev -0.404219 -0.711188 -0.57482
## avg_posAffIntensity_i -0.587913 -0.832453 -0.76832
## avg_posAffIntensity_i_dev -0.587913 -0.832453 -0.76832
## avg_desireActivity_dev 0.287400 0.201920 0.13213
## avg_posAffIntensity avg_posAffIntensity_dev
## aa.NA -0.01683 -0.01683
## aa.NA_i -0.10759 -0.10759
## aa.PA 0.04557 0.04557
## aa.PA_i 0.09115 0.09115
## i.NA -0.03888 -0.03888
## i.NA_i -0.14669 -0.14669
## i.PA 0.43225 0.43225
## i.PA_i 0.29389 0.29389
## r.PA 0.51044 0.51044
## r.PA_i 0.40338 0.40338
## r.NA -0.27202 -0.27202
## r.NA_i -0.41648 -0.41648
## maxPositivity 0.31944 0.31944
## avg_unpleasantActivity_dev -0.56827 -0.56827
## avg_negAffIntensity -0.34101 -0.34101
## avg_negAffIntensity_dev -0.34101 -0.34101
## avg_negAffIntensity_i -0.77016 -0.77016
## avg_negAffIntensity_i_dev -0.77016 -0.77016
## avg_R.ANXI_i_dev -0.64942 -0.64942
## avg_R.BORE_i_dev -0.40422 -0.40422
## avg_R.SADX_i_dev -0.71119 -0.71119
## avg_R.ANGR_i_dev -0.57482 -0.57482
## avg_posAffIntensity 1.00000 1.00000
## avg_posAffIntensity_dev 1.00000 1.00000
## avg_posAffIntensity_i 0.80200 0.80200
## avg_posAffIntensity_i_dev 0.80200 0.80200
## avg_desireActivity_dev -0.35538 -0.35538
## avg_posAffIntensity_i avg_posAffIntensity_i_dev
## aa.NA -0.038954 -0.038954
## aa.NA_i -0.078730 -0.078730
## aa.PA -0.004143 -0.004143
## aa.PA_i 0.083497 0.083497
## i.NA -0.143746 -0.143746
## i.NA_i -0.215978 -0.215978
## i.PA 0.326917 0.326917
## i.PA_i 0.228779 0.228779
## r.PA 0.476255 0.476255
## r.PA_i 0.466434 0.466434
## r.NA -0.455642 -0.455642
## r.NA_i -0.534033 -0.534033
## maxPositivity 0.294649 0.294649
## avg_unpleasantActivity_dev -0.629107 -0.629107
## avg_negAffIntensity -0.755479 -0.755479
## avg_negAffIntensity_dev -0.755479 -0.755479
## avg_negAffIntensity_i -0.974057 -0.974057
## avg_negAffIntensity_i_dev -0.974057 -0.974057
## avg_R.ANXI_i_dev -0.797036 -0.797036
## avg_R.BORE_i_dev -0.587913 -0.587913
## avg_R.SADX_i_dev -0.832453 -0.832453
## avg_R.ANGR_i_dev -0.768321 -0.768321
## avg_posAffIntensity 0.802002 0.802002
## avg_posAffIntensity_dev 0.802002 0.802002
## avg_posAffIntensity_i 1.000000 1.000000
## avg_posAffIntensity_i_dev 1.000000 1.000000
## avg_desireActivity_dev -0.423740 -0.423740
## avg_desireActivity_dev
## aa.NA 0.11068
## aa.NA_i 0.16237
## aa.PA -0.06721
## aa.PA_i -0.13172
## i.NA -0.02182
## i.NA_i 0.06790
## i.PA -0.11193
## i.PA_i -0.01645
## r.PA -0.30017
## r.PA_i -0.27368
## r.NA 0.29571
## r.NA_i 0.38191
## maxPositivity -0.06792
## avg_unpleasantActivity_dev 0.39524
## avg_negAffIntensity 0.28297
## avg_negAffIntensity_dev 0.28297
## avg_negAffIntensity_i 0.34848
## avg_negAffIntensity_i_dev 0.34848
## avg_R.ANXI_i_dev 0.43744
## avg_R.BORE_i_dev 0.28740
## avg_R.SADX_i_dev 0.20192
## avg_R.ANGR_i_dev 0.13213
## avg_posAffIntensity -0.35538
## avg_posAffIntensity_dev -0.35538
## avg_posAffIntensity_i -0.42374
## avg_posAffIntensity_i_dev -0.42374
## avg_desireActivity_dev 1.00000
print("Beijing Chinese")
## [1] "Beijing Chinese"
betweenData_BC <- data %>% distinct(subnum, .keep_all = TRUE) %>% dplyr::filter(ethnicity == "Beijing Chinese") %>% dplyr::select(aa.NA, aa.NA_i, aa.PA, aa.PA_i, i.NA, i.NA_i, i.PA, i.PA_i, r.PA, r.PA_i, r.NA, r.NA_i, maxPositivity, starts_with("avg_"))
cor(betweenData_BC)
## aa.NA aa.NA_i aa.PA aa.PA_i i.NA
## aa.NA 1.0000000 0.79097 -0.44922 -0.784875 -0.20228
## aa.NA_i 0.7909689 1.00000 -0.68959 -0.889403 -0.02700
## aa.PA -0.4492215 -0.68959 1.00000 0.778090 0.11113
## aa.PA_i -0.7848749 -0.88940 0.77809 1.000000 0.06859
## i.NA -0.2022771 -0.02700 0.11113 0.068592 1.00000
## i.NA_i -0.2408521 -0.17501 0.15195 0.149433 0.76613
## i.PA 0.2328107 0.13105 -0.21423 -0.146645 -0.63123
## i.PA_i 0.1447846 0.02918 -0.12361 -0.087194 -0.64473
## r.PA 0.0744244 -0.08040 -0.05354 0.012775 -0.15152
## r.PA_i 0.0447118 -0.13920 -0.03059 0.023078 -0.19647
## r.NA -0.0062461 0.19391 -0.06625 -0.085272 0.19234
## r.NA_i -0.0729703 0.04284 0.01733 0.014326 0.14435
## maxPositivity 0.2433071 0.10001 -0.19198 -0.128235 -0.85178
## avg_unpleasantActivity_dev 0.0598367 0.02219 -0.03064 0.005895 -0.17239
## avg_negAffIntensity -0.0830825 -0.09601 0.10592 0.110040 0.04432
## avg_negAffIntensity_dev -0.0830825 -0.09601 0.10592 0.110040 0.04432
## avg_negAffIntensity_i 0.0008743 -0.03925 0.07553 0.117181 0.06200
## avg_negAffIntensity_i_dev 0.0008743 -0.03925 0.07553 0.117181 0.06200
## avg_R.ANXI_i_dev 0.2156873 0.19613 -0.01570 -0.064530 -0.04734
## avg_R.BORE_i_dev -0.0244679 0.04213 -0.02315 0.059569 0.09067
## avg_R.SADX_i_dev -0.1749147 -0.25606 0.15644 0.210249 0.11741
## avg_R.ANGR_i_dev -0.0654192 -0.21746 0.17340 0.211434 0.06556
## avg_posAffIntensity -0.0286770 -0.02009 0.01104 -0.062556 -0.06082
## avg_posAffIntensity_dev -0.0286770 -0.02009 0.01104 -0.062556 -0.06082
## avg_posAffIntensity_i 0.0149201 0.06930 -0.06127 -0.127638 -0.09914
## avg_posAffIntensity_i_dev 0.0149201 0.06930 -0.06127 -0.127638 -0.09914
## avg_desireActivity_dev -0.0346901 -0.06062 0.04397 0.132405 -0.06925
## i.NA_i i.PA i.PA_i r.PA r.PA_i
## aa.NA -0.24085 0.23281 0.14478 0.07442 0.04471
## aa.NA_i -0.17501 0.13105 0.02918 -0.08040 -0.13920
## aa.PA 0.15195 -0.21423 -0.12361 -0.05354 -0.03059
## aa.PA_i 0.14943 -0.14664 -0.08719 0.01278 0.02308
## i.NA 0.76613 -0.63123 -0.64473 -0.15152 -0.19647
## i.NA_i 1.00000 -0.74129 -0.78771 -0.23129 -0.16652
## i.PA -0.74129 1.00000 0.76461 0.53209 0.33393
## i.PA_i -0.78771 0.76461 1.00000 0.35523 0.37972
## r.PA -0.23129 0.53209 0.35523 1.00000 0.82533
## r.PA_i -0.16652 0.33393 0.37972 0.82533 1.00000
## r.NA -0.05402 -0.05670 -0.08358 -0.55167 -0.71102
## r.NA_i 0.14451 -0.21074 -0.18706 -0.74221 -0.81493
## maxPositivity -0.82663 0.94400 0.79074 0.42387 0.30914
## avg_unpleasantActivity_dev -0.07146 -0.02083 -0.01462 -0.36162 -0.23467
## avg_negAffIntensity -0.01145 -0.03983 -0.04539 -0.13103 -0.14943
## avg_negAffIntensity_dev -0.01145 -0.03983 -0.04539 -0.13103 -0.14943
## avg_negAffIntensity_i 0.14899 -0.14478 -0.21459 -0.25414 -0.30789
## avg_negAffIntensity_i_dev 0.14899 -0.14478 -0.21459 -0.25414 -0.30789
## avg_R.ANXI_i_dev 0.02808 -0.05059 -0.11698 -0.18342 -0.22501
## avg_R.BORE_i_dev 0.12974 -0.13591 -0.22104 -0.33416 -0.39023
## avg_R.SADX_i_dev 0.15708 -0.13198 -0.17499 -0.07623 -0.10058
## avg_R.ANGR_i_dev 0.18454 -0.15962 -0.17510 -0.16134 -0.19230
## avg_posAffIntensity -0.18645 0.17372 0.22861 0.26700 0.28085
## avg_posAffIntensity_dev -0.18645 0.17372 0.22861 0.26700 0.28085
## avg_posAffIntensity_i -0.19468 0.18032 0.25480 0.31984 0.35158
## avg_posAffIntensity_i_dev -0.19468 0.18032 0.25480 0.31984 0.35158
## avg_desireActivity_dev -0.03574 0.08661 0.03941 -0.20849 -0.21009
## r.NA r.NA_i maxPositivity
## aa.NA -0.006246 -0.07297 0.24331
## aa.NA_i 0.193910 0.04284 0.10001
## aa.PA -0.066247 0.01733 -0.19198
## aa.PA_i -0.085272 0.01433 -0.12823
## i.NA 0.192336 0.14435 -0.85178
## i.NA_i -0.054023 0.14451 -0.82663
## i.PA -0.056705 -0.21074 0.94400
## i.PA_i -0.083580 -0.18706 0.79074
## r.PA -0.551674 -0.74221 0.42387
## r.PA_i -0.711019 -0.81493 0.30914
## r.NA 1.000000 0.77924 -0.12012
## r.NA_i 0.779235 1.00000 -0.20376
## maxPositivity -0.120121 -0.20376 1.00000
## avg_unpleasantActivity_dev 0.151204 0.18036 0.05927
## avg_negAffIntensity 0.121395 0.12951 -0.04576
## avg_negAffIntensity_dev 0.121395 0.12951 -0.04576
## avg_negAffIntensity_i 0.144127 0.23155 -0.12417
## avg_negAffIntensity_i_dev 0.144127 0.23155 -0.12417
## avg_R.ANXI_i_dev 0.089443 0.14153 -0.01403
## avg_R.BORE_i_dev 0.222791 0.27675 -0.13037
## avg_R.SADX_i_dev 0.054332 0.14481 -0.13910
## avg_R.ANGR_i_dev 0.041634 0.14932 -0.13571
## avg_posAffIntensity -0.144622 -0.21551 0.14322
## avg_posAffIntensity_dev -0.144622 -0.21551 0.14322
## avg_posAffIntensity_i -0.204971 -0.32009 0.16397
## avg_posAffIntensity_i_dev -0.204971 -0.32009 0.16397
## avg_desireActivity_dev 0.207602 0.29346 0.08796
## avg_unpleasantActivity_dev avg_negAffIntensity
## aa.NA 0.059837 -0.08308
## aa.NA_i 0.022194 -0.09601
## aa.PA -0.030644 0.10592
## aa.PA_i 0.005895 0.11004
## i.NA -0.172392 0.04432
## i.NA_i -0.071463 -0.01145
## i.PA -0.020828 -0.03983
## i.PA_i -0.014618 -0.04539
## r.PA -0.361625 -0.13103
## r.PA_i -0.234674 -0.14943
## r.NA 0.151204 0.12140
## r.NA_i 0.180362 0.12951
## maxPositivity 0.059266 -0.04576
## avg_unpleasantActivity_dev 1.000000 0.05499
## avg_negAffIntensity 0.054992 1.00000
## avg_negAffIntensity_dev 0.054992 1.00000
## avg_negAffIntensity_i 0.380287 0.66767
## avg_negAffIntensity_i_dev 0.380287 0.66767
## avg_R.ANXI_i_dev 0.290460 0.48385
## avg_R.BORE_i_dev 0.379052 0.53402
## avg_R.SADX_i_dev 0.148434 0.54169
## avg_R.ANGR_i_dev 0.282769 0.40971
## avg_posAffIntensity -0.510480 0.12765
## avg_posAffIntensity_dev -0.510480 0.12765
## avg_posAffIntensity_i -0.374463 -0.61868
## avg_posAffIntensity_i_dev -0.374463 -0.61868
## avg_desireActivity_dev 0.177634 0.19785
## avg_negAffIntensity_dev avg_negAffIntensity_i
## aa.NA -0.08308 0.0008743
## aa.NA_i -0.09601 -0.0392547
## aa.PA 0.10592 0.0755332
## aa.PA_i 0.11004 0.1171809
## i.NA 0.04432 0.0620000
## i.NA_i -0.01145 0.1489905
## i.PA -0.03983 -0.1447800
## i.PA_i -0.04539 -0.2145897
## r.PA -0.13103 -0.2541419
## r.PA_i -0.14943 -0.3078945
## r.NA 0.12140 0.1441274
## r.NA_i 0.12951 0.2315536
## maxPositivity -0.04576 -0.1241708
## avg_unpleasantActivity_dev 0.05499 0.3802870
## avg_negAffIntensity 1.00000 0.6676723
## avg_negAffIntensity_dev 1.00000 0.6676723
## avg_negAffIntensity_i 0.66767 1.0000000
## avg_negAffIntensity_i_dev 0.66767 1.0000000
## avg_R.ANXI_i_dev 0.48385 0.7461311
## avg_R.BORE_i_dev 0.53402 0.7937161
## avg_R.SADX_i_dev 0.54169 0.7086813
## avg_R.ANGR_i_dev 0.40971 0.7285457
## avg_posAffIntensity 0.12765 -0.5681752
## avg_posAffIntensity_dev 0.12765 -0.5681752
## avg_posAffIntensity_i -0.61868 -0.9385708
## avg_posAffIntensity_i_dev -0.61868 -0.9385708
## avg_desireActivity_dev 0.19785 0.1810012
## avg_negAffIntensity_i_dev avg_R.ANXI_i_dev
## aa.NA 0.0008743 0.21569
## aa.NA_i -0.0392547 0.19613
## aa.PA 0.0755332 -0.01570
## aa.PA_i 0.1171809 -0.06453
## i.NA 0.0620000 -0.04734
## i.NA_i 0.1489905 0.02808
## i.PA -0.1447800 -0.05059
## i.PA_i -0.2145897 -0.11698
## r.PA -0.2541419 -0.18342
## r.PA_i -0.3078945 -0.22501
## r.NA 0.1441274 0.08944
## r.NA_i 0.2315536 0.14153
## maxPositivity -0.1241708 -0.01403
## avg_unpleasantActivity_dev 0.3802870 0.29046
## avg_negAffIntensity 0.6676723 0.48385
## avg_negAffIntensity_dev 0.6676723 0.48385
## avg_negAffIntensity_i 1.0000000 0.74613
## avg_negAffIntensity_i_dev 1.0000000 0.74613
## avg_R.ANXI_i_dev 0.7461311 1.00000
## avg_R.BORE_i_dev 0.7937161 0.61866
## avg_R.SADX_i_dev 0.7086813 0.20085
## avg_R.ANGR_i_dev 0.7285457 0.26221
## avg_posAffIntensity -0.5681752 -0.42547
## avg_posAffIntensity_dev -0.5681752 -0.42547
## avg_posAffIntensity_i -0.9385708 -0.67708
## avg_posAffIntensity_i_dev -0.9385708 -0.67708
## avg_desireActivity_dev 0.1810012 0.25300
## avg_R.BORE_i_dev avg_R.SADX_i_dev avg_R.ANGR_i_dev
## aa.NA -0.02447 -0.17491 -0.06542
## aa.NA_i 0.04213 -0.25606 -0.21746
## aa.PA -0.02315 0.15644 0.17340
## aa.PA_i 0.05957 0.21025 0.21143
## i.NA 0.09067 0.11741 0.06556
## i.NA_i 0.12974 0.15708 0.18454
## i.PA -0.13591 -0.13198 -0.15962
## i.PA_i -0.22104 -0.17499 -0.17510
## r.PA -0.33416 -0.07623 -0.16134
## r.PA_i -0.39023 -0.10058 -0.19230
## r.NA 0.22279 0.05433 0.04163
## r.NA_i 0.27675 0.14481 0.14932
## maxPositivity -0.13037 -0.13910 -0.13571
## avg_unpleasantActivity_dev 0.37905 0.14843 0.28277
## avg_negAffIntensity 0.53402 0.54169 0.40971
## avg_negAffIntensity_dev 0.53402 0.54169 0.40971
## avg_negAffIntensity_i 0.79372 0.70868 0.72855
## avg_negAffIntensity_i_dev 0.79372 0.70868 0.72855
## avg_R.ANXI_i_dev 0.61866 0.20085 0.26221
## avg_R.BORE_i_dev 1.00000 0.33955 0.33886
## avg_R.SADX_i_dev 0.33955 1.00000 0.76412
## avg_R.ANGR_i_dev 0.33886 0.76412 1.00000
## avg_posAffIntensity -0.51960 -0.34470 -0.45305
## avg_posAffIntensity_dev -0.51960 -0.34470 -0.45305
## avg_posAffIntensity_i -0.81194 -0.67453 -0.68472
## avg_posAffIntensity_i_dev -0.81194 -0.67453 -0.68472
## avg_desireActivity_dev 0.30449 -0.03139 -0.03475
## avg_posAffIntensity avg_posAffIntensity_dev
## aa.NA -0.02868 -0.02868
## aa.NA_i -0.02009 -0.02009
## aa.PA 0.01104 0.01104
## aa.PA_i -0.06256 -0.06256
## i.NA -0.06082 -0.06082
## i.NA_i -0.18645 -0.18645
## i.PA 0.17372 0.17372
## i.PA_i 0.22861 0.22861
## r.PA 0.26700 0.26700
## r.PA_i 0.28085 0.28085
## r.NA -0.14462 -0.14462
## r.NA_i -0.21551 -0.21551
## maxPositivity 0.14322 0.14322
## avg_unpleasantActivity_dev -0.51048 -0.51048
## avg_negAffIntensity 0.12765 0.12765
## avg_negAffIntensity_dev 0.12765 0.12765
## avg_negAffIntensity_i -0.56818 -0.56818
## avg_negAffIntensity_i_dev -0.56818 -0.56818
## avg_R.ANXI_i_dev -0.42547 -0.42547
## avg_R.BORE_i_dev -0.51960 -0.51960
## avg_R.SADX_i_dev -0.34470 -0.34470
## avg_R.ANGR_i_dev -0.45305 -0.45305
## avg_posAffIntensity 1.00000 1.00000
## avg_posAffIntensity_dev 1.00000 1.00000
## avg_posAffIntensity_i 0.61343 0.61343
## avg_posAffIntensity_i_dev 0.61343 0.61343
## avg_desireActivity_dev -0.09039 -0.09039
## avg_posAffIntensity_i avg_posAffIntensity_i_dev
## aa.NA 0.01492 0.01492
## aa.NA_i 0.06930 0.06930
## aa.PA -0.06127 -0.06127
## aa.PA_i -0.12764 -0.12764
## i.NA -0.09914 -0.09914
## i.NA_i -0.19468 -0.19468
## i.PA 0.18032 0.18032
## i.PA_i 0.25480 0.25480
## r.PA 0.31984 0.31984
## r.PA_i 0.35158 0.35158
## r.NA -0.20497 -0.20497
## r.NA_i -0.32009 -0.32009
## maxPositivity 0.16397 0.16397
## avg_unpleasantActivity_dev -0.37446 -0.37446
## avg_negAffIntensity -0.61868 -0.61868
## avg_negAffIntensity_dev -0.61868 -0.61868
## avg_negAffIntensity_i -0.93857 -0.93857
## avg_negAffIntensity_i_dev -0.93857 -0.93857
## avg_R.ANXI_i_dev -0.67708 -0.67708
## avg_R.BORE_i_dev -0.81194 -0.81194
## avg_R.SADX_i_dev -0.67453 -0.67453
## avg_R.ANGR_i_dev -0.68472 -0.68472
## avg_posAffIntensity 0.61343 0.61343
## avg_posAffIntensity_dev 0.61343 0.61343
## avg_posAffIntensity_i 1.00000 1.00000
## avg_posAffIntensity_i_dev 1.00000 1.00000
## avg_desireActivity_dev -0.27745 -0.27745
## avg_desireActivity_dev
## aa.NA -0.03469
## aa.NA_i -0.06062
## aa.PA 0.04397
## aa.PA_i 0.13240
## i.NA -0.06925
## i.NA_i -0.03574
## i.PA 0.08661
## i.PA_i 0.03941
## r.PA -0.20849
## r.PA_i -0.21009
## r.NA 0.20760
## r.NA_i 0.29346
## maxPositivity 0.08796
## avg_unpleasantActivity_dev 0.17763
## avg_negAffIntensity 0.19785
## avg_negAffIntensity_dev 0.19785
## avg_negAffIntensity_i 0.18100
## avg_negAffIntensity_i_dev 0.18100
## avg_R.ANXI_i_dev 0.25300
## avg_R.BORE_i_dev 0.30449
## avg_R.SADX_i_dev -0.03139
## avg_R.ANGR_i_dev -0.03475
## avg_posAffIntensity -0.09039
## avg_posAffIntensity_dev -0.09039
## avg_posAffIntensity_i -0.27745
## avg_posAffIntensity_i_dev -0.27745
## avg_desireActivity_dev 1.00000
Ipsatized Items
aNAisNotiNA_model_i <- ' # model 1: correlation between a_NA and i_NA estimated
# latent variable definitions (common factors)
i_NA_i =~ NA*i.fear2_i + i.host2_i + i.nerv2_i + i.sadx2_i + i.lone2_i + i.unha2_i + i.slug2_i + i.slee2_i + i.dull2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
i_NA_i ~~ 1*i_NA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ i_NA_i
# manifest variable variances (uniquenesses)
i.fear2_i ~~ i.fear2_i; i.host2_i ~~ i.host2_i; i.nerv2_i ~~ i.nerv2_i
i.sadx2_i ~~ i.sadx2_i; i.lone2_i ~~ i.lone2_i; i.unha2_i ~~ i.unha2_i
i.slug2_i ~~ i.slug2_i; i.slee2_i ~~ i.slee2_i; i.dull2_i ~~ i.dull2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
i.fear2_i ~ 1; i.host2_i ~ 1; i.nerv2_i ~ 1
i.sadx2_i ~ 1; i.lone2_i ~ 1; i.unha2_i ~ 1
i.slug2_i ~ 1; i.slee2_i ~ 1; i.dull2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisiNA_model_i <- ' # model 2: correlation between a_NA and i_NA set to 1
# latent variable definitions (common factors)
i_NA_i =~ NA*i.fear2_i + i.host2_i + i.nerv2_i + i.sadx2_i + i.lone2_i + i.unha2_i + i.slug2_i + i.slee2_i + i.dull2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
i_NA_i ~~ 1*i_NA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ 1*i_NA_i
# manifest variable variances (uniquenesses)
i.fear2_i ~~ i.fear2_i; i.host2_i ~~ i.host2_i; i.nerv2_i ~~ i.nerv2_i
i.sadx2_i ~~ i.sadx2_i; i.lone2_i ~~ i.lone2_i; i.unha2_i ~~ i.unha2_i
i.slug2_i ~~ i.slug2_i; i.slee2_i ~~ i.slee2_i; i.dull2_i ~~ i.dull2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
i.fear2_i ~ 1; i.host2_i ~ 1; i.nerv2_i ~ 1
i.sadx2_i ~ 1; i.lone2_i ~ 1; i.unha2_i ~ 1
i.slug2_i ~ 1; i.slee2_i ~ 1; i.dull2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisNotiNA_fit_i <- lavaan(aNAisNotiNA_model_i, data = data_desc, mimic = "mplus")
aNAisiNA_fit_i <- lavaan(aNAisiNA_model_i, data = data_desc, mimic = "mplus")
anova(aNAisiNA_fit_i, aNAisNotiNA_fit_i)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotiNA_fit_i 134 4744 4916 271
## aNAisiNA_fit_i 135 4891 5059 419 149 0.943 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Nonipsatized Items
aNAisNotiNA_model <- ' # model 1: correlation between a_NA and i_NA estimated
# latent variable definitions (common factors)
i_NA =~ NA*i.fear2 + i.host2 + i.nerv2 + i.sadx2 + i.lone2 + i.unha2 + i.slug2 + i.slee2 + i.dull2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
i_NA ~~ 1*i_NA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ i_NA
# manifest variable variances (uniquenesses)
i.fear2 ~~ i.fear2; i.host2 ~~ i.host2; i.nerv2 ~~ i.nerv2
i.sadx2 ~~ i.sadx2; i.lone2 ~~ i.lone2; i.unha2 ~~ i.unha2
i.slug2 ~~ i.slug2; i.slee2 ~~ i.slee2; i.dull2 ~~ i.dull2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
i.fear2 ~ 1; i.host2 ~ 1; i.nerv2 ~ 1
i.sadx2 ~ 1; i.lone2 ~ 1; i.unha2 ~ 1
i.slug2 ~ 1; i.slee2 ~ 1; i.dull2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisiNA_model <- ' # model 2: correlation between a_NA and i_NA set to 1
# latent variable definitions (common factors)
i_NA =~ NA*i.fear2 + i.host2 + i.nerv2 + i.sadx2 + i.lone2 + i.unha2 + i.slug2 + i.slee2 + i.dull2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
i_NA ~~ 1*i_NA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ 1*i_NA
# manifest variable variances (uniquenesses)
i.fear2 ~~ i.fear2; i.host2 ~~ i.host2; i.nerv2 ~~ i.nerv2
i.sadx2 ~~ i.sadx2; i.lone2 ~~ i.lone2; i.unha2 ~~ i.unha2
i.slug2 ~~ i.slug2; i.slee2 ~~ i.slee2; i.dull2 ~~ i.dull2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
i.fear2 ~ 1; i.host2 ~ 1; i.nerv2 ~ 1
i.sadx2 ~ 1; i.lone2 ~ 1; i.unha2 ~ 1
i.slug2 ~ 1; i.slee2 ~ 1; i.dull2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisNotiNA_fit <- lavaan(aNAisNotiNA_model, data = data_desc, mimic = "mplus")
aNAisiNA_fit <- lavaan(aNAisiNA_model, data = data_desc, mimic = "mplus")
anova(aNAisiNA_fit, aNAisNotiNA_fit)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotiNA_fit 134 6103 6275 238
## aNAisiNA_fit 135 6439 6607 576 338 1.42 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Ipsatized Items
aNAisNotiPA_model_i <- ' # model 1_i: correlation between a_NA and i_PA estimated
# latent variable definitions (common factors)
i_PA_i =~ NA*i.enth2_i + i.exci2_i + i.elat2_i + i.happ2_i + i.sati2_i + i.cont2_i + i.rela2_i + i.calm2_i + i.peac2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
i_PA_i ~~ 1*i_PA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ i_PA_i
# manifest variable variances (uniquenesses)
i.enth2_i ~~ i.enth2_i; i.exci2_i ~~ i.exci2_i; i.elat2_i ~~ i.elat2_i
i.happ2_i ~~ i.happ2_i; i.sati2_i ~~ i.sati2_i; i.cont2_i ~~ i.cont2_i
i.rela2_i ~~ i.rela2_i; i.calm2_i ~~ i.calm2_i; i.peac2_i ~~ i.peac2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
i.enth2_i ~ 1; i.exci2_i ~ 1; i.elat2_i ~ 1
i.happ2_i ~ 1; i.sati2_i ~ 1; i.cont2_i ~ 1
i.rela2_i ~ 1; i.calm2_i ~ 1; i.peac2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisiPA_model_i <- ' # model 2_i: correlation between a_NA and i_PA set to 1
# latent variable definitions (common factors)
i_PA_i =~ NA*i.enth2_i + i.exci2_i + i.elat2_i + i.happ2_i + i.sati2_i + i.cont2_i + i.rela2_i + i.calm2_i + i.peac2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
i_PA_i ~~ 1*i_PA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ 1*i_PA_i
# manifest variable variances (uniquenesses)
i.enth2_i ~~ i.enth2_i; i.exci2_i ~~ i.exci2_i; i.elat2_i ~~ i.elat2_i
i.happ2_i ~~ i.happ2_i; i.sati2_i ~~ i.sati2_i; i.cont2_i ~~ i.cont2_i
i.rela2_i ~~ i.rela2_i; i.calm2_i ~~ i.calm2_i; i.peac2_i ~~ i.peac2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
i.enth2_i ~ 1; i.exci2_i ~ 1; i.elat2_i ~ 1
i.happ2_i ~ 1; i.sati2_i ~ 1; i.cont2_i ~ 1
i.rela2_i ~ 1; i.calm2_i ~ 1; i.peac2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisNotiPA_fit_i <- lavaan(aNAisNotiPA_model_i, data = data_desc, mimic = "mplus")
aNAisiPA_fit_i <- lavaan(aNAisiPA_model_i, data = data_desc, mimic = "mplus")
anova(aNAisiPA_fit_i, aNAisNotiPA_fit_i)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotiPA_fit_i 134 5631 5803 250
## aNAisiPA_fit_i 135 5693 5861 314 64 0.616 1 1.2e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Nonipsatized Items
aNAisNotiPA_model <- ' # model 1: correlation between a_NA and i_PA estimated
# latent variable definitions (common factors)
i_PA =~ NA*i.enth2 + i.exci2 + i.elat2 + i.happ2 + i.sati2 + i.cont2 + i.rela2 + i.calm2 + i.peac2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
i_PA ~~ 1*i_PA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ i_PA
# manifest variable variances (uniquenesses)
i.enth2 ~~ i.enth2; i.exci2 ~~ i.exci2; i.elat2 ~~ i.elat2
i.happ2 ~~ i.happ2; i.sati2 ~~ i.sati2; i.cont2 ~~ i.cont2
i.rela2 ~~ i.rela2; i.calm2 ~~ i.calm2; i.peac2 ~~ i.peac2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
i.enth2 ~ 1; i.exci2 ~ 1; i.elat2 ~ 1
i.happ2 ~ 1; i.sati2 ~ 1; i.cont2 ~ 1
i.rela2 ~ 1; i.calm2 ~ 1; i.peac2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisiPA_model <- ' # model 2: correlation between a_NA and i_PA set to 1
# latent variable definitions (common factors)
i_PA =~ NA*i.enth2 + i.exci2 + i.elat2 + i.happ2 + i.sati2 + i.cont2 + i.rela2 + i.calm2 + i.peac2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
i_PA ~~ 1*i_PA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ 1*i_PA
# manifest variable variances (uniquenesses)
i.enth2 ~~ i.enth2; i.exci2 ~~ i.exci2; i.elat2 ~~ i.elat2
i.happ2 ~~ i.happ2; i.sati2 ~~ i.sati2; i.cont2 ~~ i.cont2
i.rela2 ~~ i.rela2; i.calm2 ~~ i.calm2; i.peac2 ~~ i.peac2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
i.enth2 ~ 1; i.exci2 ~ 1; i.elat2 ~ 1
i.happ2 ~ 1; i.sati2 ~ 1; i.cont2 ~ 1
i.rela2 ~ 1; i.calm2 ~ 1; i.peac2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisNotiPA_fit <- lavaan(aNAisNotiPA_model, data = data_desc, mimic = "mplus")
aNAisiPA_fit <- lavaan(aNAisiPA_model, data = data_desc, mimic = "mplus")
anova(aNAisiPA_fit, aNAisNotiPA_fit)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotiPA_fit 134 7434 7605 258
## aNAisiPA_fit 135 7727 7895 554 295 1.33 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Ipsatized Items
aNAisNotrNA_model_i <- ' # model 1_i: correlation between a_NA and r_NA estimated
# latent variable definitions (common factors)
r_NA_i =~ NA*r.fear2_i + r.host2_i + r.nerv2_i + r.sadx2_i + r.lone2_i + r.unha2_i + r.slug2_i + r.slee2_i + r.dull2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
r_NA_i ~~ 1*r_NA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ r_NA_i
# manifest variable variances (uniquenesses)
r.fear2_i ~~ r.fear2_i; r.host2_i ~~ r.host2_i; r.nerv2_i ~~ r.nerv2_i
r.sadx2_i ~~ r.sadx2_i; r.lone2_i ~~ r.lone2_i; r.unha2_i ~~ r.unha2_i
r.slug2_i ~~ r.slug2_i; r.slee2_i ~~ r.slee2_i; r.dull2_i ~~ r.dull2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
r.fear2_i ~ 1; r.host2_i ~ 1; r.nerv2_i ~ 1
r.sadx2_i ~ 1; r.lone2_i ~ 1; r.unha2_i ~ 1
r.slug2_i ~ 1; r.slee2_i ~ 1; r.dull2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisrNA_model_i <- ' # model 2_i: correlation between a_NA and r_NA set to 1
# latent variable definitions (common factors)
r_NA_i =~ NA*r.fear2_i + r.host2_i + r.nerv2_i + r.sadx2_i + r.lone2_i + r.unha2_i + r.slug2_i + r.slee2_i + r.dull2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
r_NA_i ~~ 1*r_NA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ 1*r_NA_i
# manifest variable variances (uniquenesses)
r.fear2_i ~~ r.fear2_i; r.host2_i ~~ r.host2_i; r.nerv2_i ~~ r.nerv2_i
r.sadx2_i ~~ r.sadx2_i; r.lone2_i ~~ r.lone2_i; r.unha2_i ~~ r.unha2_i
r.slug2_i ~~ r.slug2_i; r.slee2_i ~~ r.slee2_i; r.dull2_i ~~ r.dull2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
r.fear2_i ~ 1; r.host2_i ~ 1; r.nerv2_i ~ 1
r.sadx2_i ~ 1; r.lone2_i ~ 1; r.unha2_i ~ 1
r.slug2_i ~ 1; r.slee2_i ~ 1; r.dull2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisNotrNA_fit_i <- lavaan(aNAisNotrNA_model_i, data = data_desc, mimic = "mplus")
aNAisrNA_fit_i <- lavaan(aNAisrNA_model_i, data = data_desc, mimic = "mplus")
anova(aNAisrNA_fit_i, aNAisNotrNA_fit_i)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotrNA_fit_i 134 6358 6529 203
## aNAisrNA_fit_i 135 6521 6689 368 165 0.993 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Nonipsatized Items
aNAisNotrNA_model <- ' # model 1: correlation between a_NA and r_NA estimated
# latent variable definitions (common factors)
r_NA =~ NA*r.fear2 + r.host2 + r.nerv2 + r.sadx2 + r.lone2 + r.unha2 + r.slug2 + r.slee2 + r.dull2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
r_NA ~~ 1*r_NA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ r_NA
# manifest variable variances (uniquenesses)
r.fear2 ~~ r.fear2; r.host2 ~~ r.host2; r.nerv2 ~~ r.nerv2
r.sadx2 ~~ r.sadx2; r.lone2 ~~ r.lone2; r.unha2 ~~ r.unha2
r.slug2 ~~ r.slug2; r.slee2 ~~ r.slee2; r.dull2 ~~ r.dull2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
r.fear2 ~ 1; r.host2 ~ 1; r.nerv2 ~ 1
r.sadx2 ~ 1; r.lone2 ~ 1; r.unha2 ~ 1
r.slug2 ~ 1; r.slee2 ~ 1; r.dull2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisrNA_model <- ' # model 2: correlation between a_NA and r_NA set to 1
# latent variable definitions (common factors)
r_NA =~ NA*r.fear2 + r.host2 + r.nerv2 + r.sadx2 + r.lone2 + r.unha2 + r.slug2 + r.slee2 + r.dull2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
r_NA ~~ 1*r_NA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ 1*r_NA
# manifest variable variances (uniquenesses)
r.fear2 ~~ r.fear2; r.host2 ~~ r.host2; r.nerv2 ~~ r.nerv2
r.sadx2 ~~ r.sadx2; r.lone2 ~~ r.lone2; r.unha2 ~~ r.unha2
r.slug2 ~~ r.slug2; r.slee2 ~~ r.slee2; r.dull2 ~~ r.dull2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
r.fear2 ~ 1; r.host2 ~ 1; r.nerv2 ~ 1
r.sadx2 ~ 1; r.lone2 ~ 1; r.unha2 ~ 1
r.slug2 ~ 1; r.slee2 ~ 1; r.dull2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisNotrNA_fit <- lavaan(aNAisNotrNA_model, data = data_desc, mimic = "mplus")
aNAisrNA_fit <- lavaan(aNAisrNA_model, data = data_desc, mimic = "mplus")
anova(aNAisrNA_fit, aNAisNotrNA_fit)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotrNA_fit 134 6946 7117 214
## aNAisrNA_fit 135 7195 7363 464 251 1.23 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Ipsatized Items
aNAisNotrPA_model_i <- ' # model 1_i: correlation between a_NA and r_PA estimated
# latent variable definitions (common factors)
r_PA_i =~ NA*r.enth2_i + r.exci2_i + r.elat2_i + r.happ2_i + r.sati2_i + r.cont2_i + r.rela2_i + r.calm2_i + r.peac2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
r_PA_i ~~ 1*r_PA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ r_PA_i
# manifest variable variances (uniquenesses)
r.enth2_i ~~ r.enth2_i; r.exci2_i ~~ r.exci2_i; r.elat2_i ~~ r.elat2_i
r.happ2_i ~~ r.happ2_i; r.sati2_i ~~ r.sati2_i; r.cont2_i ~~ r.cont2_i
r.rela2_i ~~ r.rela2_i; r.calm2_i ~~ r.calm2_i; r.peac2_i ~~ r.peac2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
r.enth2_i ~ 1; r.exci2_i ~ 1; r.elat2_i ~ 1
r.happ2_i ~ 1; r.sati2_i ~ 1; r.cont2_i ~ 1
r.rela2_i ~ 1; r.calm2_i ~ 1; r.peac2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisrPA_model_i <- ' # model 2_i: correlation between a_NA and r_PA set to 1
# latent variable definitions (common factors)
r_PA_i =~ NA*r.enth2_i + r.exci2_i + r.elat2_i + r.happ2_i + r.sati2_i + r.cont2_i + r.rela2_i + r.calm2_i + r.peac2_i
a_NA_i =~ NA*aa.fear_i + aa.host_i + aa.nerv_i + aa.sadx_i + aa.lone_i + aa.unha_i + aa.slug_i + aa.slee_i + aa.dull_i
# second order latent variable definitions (common factors)
# latent variable variances
r_PA_i ~~ 1*r_PA_i
a_NA_i ~~ 1*a_NA_i
# latent variable covariances
a_NA_i ~~ 1*r_PA_i
# manifest variable variances (uniquenesses)
r.enth2_i ~~ r.enth2_i; r.exci2_i ~~ r.exci2_i; r.elat2_i ~~ r.elat2_i
r.happ2_i ~~ r.happ2_i; r.sati2_i ~~ r.sati2_i; r.cont2_i ~~ r.cont2_i
r.rela2_i ~~ r.rela2_i; r.calm2_i ~~ r.calm2_i; r.peac2_i ~~ r.peac2_i
aa.fear_i ~~ aa.fear_i; aa.host_i ~~ aa.host_i; aa.nerv_i ~~ aa.nerv_i
aa.sadx_i ~~ aa.sadx_i; aa.lone_i ~~ aa.lone_i; aa.unha_i ~~ aa.unha_i
aa.slug_i ~~ aa.slug_i; aa.slee_i ~~ aa.slee_i; aa.dull_i ~~ aa.dull_i
# manifest variable covariances (uniquenesses)
# manifest variable means
r.enth2_i ~ 1; r.exci2_i ~ 1; r.elat2_i ~ 1
r.happ2_i ~ 1; r.sati2_i ~ 1; r.cont2_i ~ 1
r.rela2_i ~ 1; r.calm2_i ~ 1; r.peac2_i ~ 1
aa.fear_i ~ 1; aa.host_i ~ 1; aa.nerv_i ~ 1
aa.sadx_i ~ 1; aa.lone_i ~ 1; aa.unha_i ~ 1
aa.slug_i ~ 1; aa.slee_i ~ 1; aa.dull_i ~ 1
'
aNAisNotrPA_fit_i <- lavaan(aNAisNotrPA_model_i, data = data_desc, mimic = "mplus")
aNAisrPA_fit_i <- lavaan(aNAisrPA_model_i, data = data_desc, mimic = "mplus")
anova(aNAisrPA_fit_i, aNAisNotrPA_fit_i)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotrPA_fit_i 134 6509 6681 262
## aNAisrPA_fit_i 135 6635 6803 390 128 0.875 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Nonipsatized Items
aNAisNotrPA_model <- ' # model 1: correlation between a_NA and r_PA estimated
# latent variable definitions (common factors)
r_PA =~ NA*r.enth2 + r.exci2 + r.elat2 + r.happ2 + r.sati2 + r.cont2 + r.rela2 + r.calm2 + r.peac2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
r_PA ~~ 1*r_PA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ r_PA
# manifest variable variances (uniquenesses)
r.enth2 ~~ r.enth2; r.exci2 ~~ r.exci2; r.elat2 ~~ r.elat2
r.happ2 ~~ r.happ2; r.sati2 ~~ r.sati2; r.cont2 ~~ r.cont2
r.rela2 ~~ r.rela2; r.calm2 ~~ r.calm2; r.peac2 ~~ r.peac2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
r.enth2 ~ 1; r.exci2 ~ 1; r.elat2 ~ 1
r.happ2 ~ 1; r.sati2 ~ 1; r.cont2 ~ 1
r.rela2 ~ 1; r.calm2 ~ 1; r.peac2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisrPA_model <- ' # model 2: correlation between a_NA and r_PA set to 1
# latent variable definitions (common factors)
r_PA =~ NA*r.enth2 + r.exci2 + r.elat2 + r.happ2 + r.sati2 + r.cont2 + r.rela2 + r.calm2 + r.peac2
a_NA =~ NA*aa.fear + aa.host + aa.nerv + aa.sadx + aa.lone + aa.unha + aa.slug + aa.slee + aa.dull
# second order latent variable definitions (common factors)
# latent variable variances
r_PA ~~ 1*r_PA
a_NA ~~ 1*a_NA
# latent variable covariances
a_NA ~~ 1*r_PA
# manifest variable variances (uniquenesses)
r.enth2 ~~ r.enth2; r.exci2 ~~ r.exci2; r.elat2 ~~ r.elat2
r.happ2 ~~ r.happ2; r.sati2 ~~ r.sati2; r.cont2 ~~ r.cont2
r.rela2 ~~ r.rela2; r.calm2 ~~ r.calm2; r.peac2 ~~ r.peac2
aa.fear ~~ aa.fear; aa.host ~~ aa.host; aa.nerv ~~ aa.nerv
aa.sadx ~~ aa.sadx; aa.lone ~~ aa.lone; aa.unha ~~ aa.unha
aa.slug ~~ aa.slug; aa.slee ~~ aa.slee; aa.dull ~~ aa.dull
# manifest variable covariances (uniquenesses)
# manifest variable means
r.enth2 ~ 1; r.exci2 ~ 1; r.elat2 ~ 1
r.happ2 ~ 1; r.sati2 ~ 1; r.cont2 ~ 1
r.rela2 ~ 1; r.calm2 ~ 1; r.peac2 ~ 1
aa.fear ~ 1; aa.host ~ 1; aa.nerv ~ 1
aa.sadx ~ 1; aa.lone ~ 1; aa.unha ~ 1
aa.slug ~ 1; aa.slee ~ 1; aa.dull ~ 1
'
aNAisNotrPA_fit <- lavaan(aNAisNotrPA_model, data = data_desc, mimic = "mplus")
aNAisrPA_fit <- lavaan(aNAisrPA_model, data = data_desc, mimic = "mplus")
anova(aNAisrPA_fit, aNAisNotrPA_fit)
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## aNAisNotrPA_fit 134 7290 7461 266
## aNAisrPA_fit 135 7725 7893 703 437 1.62 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Ipsatized Items
# select AVI data
avidata <- data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(
subnum, ethnicity,
aa.NA_i, aa.PA_i, i.PA_i, i.NA_i, r.NA_i, r.PA_i,
aa.HAN_i, aa.NEG_i, aa.LAN_i,
i.HAN_i, i.NEG_i, i.LAN_i, i.HAP_i, i.POS_i, i.LAP_i,
r.HAN_i, r.NEG_i, r.LAN_i, r.HAP_i, r.POS_i, r.LAP_i)
# test if cultures differ on avoided NA (ipsatized scores, iPA, rPA)
avoidedNAresult_i <-
lm(aa.NA_i ~ ethnicity,
data = avidata)
summary(avoidedNAresult_i)
##
## Call:
## lm(formula = aa.NA_i ~ ethnicity, data = avidata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0671 -0.0708 0.1044 0.2092 0.4894
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.0160 0.0486 20.93 < 2e-16 ***
## ethnicityBeijing Chinese -0.3303 0.0638 -5.17 6.6e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.406 on 164 degrees of freedom
## Multiple R-squared: 0.14, Adjusted R-squared: 0.135
## F-statistic: 26.8 on 1 and 164 DF, p-value: 6.62e-07
# test if cultures differ on avoided NA (ipsatized scores, iPA, iNA, rPA, rNA)
avoidedNAresult_EA_i_all <-
lm(aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i + ethnicity,
data = avidata)
summary(avoidedNAresult_EA_i_all)
##
## Call:
## lm(formula = aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i + ethnicity,
## data = avidata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0672 -0.0652 0.1004 0.1957 0.4556
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.8471 0.1424 5.95 1.6e-08 ***
## i.PA_i -0.1734 0.2250 -0.77 0.44209
## i.NA_i -0.3744 0.2122 -1.76 0.07964 .
## r.PA_i -0.1325 0.1379 -0.96 0.33815
## r.NA_i -0.0451 0.1286 -0.35 0.72646
## ethnicityBeijing Chinese -0.2564 0.0755 -3.40 0.00086 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.404 on 160 degrees of freedom
## Multiple R-squared: 0.172, Adjusted R-squared: 0.146
## F-statistic: 6.64 on 5 and 160 DF, p-value: 1.21e-05
plot_coeffs1 <- data.frame(
Predictor = c("Intercept", "Ideal PA", "Ideal NA", "Actual PA", "Actual NA", "Culture"),
Coefficient = c(summary(avoidedNAresult_EA_i_all)$coefficient[1,1], summary(avoidedNAresult_EA_i_all)$coefficient[2,1], summary(avoidedNAresult_EA_i_all)$coefficient[3,1], summary(avoidedNAresult_EA_i_all)$coefficient[4,1], summary(avoidedNAresult_EA_i_all)$coefficient[5,1], summary(avoidedNAresult_EA_i_all)$coefficient[6,1]),
CILower = c(confint(avoidedNAresult_EA_i_all)[1,1], confint(avoidedNAresult_EA_i_all)[2,1], confint(avoidedNAresult_EA_i_all)[3,1], confint(avoidedNAresult_EA_i_all)[4,1], confint(avoidedNAresult_EA_i_all)[5,1], confint(avoidedNAresult_EA_i_all)[6,1]),
CIUpper = c(confint(avoidedNAresult_EA_i_all)[1,2], confint(avoidedNAresult_EA_i_all)[2,2], confint(avoidedNAresult_EA_i_all)[3,2], confint(avoidedNAresult_EA_i_all)[4,2], confint(avoidedNAresult_EA_i_all)[5,2], confint(avoidedNAresult_EA_i_all)[6,2])) %>%
dplyr::mutate(
Predictor = factor(Predictor,
levels = c("Ideal PA", "Ideal NA", "Actual PA", "Actual NA", "Culture", "Intercept")),
Color = ifelse(Predictor == "Culture", "brown", "black")) # Add a new column for color
ggplot(plot_coeffs1, aes(x = Predictor, y = Coefficient)) +
ylab("Regression Coefficient")+
geom_point(aes(color = Color)) + # Map the color aesthetic
geom_errorbar(aes(ymin = CILower, ymax = CIUpper, color = Color), width = .2, position = position_dodge(.9)) +
geom_hline(yintercept = 0, color = "grey") +
ylim(c(-1.5, 1.5)) +
scale_color_manual(values = c("black" = "black", "brown" = "brown")) +
theme_minimal()+
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 10),
legend.position = "none",
axis.title.x=element_blank())
# test if cultures differ on avoided NA (ipsatized scores, iPA, iNA, rPA, rNA)
avoidedNAresult_EA_i_noethn <-
lm(aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i,
data = avidata)
summary(avoidedNAresult_EA_i_noethn)
##
## Call:
## lm(formula = aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i, data = avidata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.9517 -0.0872 0.0915 0.2263 0.7918
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.5735 0.1212 4.73 4.8e-06 ***
## i.PA_i -0.4168 0.2201 -1.89 0.06 .
## i.NA_i -0.7486 0.1872 -4.00 9.7e-05 ***
## r.PA_i -0.0490 0.1401 -0.35 0.73
## r.NA_i 0.0507 0.1295 0.39 0.70
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.417 on 161 degrees of freedom
## Multiple R-squared: 0.112, Adjusted R-squared: 0.09
## F-statistic: 5.08 on 4 and 161 DF, p-value: 0.000701
plot_coeffs2 <- data.frame(
Predictor = c("Intercept", "Ideal PA", "Ideal NA", "Actual PA", "Actual NA", ""),
Coefficient = c(summary(avoidedNAresult_EA_i_noethn)$coefficient[1,1], summary(avoidedNAresult_EA_i_noethn)$coefficient[2,1], summary(avoidedNAresult_EA_i_noethn)$coefficient[3,1], summary(avoidedNAresult_EA_i_noethn)$coefficient[4,1], summary(avoidedNAresult_EA_i_noethn)$coefficient[5,1], NA_real_),
CILower = c(confint(avoidedNAresult_EA_i_noethn)[1,1], confint(avoidedNAresult_EA_i_noethn)[2,1], confint(avoidedNAresult_EA_i_noethn)[3,1], confint(avoidedNAresult_EA_i_noethn)[4,1], confint(avoidedNAresult_EA_i_noethn)[5,1], NA_real_),
CIUpper = c(confint(avoidedNAresult_EA_i_noethn)[1,2], confint(avoidedNAresult_EA_i_noethn)[2,2], confint(avoidedNAresult_EA_i_noethn)[3,2], confint(avoidedNAresult_EA_i_noethn)[4,2], confint(avoidedNAresult_EA_i_noethn)[5,2], NA_real_)) %>%
dplyr::mutate(
Predictor = factor(Predictor,
levels = c("Ideal PA", "Ideal NA", "Actual PA", "Actual NA", "", "Intercept")),
Color = ifelse(Predictor == "Ideal NA", "brown", "black")) # Add a new column for color
ggplot(plot_coeffs2, aes(x = Predictor, y = Coefficient, color = Color)) +
ylab("Regression Coefficient")+
geom_point(aes(color = Color)) + # Map the color aesthetic
geom_errorbar(aes(ymin = CILower, ymax = CIUpper, color = Color), width = .2, position = position_dodge(.9)) +
geom_hline(yintercept = 0, color = "grey") +
ylim(c(-1.5, 1.5)) +
scale_color_manual(values = c("black" = "black", "brown" = "brown")) +
theme_minimal()+
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 10),
legend.position = "none",
axis.title.x=element_blank())
## Warning: Removed 1 rows containing missing values (`geom_point()`).
# Compare the two models using anova()
anova_result <- anova(avoidedNAresult_EA_i_noethn, avoidedNAresult_EA_i_all)
print(anova_result)
## Analysis of Variance Table
##
## Model 1: aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i
## Model 2: aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i + ethnicity
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 161 27.9
## 2 160 26.1 1 1.88 11.5 0.00086 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
longavidata <- avidata %>% pivot_longer(cols = 'aa.NA_i':'aa.LAN_i',
names_to = "AVI",
values_to = "value")
# test if cultures differ on avoided NA (ipsatized scores, iPA, iNA, rPA, rNA)
avoidedNAresult_EA_i_onlyethn <-
lm(aa.NA_i ~ ethnicity,
data = avidata)
summary(avoidedNAresult_EA_i_onlyethn)
##
## Call:
## lm(formula = aa.NA_i ~ ethnicity, data = avidata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0671 -0.0708 0.1044 0.2092 0.4894
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.0160 0.0486 20.93 < 2e-16 ***
## ethnicityBeijing Chinese -0.3303 0.0638 -5.17 6.6e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.406 on 164 degrees of freedom
## Multiple R-squared: 0.14, Adjusted R-squared: 0.135
## F-statistic: 26.8 on 1 and 164 DF, p-value: 6.62e-07
plot_coeffs3 <- data.frame(
Predictor = c("Intercept", " ", " ", " ", " ", "Culture"),
Coefficient = c(summary(avoidedNAresult_EA_i_onlyethn)$coefficient[1,1], NA_real_, NA_real_, NA_real_, NA_real_, summary(avoidedNAresult_EA_i_onlyethn)$coefficient[2,1]),
CILower = c(confint(avoidedNAresult_EA_i_onlyethn)[1,1], NA_real_, NA_real_, NA_real_, NA_real_, confint(avoidedNAresult_EA_i_onlyethn)[2,1]),
CIUpper = c(confint(avoidedNAresult_EA_i_onlyethn)[1,2], NA_real_, NA_real_, NA_real_, NA_real_, confint(avoidedNAresult_EA_i_onlyethn)[2,2])) %>%
dplyr::mutate(
Predictor = factor(Predictor,
levels = c(" ", " ", " ", " ", "Culture", "Intercept")),
Color = ifelse(Predictor == "Culture", "brown", "black")) # Add a new column for color
ggplot(plot_coeffs3, aes(x = Predictor, y = Coefficient)) +
ylab("Regression Coefficient")+
geom_point(aes(color = Color)) + # Map the color aesthetic
geom_errorbar(aes(ymin = CILower, ymax = CIUpper, color = Color), width = .2, position = position_dodge(.9)) +
geom_hline(yintercept = 0, color = "grey") +
ylim(c(-1.5, 1.5)) +
scale_color_manual(values = c("black" = "black", "brown" = "brown")) +
theme_minimal()+
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 10),
legend.position = "none",
axis.title.x=element_blank())
## Warning: Removed 4 rows containing missing values (`geom_point()`).
# Compare the two models using anova()
anova_result <- anova(avoidedNAresult_EA_i_onlyethn, avoidedNAresult_EA_i_all)
print(anova_result)
## Analysis of Variance Table
##
## Model 1: aa.NA_i ~ ethnicity
## Model 2: aa.NA_i ~ i.PA_i + i.NA_i + r.PA_i + r.NA_i + ethnicity
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 164 27.1
## 2 160 26.1 4 0.99 1.52 0.2
longavidata <- avidata %>% pivot_longer(cols = 'aa.NA_i':'aa.LAN_i',
names_to = "AVI",
values_to = "value")
# prepare data to plot
plotAVI <-
longavidata %>% dplyr::filter(AVI == "aa.NA" | AVI == "aa.NA_i" |
AVI == "aa.HAN" | AVI == "aa.NEG" | AVI == "aa.LAN"|
AVI == "aa.HAN_i" | AVI == "aa.NEG_i" | AVI == "aa.LAN_i") %>%
group_by(ethnicity, AVI) %>%
summarize(
mean = mean(value, na.rm = TRUE),
sd = sd(value, na.rm = TRUE),
se = sd(value, na.rm = TRUE)/sqrt(length(value)))
## `summarise()` has grouped output by 'ethnicity'. You can override using the
## `.groups` argument.
# plot ipsatized scores
AVIplot_i <- ggplot(plotAVI %>% dplyr::filter(AVI == "aa.NA_i") %>% mutate(AVI = "Ethnicity"),
aes(x = ethnicity, y = mean, fill = ethnicity)) +
geom_bar(stat = "identity", position = "dodge", width = 1) +
labs(title = " ",
y = "Avoided Negative Affect (Ipsatized)",
x = "Culture") +
ylim(c(0,1.2)) +
theme(plot.title = element_text(hjust = 0.5)) +
scale_fill_manual(name = "ethnicity", values = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF" )) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=0.1, position=position_dodge(0.9)) +
jtools::theme_apa() +
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 10),
legend.title = element_blank(),
axis.title.x=element_blank())
AVIplot_i
avidatalong <- avidata %>%
pivot_longer(cols = c("aa.HAN_i", "aa.NEG_i", "aa.LAN_i"),
names_to = "AVI",
values_to = "value")
# test if cultures differ on avoided NA (ipsatized scores)
avoidedNAresult_i <-
aov(value ~ ethnicity*AVI + Error(subnum/AVI),
data = avidatalong)
options("contrasts") # check contrasts first -- should say "contr.sum" "contr.poly"
## $contrasts
## [1] "contr.sum" "contr.poly"
summary(avoidedNAresult_i)
##
## Error: subnum
## Df Sum Sq Mean Sq
## ethnicity 1 13 13
##
## Error: subnum:AVI
## Df Sum Sq Mean Sq
## AVI 2 1.72 0.858
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## ethnicity 1 1.3 1.319 5.07 0.025 *
## AVI 2 0.0 0.011 0.04 0.957
## ethnicity:AVI 2 0.6 0.277 1.06 0.346
## Residuals 489 127.2 0.260
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans::emmeans(avoidedNAresult_i, ~ ethnicity | AVI, data = avidatalong) %>% pairs()
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results are based on intra-block estimates and are biased.
## AVI = aa.HAN_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.3472 0.145 489 2.396 0.0170
##
## AVI = aa.LAN_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.0505 0.145 489 0.349 0.7275
##
## AVI = aa.NEG_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.1674 0.145 489 1.155 0.2487
# test if cultures differ on avoided NA (ipsatized scores)
avoidedNAresult_i <-
aov(value ~ ethnicity*AVI + r.HAN_i + r.NEG_i + r.LAN_i + i.HAN_i + i.NEG_i + i.LAN_i + Error(subnum/AVI),
data = avidatalong)
options("contrasts") # check contrasts first -- should say "contr.sum" "contr.poly"
## $contrasts
## [1] "contr.sum" "contr.poly"
summary(avoidedNAresult_i)
##
## Error: subnum
## Df Sum Sq Mean Sq
## ethnicity 1 13 13
##
## Error: subnum:AVI
## Df Sum Sq Mean Sq
## AVI 2 1.72 0.858
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## ethnicity 1 1.3 1.319 5.15 0.024 *
## AVI 2 0.0 0.011 0.04 0.956
## r.HAN_i 1 0.0 0.041 0.16 0.688
## r.NEG_i 1 0.1 0.104 0.41 0.523
## r.LAN_i 1 1.5 1.509 5.89 0.016 *
## i.HAN_i 1 0.3 0.322 1.26 0.262
## i.NEG_i 1 1.6 1.585 6.19 0.013 *
## i.LAN_i 1 0.1 0.056 0.22 0.641
## ethnicity:AVI 2 0.6 0.277 1.08 0.340
## Residuals 483 123.6 0.256
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans::emmeans(avoidedNAresult_i, ~ ethnicity | AVI, data = avidatalong) %>% pairs()
## Note: re-fitting model with sum-to-zero contrasts
## Warning in (mth$objs[[1]])(object, trms, xlev, grid, ...): Some predictors are
## correlated with the intercept - results may be very biased
## NOTE: Results are based on intra-block estimates and are biased.
## AVI = aa.HAN_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.2023 0.15 483 1.346 0.1790
##
## AVI = aa.LAN_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese -0.0943 0.15 483 -0.628 0.5306
##
## AVI = aa.NEG_i:
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.0225 0.15 483 0.150 0.8810
# plot ipsatized scores by arousal level
AVIplot_i2 <- ggplot(plotAVI %>% dplyr::filter(AVI == "aa.HAN_i" | AVI == "aa.NEG_i" | AVI == "aa.LAN_i") %>%
dplyr::mutate(AVI = case_when(AVI == "aa.HAN_i" ~ "Avoided HAN",
AVI == "aa.LAN_i" ~ "Avoided LAN",
AVI == "aa.NEG_i" ~ "Avoided NEG")),
aes(x = AVI, y = mean, fill = ethnicity)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Avoided HAN, NEG, and LAN (Ipsatized)",
ethnicity_EA = "Ethnicity",
y = "Avoided Affect") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_fill_manual(name = "ethnicity", values = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF" )) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=0.1, position=position_dodge(0.9)) +
theme(plot.title = element_text(size = 10),
axis.title = element_text(size = 9),
legend.title = element_blank(),
axis.title.x=element_blank())
AVIplot_i2
Nonipsatized Items
# select AVI data
avidata_raw <- data %>% distinct(subnum, .keep_all = TRUE) %>%
dplyr::select(
subnum, ethnicity,
aa.NA, aa.PA, i.PA, i.NA, r.NA, r.PA,
aa.HAN, aa.NEG, aa.LAN,
i.HAN, i.NEG, i.LAN, i.HAP, i.POS, i.LAP,
r.HAN, r.NEG, r.LAN, r.HAP, r.POS, r.LAP)
# test if cultures differ on avoided NA (ipsatized scores, iPA, rPA)
avoidedNAresult <-
lm(aa.NA ~ ethnicity,
data = avidata_raw)
summary(avoidedNAresult)
##
## Call:
## lm(formula = aa.NA ~ ethnicity, data = avidata_raw)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.371 -0.299 0.185 0.465 1.243
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.3706 0.0948 46.10 < 2e-16 ***
## ethnicityBeijing Chinese -0.6134 0.1247 -4.92 2.1e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.793 on 164 degrees of freedom
## Multiple R-squared: 0.129, Adjusted R-squared: 0.123
## F-statistic: 24.2 on 1 and 164 DF, p-value: 2.09e-06
# test if cultures differ on avoided NA (ipsatized scores, iPA, iNA, rPA, rNA)
avoidedNAresult_EA_all <-
lm(aa.NA ~ i.PA + i.NA + r.PA + r.NA + ethnicity,
data = avidata_raw)
summary(avoidedNAresult_EA_all)
##
## Call:
## lm(formula = aa.NA ~ i.PA + i.NA + r.PA + r.NA + ethnicity, data = avidata_raw)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.567 -0.257 0.200 0.402 1.268
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.6486 0.7735 4.72 5.2e-06 ***
## i.PA 0.2745 0.1845 1.49 0.1387
## i.NA -0.1696 0.2427 -0.70 0.4857
## r.PA -0.0776 0.1669 -0.47 0.6424
## r.NA 0.0395 0.1903 0.21 0.8360
## ethnicityBeijing Chinese -0.4567 0.1401 -3.26 0.0014 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.783 on 160 degrees of freedom
## Multiple R-squared: 0.173, Adjusted R-squared: 0.147
## F-statistic: 6.68 on 5 and 160 DF, p-value: 1.13e-05
plot_coeffs1 <- data.frame(
Predictor = c("Intercept", "Ideal PA", "Ideal NA", "Actual PA", "Actual NA", "Culture"),
Coefficient = c(summary(avoidedNAresult_EA_all)$coefficient[1,1], summary(avoidedNAresult_EA_all)$coefficient[2,1], summary(avoidedNAresult_EA_all)$coefficient[3,1], summary(avoidedNAresult_EA_all)$coefficient[4,1], summary(avoidedNAresult_EA_all)$coefficient[5,1], summary(avoidedNAresult_EA_all)$coefficient[6,1]),
CILower = c(confint(avoidedNAresult_EA_all)[1,1], confint(avoidedNAresult_EA_all)[2,1], confint(avoidedNAresult_EA_all)[3,1], confint(avoidedNAresult_EA_all)[4,1], confint(avoidedNAresult_EA_all)[5,1], confint(avoidedNAresult_EA_all)[6,1]),
CIUpper = c(confint(avoidedNAresult_EA_all)[1,2], confint(avoidedNAresult_EA_all)[2,2], confint(avoidedNAresult_EA_all)[3,2], confint(avoidedNAresult_EA_all)[4,2], confint(avoidedNAresult_EA_all)[5,2], confint(avoidedNAresult_EA_all)[6,2])) %>%
dplyr::mutate(
Predictor = factor(Predictor,
levels = c("Ideal PA", "Ideal NA", "Actual PA", "Actual NA", "Culture", "Intercept")),
Color = ifelse(Predictor == "Culture", "brown", "black")) # Add a new column for color
ggplot(plot_coeffs1, aes(x = Predictor, y = Coefficient)) +
ylab("Regression Coefficient")+
geom_point(aes(color = Color)) + # Map the color aesthetic
geom_errorbar(aes(ymin = CILower, ymax = CIUpper, color = Color), width = .2, position = position_dodge(.9)) +
geom_hline(yintercept = 0, color = "grey") +
ylim(c(-1.5, 6)) +
scale_color_manual(values = c("black" = "black", "brown" = "brown")) +
theme_minimal()+
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 10),
legend.position = "none",
axis.title.x=element_blank())
# test if cultures differ on avoided NA (ipsatized scores, iPA, iNA, rPA, rNA)
avoidedNAresult_EA_noethn <-
lm(aa.NA ~ i.PA + i.NA + r.PA + r.NA,
data = avidata_raw)
summary(avoidedNAresult_EA_noethn)
##
## Call:
## lm(formula = aa.NA ~ i.PA + i.NA + r.PA + r.NA, data = avidata_raw)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.392 -0.220 0.158 0.498 1.215
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.3516 0.7907 4.24 3.8e-05 ***
## i.PA 0.2577 0.1898 1.36 0.177
## i.NA -0.4370 0.2351 -1.86 0.065 .
## r.PA -0.0264 0.1711 -0.15 0.877
## r.NA 0.1940 0.1897 1.02 0.308
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.806 on 161 degrees of freedom
## Multiple R-squared: 0.118, Adjusted R-squared: 0.0957
## F-statistic: 5.37 on 4 and 161 DF, p-value: 0.000441
# Compare the two models using anova()
anova_result <- anova(avoidedNAresult_EA_noethn, avoidedNAresult_EA_all)
print(anova_result)
## Analysis of Variance Table
##
## Model 1: aa.NA ~ i.PA + i.NA + r.PA + r.NA
## Model 2: aa.NA ~ i.PA + i.NA + r.PA + r.NA + ethnicity
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 161 104
## 2 160 98 1 6.51 10.6 0.0014 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
options(contrasts = c("contr.treatment", "contr.poly"))
# test if cultures differ on average unpleasantness
avg_unpleasantness_result <-
aov(avg_unpleasantActivity_dev ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
Anova(avg_unpleasantness_result, type = "3")
## Anova Table (Type III tests)
##
## Response: avg_unpleasantActivity_dev
## Sum Sq Df F value Pr(>F)
## (Intercept) 68.7 1 211.62 <2e-16 ***
## ethnicity 0.1 1 0.16 0.69
## Residuals 53.2 164
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
eta_squared(avg_unpleasantness_result)
## For one-way between subjects designs, partial eta squared is equivalent
## to eta squared. Returning eta squared.
## # Effect Size for ANOVA
##
## Parameter | Eta2 | 95% CI
## -----------------------------------
## ethnicity | 9.60e-04 | [0.00, 1.00]
##
## - One-sided CIs: upper bound fixed at [1.00].
emmeans(avg_unpleasantness_result, pairwise ~ ethnicity)
## $emmeans
## ethnicity emmean SE df lower.CL upper.CL
## European Americans -0.99 0.0681 164 -1.12 -0.856
## Beijing Chinese -1.03 0.0581 164 -1.14 -0.911
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.0355 0.0895 164 0.397 0.6919
t.test(avg_unpleasantActivity_dev ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
##
## Welch Two Sample t-test
##
## data: avg_unpleasantActivity_dev by ethnicity
## t = 0.39, df = 136, p-value = 0.7
## alternative hypothesis: true difference in means between group European Americans and group Beijing Chinese is not equal to 0
## 95 percent confidence interval:
## -0.1454 0.2165
## sample estimates:
## mean in group European Americans mean in group Beijing Chinese
## -0.9904 -1.0259
Ipsatized
options(contrasts = c("contr.treatment", "contr.poly"))
# test if cultures differ on average momentary NA (ipsatized scores)
avg_negAffIntensity_i_result <-
aov(avg_negAffIntensity_i ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
Anova(avg_negAffIntensity_i_result, type = "3")
## Anova Table (Type III tests)
##
## Response: avg_negAffIntensity_i
## Sum Sq Df F value Pr(>F)
## (Intercept) 23.38 1 236.50 <2e-16 ***
## ethnicity 0.09 1 0.91 0.34
## Residuals 16.21 164
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
eta_squared(avg_negAffIntensity_i_result)
## For one-way between subjects designs, partial eta squared is equivalent
## to eta squared. Returning eta squared.
## # Effect Size for ANOVA
##
## Parameter | Eta2 | 95% CI
## -----------------------------------
## ethnicity | 5.55e-03 | [0.00, 1.00]
##
## - One-sided CIs: upper bound fixed at [1.00].
emmeans(avg_negAffIntensity_i_result, pairwise ~ ethnicity)
## $emmeans
## ethnicity emmean SE df lower.CL upper.CL
## European Americans -0.578 0.0376 164 -0.652 -0.504
## Beijing Chinese -0.625 0.0321 164 -0.688 -0.562
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.0473 0.0494 164 0.956 0.3403
t.test(avg_negAffIntensity_i ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
##
## Welch Two Sample t-test
##
## data: avg_negAffIntensity_i by ethnicity
## t = 0.92, df = 128, p-value = 0.4
## alternative hypothesis: true difference in means between group European Americans and group Beijing Chinese is not equal to 0
## 95 percent confidence interval:
## -0.05392 0.14843
## sample estimates:
## mean in group European Americans mean in group Beijing Chinese
## -0.5779 -0.6252
Nonipsatized
# test if cultures differ on average momentary NA (nonipsatized scores)
avg_negAffIntensity_result <-
aov(avg_negAffIntensity ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
Anova(avg_negAffIntensity_result, type = "3")
## Anova Table (Type III tests)
##
## Response: avg_negAffIntensity
## Sum Sq Df F value Pr(>F)
## (Intercept) 200.3 1 1392.2 <2e-16 ***
## ethnicity 0.0 1 0.2 0.66
## Residuals 23.6 164
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
eta_squared(avg_negAffIntensity_result)
## For one-way between subjects designs, partial eta squared is equivalent
## to eta squared. Returning eta squared.
## # Effect Size for ANOVA
##
## Parameter | Eta2 | 95% CI
## -----------------------------------
## ethnicity | 1.20e-03 | [0.00, 1.00]
##
## - One-sided CIs: upper bound fixed at [1.00].
emmeans(avg_negAffIntensity_result, pairwise ~ ethnicity)
## $emmeans
## ethnicity emmean SE df lower.CL upper.CL
## European Americans 1.69 0.0453 164 1.60 1.78
## Beijing Chinese 1.67 0.0387 164 1.59 1.74
##
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## European Americans - Beijing Chinese 0.0264 0.0596 164 0.443 0.6582
t.test(avg_negAffIntensity ~ ethnicity,
data = data %>% distinct(subnum, .keep_all = TRUE))
##
## Welch Two Sample t-test
##
## data: avg_negAffIntensity by ethnicity
## t = 0.44, df = 143, p-value = 0.7
## alternative hypothesis: true difference in means between group European Americans and group Beijing Chinese is not equal to 0
## 95 percent confidence interval:
## -0.09271 0.14556
## sample estimates:
## mean in group European Americans mean in group Beijing Chinese
## 1.692 1.665
# plot nonipsatized scores
avg_momentNAplot <-
ggplot(data %>% distinct(subnum, .keep_all = TRUE) %>%
group_by(ethnicity) %>%
summarize(
mean = mean(avg_negAffIntensity, na.rm = TRUE),
sd = sd(avg_negAffIntensity, na.rm = TRUE),
se = sd(avg_negAffIntensity, na.rm = TRUE)/sqrt(length(avg_negAffIntensity))),
aes(x = ethnicity, y = mean, fill = ethnicity)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Average Momentary Negative Affect Intensity",
x= " ",
y = "NA Intensity") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_fill_manual(name = "ethnicity", values = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF" )) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=0.1, position=position_dodge(0.9)) +
theme(plot.title = element_text(size = 12),
axis.title = element_text(size = 9),
legend.title = element_blank())
avg_momentNAplot
rm(avg_momentNAplot)
Visualize
ICC for the model (1|subnum) distinct from (1|subnum:date)
# baseline model w subnum
baseline_sub = lmer(negAffIntensity_i ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.2131
# baseline model w date
baseline_date = lmer(negAffIntensity_i ~ 1 + (1 | date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_date <- VarCorr(baseline_date) %>% as.data.frame()
icc_between_date <- rand_eff_date[1,4]/(rand_eff_date[1,4]+rand_eff_date[2,4]) # (between-date var) / (between + within date var)
icc_between_date
## [1] 0.07239
# baseline model w date
baseline_subdate = lmer(negAffIntensity_i ~ 1 + (1 | subnum:date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subdate <- VarCorr(baseline_subdate) %>% as.data.frame()
icc_between_subdate <- rand_eff_subdate[1,4]/(rand_eff_subdate[1,4]+rand_eff_subdate[2,4]) # (between-date var) / (between + within date var)
icc_between_subdate
## [1] 0.3804
# compare model fit
AIC(baseline_sub); AIC(baseline_date); AIC(baseline_subdate)
## [1] 11445
## [1] 12439
## [1] 11485
BIC(baseline_sub); BIC(baseline_date); BIC(baseline_subdate)
## [1] 11465
## [1] 12459
## [1] 11506
ICC for the model (1|subnum) distinct from (1|subnum/day)
# baseline model w subnum
baseline_sub = lmer(negAffIntensity_i ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.2131
# baseline model w day
baseline_day = lmer(negAffIntensity_i ~ 1 + (1 | day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_day <- VarCorr(baseline_day) %>% as.data.frame()
icc_between_day <- rand_eff_day[1,4]/(rand_eff_day[1,4]+rand_eff_day[2,4]) # (between-day var) / (between + within day var)
icc_between_day
## [1] 0.004774
# baseline model w day
baseline_subday = lmer(negAffIntensity_i ~ 1 + (1 | subnum:day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subday <- VarCorr(baseline_subday) %>% as.data.frame()
icc_between_subday <- rand_eff_subday[1,4]/(rand_eff_subday[1,4]+rand_eff_subday[2,4]) # (between-day var) / (between + within day var)
icc_between_subday
## [1] 0.3083
# compare model fit
AIC(baseline_sub); AIC(baseline_day); AIC(baseline_subday)
## [1] 11445
## [1] 12551
## [1] 11661
BIC(baseline_sub); BIC(baseline_day); BIC(baseline_subday)
## [1] 11465
## [1] 12571
## [1] 11682
# see if random slope is needed
yesslopeforula = "negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum)"
noslopeforula = "negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (1 | subnum)"
yesslope = lmer(paste(yesslopeforula), data = data, REML = FALSE, na.action = na.exclude)
noslope = lmer(paste(noslopeforula), data = data, REML = FALSE, na.action = na.exclude)
#yesslope_brm <- brm(paste(yesslopeforula), data = data, family = gaussian(), save_all_pars = TRUE, iter = 2000, warmup = 1000, chains = 4, seed = 1234)
#noslope_brm <- brm(paste(noslopeforula), data = data, family = gaussian(), save_all_pars = TRUE, iter = 2000, warmup = 1000, chains = 4, seed = 1234)
AIC(noslope); AIC(yesslope)
## [1] 9773
## [1] 9672
BIC(noslope); BIC(yesslope)
## [1] 9821
## [1] 9733
#bf(bridge_sampler(yesslope_brm), bridge_sampler(noslope_brm))
yesslope %>% summary()
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: paste(yesslopeforula)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 9672 9733 -4827 9654 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.579 -0.601 -0.139 0.420 6.964
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.06709 0.2590
## unpleasantActivity_dev 0.00629 0.0793 0.16
## Residual 0.25017 0.5002
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -0.3107 0.0490 167.3241
## unpleasantActivity_dev 0.1186 0.0119 125.5028
## ethnicityBeijing Chinese -0.0690 0.0427 166.0786
## avg_unpleasantActivity_dev 0.2706 0.0370 165.8438
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.0160 0.0164 147.7786
## t value Pr(>|t|)
## (Intercept) -6.35 2e-09 ***
## unpleasantActivity_dev 9.97 <2e-16 ***
## ethnicityBeijing Chinese -1.61 0.11
## avg_unpleasantActivity_dev 7.32 1e-11 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.97 0.33
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.084
## ethnctyBjnC -0.482 -0.094
## avg_nplsnA_ 0.748 0.003 0.031
## unplsnA_:BC -0.059 -0.724 0.117 0.000
#interact_plot(
# lmer(negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
# data = data, REML = FALSE,
# na.action = na.exclude),
# pred = "unpleasantActivity_dev",
# modx = "ethnicity",
# legend.main = "Culture",
# centered = "none",
# colors = c("European Americans" = "white", "Beijing Chinese" = "white")) +
# xlab("Unpleasantness of Current Activity") +
# ylab("Negative Affect (Ipsatized)") +
# theme(legend.position = "bottom")
#interact_plot(
# lmer(negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + #(unpleasantActivity_dev | subnum),
# data = data, REML = FALSE,
# na.action = na.exclude),
# pred = "unpleasantActivity_dev",
# modx = "ethnicity",
# legend.main = "Culture",
# centered = "none",
# colors = c("European Americans" = "#F49070", "Beijing Chinese" = "white")) +
# xlab("Unpleasantness of Current Activity") +
# ylab("Negative Affect (Ipsatized)") +
# theme(legend.position = "bottom")
interact_plot(
lmer(negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity",
legend.main = "Culture",
centered = "none",
colors = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF")) +
xlab("Unpleasantness of Current Activity") +
ylab("Negative Affect (Ipsatized)") +
theme(legend.position = "bottom")
sim_slopes(
lmer(negAffIntensity_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity")
## Warning: Johnson-Neyman intervals are not available for factor moderators.
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when ethnicity = Beijing Chinese:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.10 0.01 9.06 0.00
##
## Slope of unpleasantActivity_dev when ethnicity = European Americans:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.12 0.01 9.97 0.00
# controlling for PA
lmer(negAffIntensity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + posAffIntensity_dev + avg_posAffIntensity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary()
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## negAffIntensity ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## posAffIntensity_dev + avg_posAffIntensity_dev + (unpleasantActivity_dev |
## subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 9498 9572 -4738 9476 6262
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.453 -0.568 -0.133 0.415 8.216
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.12530 0.354
## unpleasantActivity_dev 0.00547 0.074 0.10
## Residual 0.23946 0.489
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 1.8091 0.1710 166.4255
## unpleasantActivity_dev 0.0873 0.0115 138.0243
## ethnicityBeijing Chinese -0.0509 0.0572 166.3852
## avg_unpleasantActivity_dev 0.1903 0.0589 166.3692
## posAffIntensity_dev -0.2203 0.0124 6105.7029
## avg_posAffIntensity_dev 0.0258 0.0695 166.3561
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.0150 0.0156 153.2143
## t value Pr(>|t|)
## (Intercept) 10.58 < 2e-16 ***
## unpleasantActivity_dev 7.59 4.3e-12 ***
## ethnicityBeijing Chinese -0.89 0.3747
## avg_unpleasantActivity_dev 3.23 0.0015 **
## posAffIntensity_dev -17.73 < 2e-16 ***
## avg_posAffIntensity_dev 0.37 0.7106
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.96 0.3398
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_ psAfI_ av_AI_
## unplsntAct_ 0.017
## ethnctyBjnC -0.252 -0.055
## avg_nplsnA_ -0.256 0.003 0.066
## psAffIntns_ 0.000 0.190 0.002 0.002
## avg_psAffI_ -0.924 0.002 0.074 0.539 0.000
## unplsnA_:BC -0.012 -0.714 0.070 -0.001 -0.025 -0.001
ICC for the model (1|subnum) distinct from (1|subnum:date)
# baseline model w subnum
baseline_sub = lmer(negAffIntensity ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.2862
# baseline model w date
baseline_date = lmer(negAffIntensity ~ 1 + (1 | date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_date <- VarCorr(baseline_date) %>% as.data.frame()
icc_between_date <- rand_eff_date[1,4]/(rand_eff_date[1,4]+rand_eff_date[2,4]) # (between-date var) / (between + within date var)
icc_between_date
## [1] 0.1145
# baseline model w date
baseline_subdate = lmer(negAffIntensity ~ 1 + (1 | subnum:date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subdate <- VarCorr(baseline_subdate) %>% as.data.frame()
icc_between_subdate <- rand_eff_subdate[1,4]/(rand_eff_subdate[1,4]+rand_eff_subdate[2,4]) # (between-date var) / (between + within date var)
icc_between_subdate
## [1] 0.44
# compare model fit
AIC(baseline_sub); AIC(baseline_date); AIC(baseline_subdate)
## [1] 11561
## [1] 13006
## [1] 11788
BIC(baseline_sub); BIC(baseline_date); BIC(baseline_subdate)
## [1] 11581
## [1] 13026
## [1] 11808
ICC for the model (1|subnum) distinct from (1|subnum/day)
# baseline model w subnum
baseline_sub = lmer(negAffIntensity ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.2862
# baseline model w day
baseline_day = lmer(negAffIntensity ~ 1 + (1 | day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_day <- VarCorr(baseline_day) %>% as.data.frame()
icc_between_day <- rand_eff_day[1,4]/(rand_eff_day[1,4]+rand_eff_day[2,4]) # (between-day var) / (between + within day var)
icc_between_day
## [1] 0.004629
# baseline model w day
baseline_subday = lmer(negAffIntensity ~ 1 + (1 | subnum:day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subday <- VarCorr(baseline_subday) %>% as.data.frame()
icc_between_subday <- rand_eff_subday[1,4]/(rand_eff_subday[1,4]+rand_eff_subday[2,4]) # (between-day var) / (between + within day var)
icc_between_subday
## [1] 0.3745
# compare model fit
AIC(baseline_sub); AIC(baseline_day); AIC(baseline_subday)
## [1] 11561
## [1] 13252
## [1] 11959
BIC(baseline_sub); BIC(baseline_day); BIC(baseline_subday)
## [1] 11581
## [1] 13272
## [1] 11979
# use unpleasantness of activity
lmer(negAffIntensity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # non Sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## negAffIntensity ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 9800 9861 -4891 9782 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.398 -0.593 -0.139 0.409 6.925
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.12508 0.3537
## unpleasantActivity_dev 0.00569 0.0754 0.04
## Residual 0.25179 0.5018
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 1.8715 0.0657 166.5187
## unpleasantActivity_dev 0.1262 0.0115 128.6351
## ethnicityBeijing Chinese -0.0508 0.0571 166.4327
## avg_unpleasantActivity_dev 0.1824 0.0497 166.2769
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.0220 0.0160 152.8179
## t value Pr(>|t|)
## (Intercept) 28.50 < 2e-16 ***
## unpleasantActivity_dev 10.94 < 2e-16 ***
## ethnicityBeijing Chinese -0.89 0.37477
## avg_unpleasantActivity_dev 3.67 0.00033 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -1.38 0.17048
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.020
## ethnctyBjnC -0.480 -0.022
## avg_nplsnA_ 0.750 0.001 0.031
## unplsnA_:BC -0.014 -0.722 0.027 0.000
interact_plot(
lmer(negAffIntensity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity",
legend.main = "Culture",
centered = "none",
colors = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF")) +
xlab("Unpleasantness of Current Activity") +
ylab("Negative Affect (raw)") +
theme(legend.position = "bottom")
sim_slopes(
lmer(negAffIntensity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity")
## Warning: Johnson-Neyman intervals are not available for factor moderators.
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when ethnicity = Beijing Chinese:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.10 0.01 9.43 0.00
##
## Slope of unpleasantActivity_dev when ethnicity = European Americans:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.13 0.01 10.94 0.00
# R.ANXI_i, R.BORE_i, R.SADX_i, R.ANGR_i
# use unpleasantness of activity | R.ANXI_i
lmer(R.ANXI_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # marginal sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## R.ANXI_i ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 14846 14907 -7414 14828 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.108 -0.628 -0.166 0.507 5.258
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1541 0.393
## unpleasantActivity_dev 0.0115 0.107 0.43
## Residual 0.5737 0.757
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -0.0170 0.0726 173.3597
## unpleasantActivity_dev 0.1582 0.0167 127.6366
## ethnicityBeijing Chinese -0.2348 0.0647 165.1706
## avg_unpleasantActivity_dev 0.2940 0.0538 165.1408
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.0409 0.0233 153.0781
## t value Pr(>|t|)
## (Intercept) -0.23 0.81456
## unpleasantActivity_dev 9.45 < 2e-16 ***
## ethnicityBeijing Chinese -3.63 0.00038 ***
## avg_unpleasantActivity_dev 5.46 1.7e-07 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -1.76 0.08067 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.220
## ethnctyBjnC -0.494 -0.238
## avg_nplsnA_ 0.735 0.009 0.030
## unplsnA_:BC -0.154 -0.720 0.297 0.000
# use unpleasantness of activity | R.BORE_i
lmer(R.BORE_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # non sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## R.BORE_i ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 15380 15440 -7681 15362 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.853 -0.637 -0.172 0.533 5.255
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.12725 0.3567
## unpleasantActivity_dev 0.00993 0.0997 0.10
## Residual 0.62938 0.7933
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -0.24384 0.06860 167.37429
## unpleasantActivity_dev 0.14764 0.01638 112.03546
## ethnicityBeijing Chinese 0.12817 0.05970 166.97423
## avg_unpleasantActivity_dev 0.26211 0.05191 166.57757
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.00352 0.02291 137.35016
## t value Pr(>|t|)
## (Intercept) -3.55 0.00049 ***
## unpleasantActivity_dev 9.01 6.3e-15 ***
## ethnicityBeijing Chinese 2.15 0.03326 *
## avg_unpleasantActivity_dev 5.05 1.2e-06 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.15 0.87827
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.047
## ethnctyBjnC -0.481 -0.052
## avg_nplsnA_ 0.749 0.002 0.031
## unplsnA_:BC -0.032 -0.715 0.064 0.000
# use unpleasantness of activity | R.SADX_i
lmer(R.SADX_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # non sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## R.SADX_i ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 13238 13299 -6610 13220 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.476 -0.510 -0.172 0.249 7.675
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1336 0.366
## unpleasantActivity_dev 0.0108 0.104 0.36
## Residual 0.4412 0.664
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -0.45994 0.06765 172.06861
## unpleasantActivity_dev 0.07456 0.01563 122.08494
## ethnicityBeijing Chinese -0.11080 0.05997 166.10854
## avg_unpleasantActivity_dev 0.24444 0.05045 166.25997
## unpleasantActivity_dev:ethnicityBeijing Chinese 0.00734 0.02159 144.04054
## t value Pr(>|t|)
## (Intercept) -6.80 1.7e-10 ***
## unpleasantActivity_dev 4.77 5.2e-06 ***
## ethnicityBeijing Chinese -1.85 0.066 .
## avg_unpleasantActivity_dev 4.84 2.9e-06 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese 0.34 0.735
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.189
## ethnctyBjnC -0.491 -0.207
## avg_nplsnA_ 0.738 0.007 0.030
## unplsnA_:BC -0.133 -0.724 0.260 0.000
# use unpleasantness of activity | R.ANGR_i
lmer(R.ANGR_i ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # non sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## R.ANGR_i ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 13755 13815 -6868 13737 6264
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.199 -0.484 -0.195 0.052 6.505
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1090 0.330
## unpleasantActivity_dev 0.0113 0.106 0.31
## Residual 0.4825 0.695
## Number of obs: 6273, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -0.5514 0.0623 170.5517
## unpleasantActivity_dev 0.0921 0.0161 125.0164
## ethnicityBeijing Chinese -0.0599 0.0549 166.1953
## avg_unpleasantActivity_dev 0.2521 0.0467 166.3466
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.0247 0.0223 148.0087
## t value Pr(>|t|)
## (Intercept) -8.85 1.1e-15 ***
## unpleasantActivity_dev 5.70 8.0e-08 ***
## ethnicityBeijing Chinese -1.09 0.28
## avg_unpleasantActivity_dev 5.40 2.3e-07 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -1.11 0.27
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.159
## ethnctyBjnC -0.488 -0.175
## avg_nplsnA_ 0.742 0.006 0.030
## unplsnA_:BC -0.112 -0.723 0.219 0.000
ICC for the model (1|subnum) distinct from (1|subnum:date)
# baseline model w subnum
baseline_sub = lmer(desireActivity ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.14
# baseline model w date
baseline_date = lmer(desireActivity ~ 1 + (1 | date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_date <- VarCorr(baseline_date) %>% as.data.frame()
icc_between_date <- rand_eff_date[1,4]/(rand_eff_date[1,4]+rand_eff_date[2,4]) # (between-date var) / (between + within date var)
icc_between_date
## [1] 0.06851
# baseline model w date
baseline_subdate = lmer(desireActivity ~ 1 + (1 | subnum:date),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subdate <- VarCorr(baseline_subdate) %>% as.data.frame()
icc_between_subdate <- rand_eff_subdate[1,4]/(rand_eff_subdate[1,4]+rand_eff_subdate[2,4]) # (between-date var) / (between + within date var)
icc_between_subdate
## [1] 0.2008
# compare model fit
AIC(baseline_sub); AIC(baseline_date); AIC(baseline_subdate)
## [1] 18952
## [1] 19465
## [1] 19190
BIC(baseline_sub); BIC(baseline_date); BIC(baseline_subdate)
## [1] 18973
## [1] 19485
## [1] 19210
ICC for the model (1|subnum) distinct from (1|subnum:day)
# baseline model w subnum
baseline_sub = lmer(desireActivity ~ 1 + (1 | subnum),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_sub <- VarCorr(baseline_sub) %>% as.data.frame()
icc_between_sub <- rand_eff_sub[1,4]/(rand_eff_sub[1,4]+rand_eff_sub[2,4]) # (between-person var) / (between + within var)
icc_between_sub
## [1] 0.14
# baseline model w day
baseline_day = lmer(desireActivity ~ 1 + (1 | day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_day <- VarCorr(baseline_day) %>% as.data.frame()
icc_between_day <- rand_eff_day[1,4]/(rand_eff_day[1,4]+rand_eff_day[2,4]) # (between-day var) / (between + within day var)
icc_between_day
## [1] 0.001398
# baseline model w day
baseline_subday = lmer(desireActivity ~ 1 + (1 | subnum:day),
data = data, REML = FALSE, na.action = na.exclude)
rand_eff_subday <- VarCorr(baseline_subday) %>% as.data.frame()
icc_between_subday <- rand_eff_subday[1,4]/(rand_eff_subday[1,4]+rand_eff_subday[2,4]) # (between-day var) / (between + within day var)
icc_between_subday
## [1] 0.1926
# compare model fit
AIC(baseline_sub); AIC(baseline_day); AIC(baseline_subday)
## [1] 18952
## [1] 19573
## [1] 19180
BIC(baseline_sub); BIC(baseline_day); BIC(baseline_subday)
## [1] 18973
## [1] 19593
## [1] 19200
# see if random slope is needed
yesslopeforula = "desireActivity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum)"
noslopeforula = "desireActivity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (1 | subnum)"
yesslope = lmer(paste(yesslopeforula), data = data, REML = FALSE, na.action = na.exclude)
noslope = lmer(paste(noslopeforula), data = data, REML = FALSE, na.action = na.exclude)
#yesslope_brm <- brm(paste(yesslopeforula), data = data, family = gaussian(), save_all_pars = TRUE, iter = 2000, warmup = 1000, chains = 4, seed = 1234)
#noslope_brm <- brm(paste(noslopeforula), data = data, family = gaussian(), save_all_pars = TRUE, iter = 2000, warmup = 1000, chains = 4, seed = 1234)
AIC(noslope); AIC(yesslope)
## [1] 18020
## [1] 17840
BIC(noslope); BIC(yesslope)
## [1] 18067
## [1] 17901
#bf(bridge_sampler(yesslope_brm), bridge_sampler(noslope_brm))
yesslope %>% summary()
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: paste(yesslopeforula)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 17840 17901 -8911 17822 6247
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.796 -0.517 -0.202 0.061 4.116
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1556 0.394
## unpleasantActivity_dev 0.0274 0.165 0.60
## Residual 0.9402 0.970
## Number of obs: 6256, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.9387 0.0727 183.1159
## unpleasantActivity_dev 0.3665 0.0241 134.5045
## ethnicityBeijing Chinese -0.2833 0.0669 165.6040
## avg_unpleasantActivity_dev 0.1933 0.0524 163.9558
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.1650 0.0332 156.6104
## t value Pr(>|t|)
## (Intercept) 12.92 < 2e-16 ***
## unpleasantActivity_dev 15.18 < 2e-16 ***
## ethnicityBeijing Chinese -4.24 3.8e-05 ***
## avg_unpleasantActivity_dev 3.69 0.00031 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -4.97 1.7e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.327
## ethnctyBjnC -0.513 -0.346
## avg_nplsnA_ 0.714 0.012 0.028
## unplsnA_:BC -0.232 -0.727 0.435 0.000
r2_values_ethn <- r.squaredGLMM(yesslope)
## Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.
r2_values_ethn
## R2m R2c
## [1,] 0.1408 0.2923
# use unpleasantness of activity
lmer(desireActivity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # Sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## desireActivity ~ unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 17840 17901 -8911 17822 6247
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.796 -0.517 -0.202 0.061 4.116
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1556 0.394
## unpleasantActivity_dev 0.0274 0.165 0.60
## Residual 0.9402 0.970
## Number of obs: 6256, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.9387 0.0727 183.1159
## unpleasantActivity_dev 0.3665 0.0241 134.5045
## ethnicityBeijing Chinese -0.2833 0.0669 165.6040
## avg_unpleasantActivity_dev 0.1933 0.0524 163.9558
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.1650 0.0332 156.6104
## t value Pr(>|t|)
## (Intercept) 12.92 < 2e-16 ***
## unpleasantActivity_dev 15.18 < 2e-16 ***
## ethnicityBeijing Chinese -4.24 3.8e-05 ***
## avg_unpleasantActivity_dev 3.69 0.00031 ***
## unpleasantActivity_dev:ethnicityBeijing Chinese -4.97 1.7e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_
## unplsntAct_ 0.327
## ethnctyBjnC -0.513 -0.346
## avg_nplsnA_ 0.714 0.012 0.028
## unplsnA_:BC -0.232 -0.727 0.435 0.000
interact_plot(
lmer(desireActivity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity",
legend.main = "Culture",
centered = "none",
vary.lty = FALSE,
colors = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF")) +
xlab("Unpleasantness of Current Activity") +
ylab("Desire to Do Something Else") +
theme(legend.position = "bottom") +
scale_y_continuous(limits = c(-0.5, 4.5)) + jtools::theme_apa()
sim_slopes(
lmer(desireActivity ~ unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity")
## Warning: Johnson-Neyman intervals are not available for factor moderators.
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when ethnicity = Beijing Chinese:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.20 0.02 8.85 0.00
##
## Slope of unpleasantActivity_dev when ethnicity = European Americans:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.37 0.02 15.18 0.00
# Extract random effects
random_effects <- ranef(yesslope)$subnum
random_effects <- random_effects %>% dplyr::rename(rand_unpleasantActivity_dev = unpleasantActivity_dev)
# Extract fixed effects
fixed_effects <- fixef(yesslope)
# Prepare data for plotting
# Create a data frame for predictions
predict_data <- data %>%
dplyr::select(subnum, unpleasantActivity_dev, ethnicity) %>%
distinct()
# Merge random effects with the prediction data
predict_data <- merge(predict_data, random_effects, by.x = "subnum", by.y = "row.names")
# Calculate predicted desireActivity for each subject
predict_data <- predict_data %>%
mutate(predicted_desireActivity = fixed_effects["(Intercept)"] +
fixed_effects["unpleasantActivity_dev"] * unpleasantActivity_dev +
fixed_effects["ethnicityBeijing Chinese"] * (ethnicity == "Beijing Chinese") +
fixed_effects["unpleasantActivity_dev:ethnicityBeijing Chinese"] * (unpleasantActivity_dev * (ethnicity == "Beijing Chinese")) +
`(Intercept)` +
rand_unpleasantActivity_dev * unpleasantActivity_dev)
# Plot the lines
ggplot(predict_data, aes(x = unpleasantActivity_dev, y = predicted_desireActivity, group = subnum, color = ethnicity)) +
geom_line(alpha = 0.5) +
scale_y_continuous(limits = c(-0.5, 4.5)) +
labs(x = "Unpleasantness of Current Activity",
y = "Desire to Do Something Else") +
jtools::theme_apa() +
scale_color_manual(values = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF"))
## Warning: Removed 112 rows containing missing values (`geom_line()`).
# use unpleasantness of activity - ana
aa_yesslope <- lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) # Sig
summary(aa_yesslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## desireActivity ~ unpleasantActivity_dev * aa.NA_i + avg_unpleasantActivity_dev +
## (unpleasantActivity_dev | subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 17862 17922 -8922 17844 6247
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.769 -0.519 -0.198 0.068 4.100
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.171 0.413
## unpleasantActivity_dev 0.032 0.179 0.64
## Residual 0.940 0.970
## Number of obs: 6256, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.6458 0.0924 184.0594 6.99 5.0e-11
## unpleasantActivity_dev 0.1978 0.0367 150.7435 5.40 2.6e-07
## aa.NA_i 0.1542 0.0788 164.4722 1.96 0.05206
## avg_unpleasantActivity_dev 0.1916 0.0531 163.3293 3.61 0.00041
## unpleasantActivity_dev:aa.NA_i 0.0939 0.0386 141.7918 2.44 0.01612
##
## (Intercept) ***
## unpleasantActivity_dev ***
## aa.NA_i .
## avg_unpleasantActivity_dev ***
## unpleasantActivity_dev:aa.NA_i *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ aa.NA_ avg_A_
## unplsntAct_ 0.390
## aa.NA_i -0.724 -0.430
## avg_nplsnA_ 0.607 0.006 -0.037
## unplA_:.NA_ -0.346 -0.880 0.495 0.003
r2_values_aa <- r.squaredGLMM(aa_yesslope)
r2_values_aa
## R2m R2c
## [1,] 0.1144 0.285
interact_plot(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "aa.NA_i",
modx.values = "plus-minus",
legend.main = "Avoided NA",
centered = "none") +
xlab("Unpleasantness of Current Activity") +
ylab("Desire to Do Something Else") +
theme(legend.position = "bottom") +
scale_y_continuous(limits = c(-0.5, 3))
sim_slopes(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "aa.NA_i")
## JOHNSON-NEYMAN INTERVAL
##
## When aa.NA_i is OUTSIDE the interval [-14.29, -0.77], the slope of
## unpleasantActivity_dev is p < .05.
##
## Note: The range of observed values of aa.NA_i is [-1.05, 1.39]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when aa.NA_i = 0.3734 (- 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.23 0.02 9.34 0.00
##
## Slope of unpleasantActivity_dev when aa.NA_i = 0.8170 (Mean):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.27 0.02 15.76 0.00
##
## Slope of unpleasantActivity_dev when aa.NA_i = 1.2606 (+ 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.32 0.02 13.24 0.00
# use unpleasantness of activity - ethn and ana
lmer(desireActivity ~ unpleasantActivity_dev:aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) %>% summary() # both sig
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## desireActivity ~ unpleasantActivity_dev:aa.NA_i + unpleasantActivity_dev *
## ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev |
## subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 17842 17910 -8911 17822 6246
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.795 -0.519 -0.205 0.061 4.120
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1556 0.394
## unpleasantActivity_dev 0.0272 0.165 0.60
## Residual 0.9401 0.970
## Number of obs: 6256, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.9394 0.0727 182.8781
## unpleasantActivity_dev 0.3448 0.0432 147.1173
## ethnicityBeijing Chinese -0.2833 0.0669 165.6208
## avg_unpleasantActivity_dev 0.1940 0.0525 163.8693
## unpleasantActivity_dev:aa.NA_i 0.0213 0.0352 133.8892
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.1577 0.0353 162.6620
## t value Pr(>|t|)
## (Intercept) 12.92 < 2e-16 ***
## unpleasantActivity_dev 7.98 3.8e-13 ***
## ethnicityBeijing Chinese -4.24 3.8e-05 ***
## avg_unpleasantActivity_dev 3.70 0.0003 ***
## unpleasantActivity_dev:aa.NA_i 0.60 0.5466
## unpleasantActivity_dev:ethnicityBeijing Chinese -4.47 1.5e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ ethnBC avg_A_ uA_:.N
## unplsntAct_ 0.170
## ethnctyBjnC -0.513 -0.192
## avg_nplsnA_ 0.714 -0.009 0.028
## unplA_:.NA_ 0.013 -0.830 0.000 0.018
## unplsnA_:BC -0.212 -0.666 0.407 0.006 0.343
# use unpleasantness of activity - ethn and ana
aaethn_yesslope <- lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude) # both sig
summary(aaethn_yesslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## desireActivity ~ unpleasantActivity_dev * aa.NA_i + unpleasantActivity_dev *
## ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev |
## subnum)
## Data: data
##
## AIC BIC logLik deviance df.resid
## 17844 17918 -8911 17822 6245
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.795 -0.520 -0.206 0.061 4.119
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subnum (Intercept) 0.1553 0.394
## unpleasantActivity_dev 0.0272 0.165 0.60
## Residual 0.9401 0.970
## Number of obs: 6256, groups: subnum, 166
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.8984 0.1114 176.7392
## unpleasantActivity_dev 0.3361 0.0468 141.5265
## aa.NA_i 0.0396 0.0816 164.2271
## ethnicityBeijing Chinese -0.2702 0.0721 165.6770
## avg_unpleasantActivity_dev 0.1932 0.0524 163.7982
## unpleasantActivity_dev:aa.NA_i 0.0298 0.0393 142.5528
## unpleasantActivity_dev:ethnicityBeijing Chinese -0.1548 0.0357 157.3169
## t value Pr(>|t|)
## (Intercept) 8.06 1.1e-13 ***
## unpleasantActivity_dev 7.19 3.4e-11 ***
## aa.NA_i 0.49 0.62763
## ethnicityBeijing Chinese -3.75 0.00025 ***
## avg_unpleasantActivity_dev 3.68 0.00031 ***
## unpleasantActivity_dev:aa.NA_i 0.76 0.44981
## unpleasantActivity_dev:ethnicityBeijing Chinese -4.33 2.6e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) unplA_ aa.NA_ ethnBC avg_A_ uA_:.N
## unplsntAct_ 0.392
## aa.NA_i -0.758 -0.382
## ethnctyBjnC -0.594 -0.307 0.374
## avg_nplsnA_ 0.488 0.003 -0.030 0.015
## unplA_:.NA_ -0.331 -0.857 0.447 0.167 0.003
## unplsnA_:BC -0.259 -0.669 0.162 0.433 0.001 0.375
r2_values_aaethn <- r.squaredGLMM(aaethn_yesslope)
r2_values_aaethn
## R2m R2c
## [1,] 0.1413 0.2924
anova(yesslope, aaethn_yesslope)
## Data: data
## Models:
## yesslope: paste(yesslopeforula)
## aaethn_yesslope: desireActivity ~ unpleasantActivity_dev * aa.NA_i + unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## yesslope 9 17840 17901 -8911 17822
## aaethn_yesslope 11 17844 17918 -8911 17822 0.6 2 0.74
anova(aa_yesslope, aaethn_yesslope)
## Data: data
## Models:
## aa_yesslope: desireActivity ~ unpleasantActivity_dev * aa.NA_i + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum)
## aaethn_yesslope: desireActivity ~ unpleasantActivity_dev * aa.NA_i + unpleasantActivity_dev * ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## aa_yesslope 9 17862 17922 -8922 17844
## aaethn_yesslope 11 17844 17918 -8911 17822 21.7 2 1.9e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interact_plot(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "aa.NA_i",
modx.values = "plus-minus",
legend.main = "Avoided NA",
centered = "none") +
xlab("Unpleasantness of Current Activity") +
ylab("Desire to Do Something Else") +
theme(legend.position = "bottom")
sim_slopes(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "aa.NA_i")
## JOHNSON-NEYMAN INTERVAL
##
## When aa.NA_i is INSIDE the interval [-2.37, 8.73], the slope of
## unpleasantActivity_dev is p < .05.
##
## Note: The range of observed values of aa.NA_i is [-1.05, 1.39]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when aa.NA_i = 0.3734 (- 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.35 0.03 9.93 0.00
##
## Slope of unpleasantActivity_dev when aa.NA_i = 0.8170 (Mean):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.36 0.03 14.22 0.00
##
## Slope of unpleasantActivity_dev when aa.NA_i = 1.2606 (+ 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.37 0.03 14.43 0.00
interact_plot(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data, REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity",
legend.main = "Culture",
centered = "none",
colors = c("European Americans" = "#F49070", "Beijing Chinese" = "#52B2CF")) +
xlab("Unpleasantness of Current Activity") +
ylab("Desire to Do Something Else") +
theme(legend.position = "bottom") +
ylim(c(-0.5, 3))
sim_slopes(
lmer(desireActivity ~ unpleasantActivity_dev*aa.NA_i + unpleasantActivity_dev*ethnicity + avg_unpleasantActivity_dev + (unpleasantActivity_dev | subnum),
data = data,
REML = FALSE,
na.action = na.exclude),
pred = "unpleasantActivity_dev",
modx = "ethnicity")
## Warning: Johnson-Neyman intervals are not available for factor moderators.
## SIMPLE SLOPES ANALYSIS
##
## Slope of unpleasantActivity_dev when ethnicity = Beijing Chinese:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.21 0.02 8.80 0.00
##
## Slope of unpleasantActivity_dev when ethnicity = European Americans:
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.36 0.03 14.22 0.00
slope1 = -0.1650
se1 = 0.0332
slope2 = -0.1577
se2= 0.0353
z = (slope1 - slope2) / ((se1)^2 + (se2)^2)^0.5
z
## [1] -0.1506