## [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 M 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] 162
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
#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
#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
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_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'
#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.00642657 (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
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_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,person,situation,person,situation"
## [20] "person,person,situation"
## [21] "person,person"
## [22] "person,situation,situation,situation,situation,situation,situation"
## [23] "person,situation,situation"
## [24] "situation,situation,situation,situation,situation"
## [25] "situation,person"
## [26] "person,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
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00292711 (tol = 0.002, component 1)
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, effect of country
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 14 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 14 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 14 rows containing non-finite values (`stat_smooth()`).
## Removed 14 rows containing missing values (`geom_point()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 14 rows containing non-finite values (`stat_smooth()`).
## Removed 14 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!)
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'