## [1] "US" "CN" "demog"
## Joining, by = "subject_id"
## [1] 122
## [1] 101
## [1] 222
## [1] 221
Loaded demographic data from 256 participants. Loaded coded data from 221 participants.
Age breakdown:
d %>% group_by(subject_id, years, country) %>%
summarise(n=n()) %>%
group_by(years, country) %>%
summarise(n=n())
## `summarise()` has grouped output by 'subject_id', 'years'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'years'. You can override using the
## `.groups` argument.
## # A tibble: 20 × 3
## # Groups: years [10]
## years country n
## <dbl> <chr> <int>
## 1 3 CN 11
## 2 3 US 7
## 3 4 CN 13
## 4 4 US 4
## 5 5 CN 11
## 6 5 US 9
## 7 6 CN 7
## 8 6 US 19
## 9 7 CN 17
## 10 7 US 18
## 11 8 CN 11
## 12 8 US 15
## 13 9 CN 10
## 14 9 US 12
## 15 10 CN 7
## 16 10 US 22
## 17 11 CN 8
## 18 11 US 5
## 19 12 CN 5
## 20 12 US 10
#quick counts
youngUS <- d %>% filter(years<7,country=="US") %>% distinct(subject_id) # 39
midUS <- d %>% filter(years>=7 & years<10,country=="US") %>% distinct(subject_id) # 45 (was 43)
oldUS <- d %>% filter(years>=10,country=="US") %>% distinct(subject_id) # 37
youngCN <- d %>% filter(years<7,country=="CN") %>% distinct(subject_id) # 41 (was 42)
midCN <- d %>% filter(years>=7 & years<10,country=="CN") %>% distinct(subject_id) # 38
oldCN <- d %>% filter(years>=10,country=="CN") %>% distinct(subject_id) # 20
#US ppt lists
youngUS <- d %>% filter(years<7,country=="US")
youngUS = unique(youngUS$subject_id)
midUS <- d %>% filter(years>=7 & years<10,country=="US")
midUS = unique(midUS$subject_id)
oldUS <- d %>% filter(years>=10,country=="US")
oldUS = unique(oldUS$subject_id)
#CN ppt lists
youngCN <- d %>% filter(years<7,country=="CN")
youngCN = unique(youngCN$subject_id)
midCN <- d %>% filter(years>=7 & years<10,country=="CN")
midCN = unique(midCN$subject_id)
oldCN <- d %>% filter(years>=10,country=="CN")
oldCN = unique(oldCN$subject_id)
subjectExcludes <- read_csv("data/01_processed_data/exclusion_table_linked.csv") %>%
filter(!is.na(id))
## New names:
## Rows: 95 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): subject, ex_reason, id, ...4
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...4`
#make sideBias list for RMTS exclusions
sideBias <- subjectExcludes %>% filter(ex_reason=="side_bias")
#how many language exclusions from CN sample?
langCN <- subjectExcludes %>% filter(ex_reason=="language" & startsWith(id, "M"))
#how many ppts in CN sample?
totalCN <- d %>% filter(country=="CN")
CNppts = unique(totalCN$subject_id)
#if more than 20% of total CN sample would be excluded for language, drop CN lang exclusions (otherwise retain)
if(nrow(langCN) / length(CNppts) > .2) {
idx = with(subjectExcludes, which(ex_reason=="language" & startsWith(id, "M")))
subjectExcludes = subjectExcludes[-idx,]
}
#remove the side bias exclusion rows so subjectExcludes contains only ppts who should be FULLY excluded for demog reasons
subjectExcludes <- subjectExcludes %>% filter(ex_reason!="side_bias")
length(unique(d$subject_id)) #221
## [1] 221
d <- d %>% filter(!is.element(subject_id, subjectExcludes$id))
length(unique(d$subject_id)) #205
## [1] 205
#make language category that distinguishes between CN ppts who are/are not bilingual in English
d <- d %>% mutate(language=ifelse(is.element(subject_id, langCN$id), "CN_ENG", country))
d %>% group_by(subject_id, language) %>%
summarise(n=n()) %>%
group_by(language) %>%
summarise(n=n())
## `summarise()` has grouped output by 'subject_id'. You can override using the
## `.groups` argument.
## # A tibble: 3 × 2
## language n
## <chr> <int>
## 1 CN 53
## 2 CN_ENG 43
## 3 US 109
d_rmts <- d %>% filter(task_type=="RMTS")
#clean up resp coding
d_rmts[which(d_rmts$resp=="relational"),]$resp = "relation"
d_rmts[which(d_rmts$resp=="obejct"),]$resp = "object"
d_rmts[which(d_rmts$resp=="n/a"),]$resp = NA
d_rmts[which(d_rmts$resp=="NA"),]$resp = NA
#check resp cleaning
unique(d_rmts$resp)
## [1] "relation" "object" NA
d_rmts <- d_rmts %>%
mutate(object_score = ifelse(resp=="object", 1,
ifelse(resp=="relation", 0, NA)),
across(c(subject_id, country), as.factor),
trial_number = as.numeric(trial_number)) %>%
mutate(age_sc = scale(age))
#PREREG Ambiguous RMTS (logistic regression): choice ~ culture * age + (trial_num | subject).
m_rmts <- glmer(object_score ~ country * age_sc + (trial_number | subject_id),
data = d_rmts,
family = "binomial") #does not converge
m_rmts2 <- glmer(object_score ~ country * age_sc + (1 | subject_id),
data = d_rmts,
family = "binomial") #only intercept
summary(m_rmts2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: object_score ~ country * age_sc + (1 | subject_id)
## Data: d_rmts
##
## AIC BIC logLik deviance df.resid
## 874.4 898.9 -432.2 864.4 985
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.6444 -0.1665 -0.1325 0.2525 1.8072
##
## Random effects:
## Groups Name Variance Std.Dev.
## subject_id (Intercept) 16.98 4.121
## Number of obs: 990, groups: subject_id, 205
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.87222 0.58574 -3.196 0.00139 **
## countryUS 0.04786 0.72732 0.066 0.94753
## age_sc 0.13332 0.47660 0.280 0.77968
## countryUS:age_sc 0.30904 0.69569 0.444 0.65689
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cntrUS age_sc
## countryUS -0.665
## age_sc 0.203 -0.163
## cntryUS:g_s -0.154 0.103 -0.685
#Because of concerns that children may (exploratorily) change their response strategy on later trials (2-4), we will also analyze first trial responding separately (logistic regression: choice ~ culture * age). If this first trials analysis produces results that differ significantly from our regression with all trials, we will rely on the first trial results for interpretation.
m_rmts_first <- glm(object_score ~ country * age_sc,
data = d_rmts %>% filter(trial_number == 1),
family = "binomial") #only intercept
summary(m_rmts_first)
##
## Call:
## glm(formula = object_score ~ country * age_sc, family = "binomial",
## data = d_rmts %>% filter(trial_number == 1))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.1269 -0.9061 -0.8374 1.3692 1.6942
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.8029 0.2062 -3.894 9.86e-05 ***
## countryUS 0.1646 0.2758 0.597 0.551
## age_sc -0.1175 0.1938 -0.606 0.544
## countryUS:age_sc 0.4016 0.2743 1.464 0.143
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 316.17 on 247 degrees of freedom
## Residual deviance: 313.17 on 244 degrees of freedom
## AIC: 321.17
##
## Number of Fisher Scoring iterations: 4
#is there a curvilinear relationship bw age and performance?
m_rmts_first_curve <- glm(object_score ~ country * poly(age_sc, 2),
data = d_rmts %>% filter(trial_number == 1),
family = "binomial") #only intercept
summary(m_rmts_first_curve)
##
## Call:
## glm(formula = object_score ~ country * poly(age_sc, 2), family = "binomial",
## data = d_rmts %>% filter(trial_number == 1))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.5769 -0.8544 -0.7764 1.3265 1.6638
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.8336 0.2101 -3.969 7.23e-05 ***
## countryUS 0.2318 0.2811 0.825 0.410
## poly(age_sc, 2)1 -1.2847 2.9933 -0.429 0.668
## poly(age_sc, 2)2 3.5157 3.1455 1.118 0.264
## countryUS:poly(age_sc, 2)1 4.4340 4.2458 1.044 0.296
## countryUS:poly(age_sc, 2)2 4.0346 4.3470 0.928 0.353
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 316.17 on 247 degrees of freedom
## Residual deviance: 305.42 on 242 degrees of freedom
## AIC: 317.42
##
## Number of Fisher Scoring iterations: 4
d_rmts %>% filter(!is.na(object_score)) %>%
group_by(subject_id, country, age) %>%
summarise(mean = mean(object_score)) %>%
ggplot(aes(x=jitter(age,.1), y=mean, group=country, color=country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `summarise()` has grouped output by 'subject_id', 'country'. You can override
## using the `.groups` argument.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
d_rmts %>% filter(!is.na(object_score)) %>%
group_by(subject_id, language, age) %>%
summarise(mean = mean(object_score)) %>%
ggplot(aes(x=jitter(age,.1), y=mean, group=language, color=language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `summarise()` has grouped output by 'subject_id', 'language'. You can override
## using the `.groups` argument.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
d_rmts1 <- d_rmts %>% filter(trial_number==1)
d_rmts1 %>% filter(!is.na(object_score)) %>%
group_by(subject_id, country, age) %>%
ggplot(aes(x=age, y=jitter(object_score,.1), group=country, color=country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#language plot
d_rmts1 %>% filter(!is.na(object_score)) %>%
group_by(subject_id, language, age) %>%
ggplot(aes(x=age, y=jitter(object_score,.1), group=language, color=language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#mean perf looks similar across countries, but first response seems to show an object bias in the youngest US ppts
d_fd <- d %>% filter(task_type=="FD")
d_fd[which(d_fd$resp=="NA"),]$resp = NA
d_fd[which(d_fd$resp=="N/A"),]$resp = NA
d_fd[which(d_fd$resp=="n/a"),]$resp = NA
d_fd[which(d_fd$resp=="Focal"),]$resp = "focal"
#check resp cleaning
unique(d_fd$resp)
## [1] "focal" "background" NA
d_fd <- d_fd %>%
mutate(focal_score = ifelse(resp=="focal", 1,
ifelse(resp=="background", 0, NA))) %>%
mutate(age_sc = scale(age))
#PREREG: (a, logistic regression) first_mention ~ culture * age + (1 | subject) + (culture | scene)
#(b, Poisson regression) description_num ~ description_type * culture * age + (description_type | subject) + (culture | scene)
m_fd1 <- glmer(focal_score ~ country * age_sc + (1 | subject_id) + (country | trial_number),
data = d_fd,
family = "binomial") #is singular
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.0216773 (tol = 0.002, component 1)
m_fd2 <- glmer(focal_score ~ country * age_sc + (1 | subject_id) + (1 | trial_number),
data = d_fd,
family = "binomial") #only intercept sig
summary(m_fd2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: focal_score ~ country * age_sc + (1 | subject_id) + (1 | trial_number)
## Data: d_fd
##
## AIC BIC logLik deviance df.resid
## 1256.9 1289.4 -622.4 1244.9 1674
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2519 0.1782 0.2305 0.3753 1.5987
##
## Random effects:
## Groups Name Variance Std.Dev.
## subject_id (Intercept) 2.1014 1.4496
## trial_number (Intercept) 0.1058 0.3253
## Number of obs: 1680, groups: subject_id, 204; trial_number, 17
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.286678 0.244199 9.364 <2e-16 ***
## countryUS 0.427373 0.283840 1.506 0.132
## age_sc -0.006816 0.195011 -0.035 0.972
## countryUS:age_sc -0.175638 0.286031 -0.614 0.539
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cntrUS age_sc
## countryUS -0.528
## age_sc 0.092 -0.081
## cntryUS:g_s -0.079 -0.036 -0.681
d_fd %>% filter(!is.na(focal_score)) %>%
group_by(subject_id, country, age) %>%
summarise(mean_focal = mean(focal_score)) %>%
ggplot(aes(x=age, y=mean_focal, group=country, color=country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `summarise()` has grouped output by 'subject_id', 'country'. You can override
## using the `.groups` argument.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
d_fd %>% filter(!is.na(focal_score)) %>%
group_by(subject_id, language, age) %>%
summarise(mean_focal = mean(focal_score)) %>%
ggplot(aes(x=age, y=mean_focal, group=language, color=language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `summarise()` has grouped output by 'subject_id', 'language'. You can override
## using the `.groups` argument.
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
d_ca <- d %>% filter(task_type=="CA")
d_ca[which(d_ca$resp=="0"),]$resp = "scared"
d_ca[which(d_ca$resp=="personal"),]$resp = "person"
d_ca[which(d_ca$resp=="NA"),]$resp = NA
d_ca[which(d_ca$resp=="n/a"),]$resp = NA
#check resp cleaning
unique(d_ca$resp)
## [1] "scared, situation"
## [2] "person"
## [3] "scared"
## [4] "situation"
## [5] NA
## [6] "situation, person"
## [7] "person, situation"
## [8] "scared,person"
## [9] "scared,situation"
## [10] "scared, person"
## [11] "person, scared"
## [12] "situation, situation"
## [13] "person, situation, situation, situation"
## [14] "person, situation, person"
## [15] "situation, scared"
## [16] "person, person, person, situation, person"
## [17] "situation, person, situation"
## [18] "situation,situation"
## [19] "person,situation"
## [20] "person,person,situation,situation"
## [21] "person,situation,situation"
## [22] "person,person,situation,person,situation"
## [23] "person,person,situation"
## [24] "situation,person"
## [25] "person,person"
## [26] "situation,situation,person"
## [27] "person,situation,situation,situation,situation,situation,situation"
## [28] "situation,situation,situation,situation,situation"
## [29] "situation,person,situation"
## [30] "situation,situation,situation"
d_ca <- d_ca %>% # filter(!is.na(resp)) %>%
mutate(n_person = str_count(d_ca$resp, "person"),
n_situation = str_count(d_ca$resp, "situation"),
n_scared = str_count(d_ca$resp, "scared")) %>%
mutate(person_focus = n_person - n_situation,
person_scared = n_person + n_scared - n_situation) %>%
mutate(age_sc = scale(age))
d_ca$trial_number = as.numeric(d_ca$trial_number)
#PREREG (Poisson regression): situation_attrib_num ~ culture * age + (1 | subject) + (culture | trial)
m_ca <- glmer(n_situation ~ country * age_sc + (1 | subject_id) + (country | trial_number),
data = d_ca,
family = "poisson") #singular fit
## boundary (singular) fit: see help('isSingular')
m_ca2 <- glmer(n_situation ~ country * age_sc + (1 | subject_id) + (1 | trial_number),
data = d_ca,
family = "poisson") #singular fit
## boundary (singular) fit: see help('isSingular')
m_ca3 <- glmer(n_situation ~ country * age_sc + (1 | subject_id),
data = d_ca,
family = "poisson") #intercept, trending effect of country 0.0637
summary(m_ca3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: poisson ( log )
## Formula: n_situation ~ country * age_sc + (1 | subject_id)
## Data: d_ca
##
## AIC BIC logLik deviance df.resid
## 943.2 964.0 -466.6 933.2 476
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.8573 -0.6603 0.2293 0.4321 3.3808
##
## Random effects:
## Groups Name Variance Std.Dev.
## subject_id (Intercept) 0.1965 0.4433
## Number of obs: 481, groups: subject_id, 201
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.40547 0.10299 -3.937 8.25e-05 ***
## countryUS -0.26793 0.13345 -2.008 0.0447 *
## age_sc 0.08173 0.09199 0.888 0.3743
## countryUS:age_sc -0.06577 0.13409 -0.490 0.6238
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cntrUS age_sc
## countryUS -0.655
## age_sc -0.009 -0.001
## cntryUS:g_s 0.006 -0.056 -0.686
p1 <- d_ca %>% ggplot(aes(x = age, y = jitter(person_focus), group = country, color = country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
p2 <- d_ca %>% ggplot(aes(x = age, y = jitter(person_scared), group = country, color = country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
ggarrange(p1, p2, common.legend = T)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 17 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Removed 17 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Removed 17 rows containing missing values (`geom_point()`).
pl1 <- d_ca %>% ggplot(aes(x = age, y = jitter(person_focus), group = language, color = language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
pl2 <- d_ca %>% ggplot(aes(x = age, y = jitter(person_scared), group = language, color = language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
ggarrange(pl1, pl2, common.legend = T)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Removed 17 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Removed 17 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 17 rows containing non-finite values (`stat_smooth()`).
## Removed 17 rows containing missing values (`geom_point()`).
d_up <- d %>% filter(task_type=="UP")
d_up[which(d_up$resp=="non_unique"),]$resp = "non-unique"
d_up[which(d_up$resp=="n/a"),]$resp = NA
d_up[which(d_up$resp=="NA"),]$resp = NA
#check resp cleaning
unique(d_up$resp)
## [1] "unique" "non-unique" NA
d_up <- d_up %>%
mutate(unique = ifelse(resp=="unique", 1,
ifelse(resp=="non-unique", 0, NA))) %>%
mutate(age_sc = scale(age))
#PREREG (logistic regression): choice ~ culture * age
m_up <- glm(unique ~ country * age_sc,
data = d_up,
family = "binomial") #sig effects of country and country*age (but in opposite direction, seems likely to be pragmatic helpfulness on the part of CN ppts--interesting result, but not the task we'd intended to run!)
summary(m_up)
##
## Call:
## glm(formula = unique ~ country * age_sc, family = "binomial",
## data = d_up)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1428 -1.1832 0.6010 0.8912 1.2901
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.6456 0.2664 6.178 6.47e-10 ***
## countryUS -1.2067 0.3221 -3.746 0.00018 ***
## age_sc 0.3343 0.2475 1.350 0.17691
## countryUS:age_sc -0.7057 0.3136 -2.250 0.02446 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 298.47 on 244 degrees of freedom
## Residual deviance: 276.58 on 241 degrees of freedom
## (4 observations deleted due to missingness)
## AIC: 284.58
##
## Number of Fisher Scoring iterations: 4
d_up %>% filter(!is.na(unique)) %>%
group_by(subject_id, country, age) %>%
ggplot(aes(x=age, y=jitter(unique,.2), group=country, color=country)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
d_up %>% filter(!is.na(unique)) %>%
group_by(subject_id, language, age) %>%
ggplot(aes(x=age, y=jitter(unique,.2), group=language, color=language)) +
geom_point(alpha=.5) + geom_smooth() + theme_classic()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'