a=0
design_expt1_csv_ed <- dir(path = "./DataBoth/",pattern='*.csv$', recursive = T,full.names = T)
des_expt1 <- read_TD_data(design_expt1_csv_ed,"DesignSt Expt1")
total_n <- length(unique(des_expt1$subject_id))
adult_names = c("Jzin4", "vQ9kd", "EacbK", "GRXZC", "TT7vD", "Ji6i8", "UEkPP", "FFV4A",
"cC7P3", "NMV7V", "hHuPe", "gbig8", "IXYa2", "gpUCL", "AvFRg", "45vel",
"9XL8e","53Jrb","D4DH5","h9prq","jvNSr","lYpAu","tLgrH","wjb8H",
"adgFQ","EpGTI","3cn6G","ic8aW","BmxJP","GpeNt","nbuPP","ZASe7",
"WdCBA","nvaIy","Qaa7h","fCfxr","NByx8","kD1Ga","3eHoH","5zPfp",
"SeCGm","EypNI","rcUSO","BzKid","6pdGr","Tez42","ukfz7","YxpCP",
"8dcrB","zJTaT","1gEsD","e9eGy","ymHuR","027Ke","QSW4M","AYYlf",
"QiOqC","8HFxj","6m0Fo","joshM",
"szBqs","mVEWU","yMuLA","LXr8B","gXvqG","zbwht","dg4Et","CcLBL",
"IBuM1","7MJhs","Gih6v","JFX36","sVNMn","6z8cg","o3PpO","mwJHr",
"DyREn","wW91e","A27X6","u2URN","kpJHP","0zu8T","31soU","1SUQH",
"QoIqI","QwXgL","eQQNS","bXTSI","tHStk","LdnD0","Hp72M","iCdH6",
"oW2tT","iWtjn","Fj0kh","Jzin4","VQ9kd","EacbK","29AmA","GRXZC",
"TT7vD","Ji6i8","2p8MJ","y61xN","cC7P3","NMV7V","hHuPe","v9Xa5",
"l4x2M","gbig8","IXYa2","gpUCL","wFfMn","UEkPP","tLgrH","jvNSr",
"fWVGz","KmSdy","FFV4A","IYpAu","h9prq","KRCL4","AvFRg","9XL8e",
"D4DH5","bMpOb","45vel","53Jrb","wjb8H","rAfUQ","Mn3sK","BzKid",
"6pdGr","Tez42","Kh4iJ","oK2A9","3cn6G","kD1Ga","3eHoH","Lc3Gs",
"SeCGm","ukfz7","YxpCP","STr6P","ic8aW","5zPfp","EypNI","wjyLD",
"Odzh7","BmxJP","nvaly","Qaa7h","4tsOw","adgFQ","EpGTI","ZASe7",
"bVyUg","2DPvU","nbuPP","NByx8","rcUSO","dPQPw","VnlKz","GpeNt",
"WdCBA","fCfxr","6xabB","8dcrB","e9eGy","QSW4M","8HFxj","zJTaT",
"ymHuR","AYYlf","6m0Fo","1gEsD","027Kw","QiOqC","joshM","qomFR",
"dW5EX","DK2rv","aSCIO","Xg2rm","7BIeX","szBqs","LXr8B","dg4Et",
"7MJhs","mVEWU","gXvqG","CcLBL","Gih6v","yMuLA","zbwht","IBuM1",
"JFX36","XJ8p7","M585l","8YaRm","sVNMn","ci6Ek","bxdbA","wQ6Nb",
"ci6Ek","Zjfhe","RKPwE","DRKZ5","rA2ld","TMU9i","kiyC1","9fzQp",
"WXnfW","WQWgx","7bVIW","D8ufy","eV8aL","p9V9G","iNXHp")
#"7AAKi","MkAlx","yIIAB")
# Note that before Feb 7, all participants tested in ME_Conventional were
# Actually in ME_Idio. That list is:
# Edinburgh Child:
# PKcJO
#
# Berk Adults:
# adgFQ
# EpGTI
#
# Berk Kids:
# zRiaH
# XPFnX
# 7AAKi
# yIIAB
# Edinburgh excluded participants
ed_excluded_ptpts = c("mNiKL","xa5MU","aLqsz","yoliT")
des_expt1 = des_expt1[!des_expt1$subject_id %in% ed_excluded_ptpts,]
wrong_cond_names = c("PKcJO","adgFQ","EpGTI","zRiaH","XPFnX","7AAKi","yIIAB")
des_expt1[des_expt1$subject_id %in% wrong_cond_names,]$prevalence = "ME_idiosyncratic"
# Wrong gender
des_expt1[des_expt1$subject_id %in% c("DzgE5"),]$gender = "female"
# Describe participants
part_expt1 <- des_expt1 %>%
dplyr::mutate(Age_Group = ifelse(subject_id %in% adult_names, "Adult","Child")) %>%
dplyr::select(subject_id,trial_type,accuracy,Age_Group) %>%
dplyr::group_by(subject_id,trial_type,Age_Group) %>%
dplyr::summarise(n = n(), mean_acc = mean(accuracy))
part_expt1[part_expt1$trial_type == "critical",]$mean_acc <- 1
part_expt1 <- part_expt1 %>%
dplyr::group_by(subject_id,Age_Group) %>%
dplyr::summarise(mean_acc = mean(mean_acc), n = sum(n)) #%>%
#dplyr::filter( !n<8,!mean_acc <1)
# Exclude participants
des_expt1 <- inner_join(des_expt1,part_expt1,by="subject_id") #%>%
# dplyr::filter((age %in% c("4","4.5")|Age_Group == "Adult"))
excluded_n <- total_n - length(unique(des_expt1$subject_id))
des_expt1$ChooseLeft <- ifelse(des_expt1$side_chosen == "left",1,0)
des_expt1$Label = as.factor(ifelse(des_expt1$prevalence %in% c("conventional","idiosyncratic"), "WE",
ifelse(des_expt1$prevalence %in% c("ME_conventional","ME_idiosyncratic"),"ME","-")))
des_expt1$Task = as.factor(ifelse(des_expt1$prevalence %in% c("conventional","idiosyncratic",
"ME_conventional","ME_idiosyncratic"),
"Label",
"Function"))
des_expt1$Prev = ifelse(des_expt1$prevalence %in% c("conventional","ME_conventional"),
"conventional",
ifelse(des_expt1$prevalence =="function",
"conventional",
"idiosyncratic"))
des_expt1[des_expt1$poly_order %in% c("first"),]$Prev = "first"
des_expt1[des_expt1$poly_order %in% c("second"),]$Prev = "second"
des_expt1$Prev = as.factor(des_expt1$Prev)
des_expt1$Age_Group = as.factor(des_expt1$Age_Group)
contrasts(des_expt1$Label)[1] = -1
contrasts(des_expt1$Prev)[1] = 0
contrasts(des_expt1$Age_Group)[1] = 0
contrasts(des_expt1$Task)[1] = 0
# Process train trial 2 on function experiment to reverse code it.
des_expt1[des_expt1$trial_id == "train2" & des_expt1$Task == "Function",]$accuracy = ifelse(
des_expt1[des_expt1$trial_id == "train2" & des_expt1$Task == "Function",]$accuracy == 1,0,
1
)
kable(des_expt1 %>%
group_by(subject_id,Age_Group,Task,Label,Prev) %>%
dplyr::summarise(acc = mean(accuracy)) %>%
dplyr::select(subject_id,Age_Group,Task,Label,Prev,acc) %>%
group_by(Age_Group,Task,Label,Prev) %>%
dplyr::summarise(n = length(acc)),
caption = "Number of participants per condition")
Analysis
- For Critical trials of all studies, we plot whether children are more likely to choose the original function.
- For Training trials of labeling studies, we plot if they correctly chose the named function.
- For Training trials of function studies, we plot if they correctly chose the original function.
a=0
des_expt1_summary <- des_expt1 %>%
dplyr::group_by(trial_type,list,Task,Prev,prevalence,Label,subject_id,Age_Group) %>%
dplyr::select(rt,accuracy,ChooseLeft,trial_type,list,prevalence,Task,Prev,Label,subject_id,Age_Group) %>%
dplyr::summarise(ChooseLeft.m = mean(ChooseLeft), acc.m = mean(accuracy,na.rm = T),rt.m = mean(rt,na.rm = T))
des_expt1_summary_graph_NoPrev <- des_expt1_summary%>%
dplyr::group_by(trial_type,Label,Age_Group,Task) %>%
dplyr::select(ChooseLeft.m,acc.m,rt.m,trial_type,Label,Task,subject_id,Age_Group) %>%
dplyr::summarise(ChooseLeft.mean = mean(ChooseLeft.m),
acc.mean = mean(acc.m,na.rm = T),
acc.sd = sd(acc.m,na.rm=T),
rt.mean = mean(rt.m, na.rm = T),
rt.sd = sd(rt.m,na.rm = T),
acc.low = ci.low(acc.m),
acc.high = ci.high(acc.m),
rt.low = ci.low(rt.m),
rt.high = ci.high(rt.m))
des_expt1_summary_graph <- des_expt1_summary%>%
dplyr::group_by(trial_type,prevalence,Age_Group,Label,Task,Prev) %>%
dplyr::select(ChooseLeft.m,acc.m,rt.m,trial_type,prevalence,Task,Label,Prev,subject_id,Age_Group) %>%
dplyr::summarise(ChooseLeft.mean = mean(ChooseLeft.m),
acc.mean = mean(acc.m,na.rm = T),
acc.sd = sd(acc.m,na.rm=T),
rt.mean = mean(rt.m, na.rm = T),
rt.sd = sd(rt.m,na.rm = T),
acc.low = ci.low(acc.m),
acc.high = ci.high(acc.m),
rt.low = ci.low(rt.m),
rt.high = ci.high(rt.m))
des_expt1_summary_graph_list <- des_expt1_summary%>%
dplyr::group_by(trial_type,list,prevalence,Age_Group,Task,Prev,Label) %>%
dplyr::select(acc.m,rt.m,trial_type,list,prevalence,Task,Prev,Label,subject_id,Age_Group) %>%
dplyr::summarise(acc.mean = mean(acc.m,na.rm = T),
acc.sd = sd(acc.m,na.rm=T),
rt.mean = mean(rt.m, na.rm = T),
rt.sd = sd(rt.m,na.rm = T),
acc.low = ci.low(acc.m),
acc.high = ci.high(acc.m),
rt.low = ci.low(rt.m),
rt.high = ci.high(rt.m))
dodge <- position_dodge(width=0.9)
labeling = ggplot(subset(des_expt1_summary_graph, Task == "Label"), aes(Label,acc.mean, fill = Prev)) +
geom_bar(stat = "identity", position = dodge) +
facet_wrap(Age_Group~trial_type)+
geom_errorbar(data = subset(des_expt1_summary_graph, Task == "Label"), aes(ymax = acc.high, ymin = acc.low), width=0.25, position = dodge) +
labs(fill = "Prevalence") +
theme(axis.text.x = element_text(colour = "black", size = 12)) +
ylab("Proportion of extensions to original function") +
xlab("") +
ylim(c(0,1)) +
geom_hline(yintercept = 0.5, size =1, linetype = 2)
function_prev = ggplot(subset(des_expt1_summary_graph, Task == "Function" & Prev
%in% c("conventional","idiosyncratic")),
aes(Prev,acc.mean, fill = Prev)) +
geom_bar(stat = "identity", position = dodge) +
facet_wrap(Age_Group~trial_type)+
geom_errorbar(data = subset(des_expt1_summary_graph, Task == "Function" & Prev
%in% c("conventional","idiosyncratic")), aes(ymax = acc.high, ymin = acc.low), width=0.25, position = dodge) +
labs(fill = "Prevalence") +
theme(axis.text.x = element_text(colour = "black", size = 12)) +
ylab("Proportion of extensions to original function") +
xlab("") +
ylim(c(0,1)) +
geom_hline(yintercept = 0.5, size =1, linetype = 2)
function_label = ggplot(subset(des_expt1_summary_graph, Task == "Function" & !Prev
%in% c("conventional","idiosyncratic")),
aes(Prev,acc.mean, fill = Prev)) +
geom_bar(stat = "identity", position = dodge) +
facet_wrap(Age_Group~trial_type)+
geom_errorbar(data = subset(des_expt1_summary_graph, Task == "Function" & !Prev
%in% c("conventional","idiosyncratic")), aes(ymax = acc.high, ymin = acc.low), width=0.25, position = dodge) +
labs(fill = "Prevalence") +
theme(axis.text.x = element_text(colour = "black", size = 12)) +
ylab("Proportion of extensions to original function") +
xlab("") +
ylim(c(0,1)) +
geom_hline(yintercept = 0.5, size =1, linetype = 2)
Labeling study
labeling_model = brm(accuracy ~ Prev*Label*Age_Group + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Task == "Label" & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
labeling_children = brm(accuracy ~ Prev*Label + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Label" & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
labeling_children_WE = brm(accuracy ~ Prev + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Label == "WE" & Age_Group == "Child" & Task == "Label" & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
labeling_children_ME = brm(accuracy ~ Prev + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Label == "ME" & Age_Group == "Child" & Task == "Label" & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))

kable(convert_stan_to_dataframe(labeling_model),
caption = "Labeling logistic regression")
Labeling logistic regression
| Intercept |
-1.0849866 |
0.3310658 |
-1.7514482 |
-0.4665858 |
1337.529 |
1.003394 |
* |
| Previdiosyncratic |
-1.3362685 |
0.4808109 |
-2.3055034 |
-0.4443511 |
1494.935 |
1.001924 |
* |
| LabelWE |
2.7678612 |
0.4468512 |
1.9354536 |
3.6806839 |
1324.080 |
1.002244 |
* |
| Age_GroupChild |
0.8966512 |
0.3372263 |
0.2523800 |
1.5635471 |
1552.101 |
1.000889 |
* |
| Previdiosyncratic:LabelWE |
4.3398513 |
0.9811238 |
2.5446110 |
6.3892744 |
1470.642 |
1.004073 |
* |
| Previdiosyncratic:Age_GroupChild |
1.3920055 |
0.5276435 |
0.4085851 |
2.4829471 |
1486.001 |
1.001447 |
* |
| LabelWE:Age_GroupChild |
-2.1183407 |
0.4990415 |
-3.1112807 |
-1.1384267 |
1386.736 |
1.001908 |
* |
| Previdiosyncratic:LabelWE:Age_GroupChild |
-4.3756917 |
1.0226094 |
-6.4916968 |
-2.4792923 |
1401.764 |
1.004056 |
* |
kable(convert_stan_to_dataframe(labeling_children),
caption = "Labeling logistic regression for children")
Labeling logistic regression for children
| Intercept |
-0.1909612 |
0.1707636 |
-0.5258022 |
0.1333332 |
2075.865 |
1.000881 |
- |
| Previdiosyncratic |
0.0969991 |
0.2131310 |
-0.3165154 |
0.5061316 |
2898.847 |
1.001646 |
- |
| LabelWE |
0.6327583 |
0.2111274 |
0.2174868 |
1.0338828 |
2880.675 |
1.000376 |
* |
| Previdiosyncratic:LabelWE |
-0.1129170 |
0.3079817 |
-0.7013668 |
0.5173954 |
2510.185 |
1.001281 |
- |
kable(convert_stan_to_dataframe(labeling_children_WE),
caption = "Labeling logistic regression for child WE")
Labeling logistic regression for child WE
| Intercept |
0.4598106 |
0.2040438 |
0.0625166 |
0.8771937 |
2592.064 |
1.000557 |
* |
| Previdiosyncratic |
-0.0286317 |
0.2484386 |
-0.5223661 |
0.4716816 |
4000.000 |
1.000080 |
- |
kable(convert_stan_to_dataframe(labeling_children_ME),
caption = "Labeling logistic regression for child ME")
Labeling logistic regression for child ME
| Intercept |
-0.1789382 |
0.2361430 |
-0.5850651 |
0.2864920 |
190.0637 |
1.025671 |
- |
| Previdiosyncratic |
0.0983333 |
0.2112191 |
-0.3116458 |
0.5241802 |
4000.0000 |
1.005602 |
- |
There is a significant 3 way interaction between age, label type (WE/ME), and prevalence. Prevalence and label type interact for adults, but only label type has an effect for children.
Function – prevalence
func_prev_model = brm(accuracy ~ Prev*Age_Group + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Task == "Function" & Prev
%in% c("conventional","idiosyncratic") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
func_prev_children = brm(accuracy ~ Prev + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("conventional","idiosyncratic") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
func_prev_children_Conventional = brm(accuracy ~ 1 + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("conventional") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd)))
func_prev_children_Idio = brm(accuracy ~ 1 + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("idiosyncratic") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd)))

kable(convert_stan_to_dataframe(func_prev_model),
caption = "Function Prevalence logistic regression")
Function Prevalence logistic regression
| Intercept |
1.2353004 |
0.6264140 |
0.0250229 |
2.5184712 |
2230.567 |
1.002531 |
* |
| Previdiosyncratic |
2.5045801 |
0.9150294 |
0.7809096 |
4.3740957 |
2364.229 |
1.001029 |
* |
| Age_GroupChild |
-1.1934891 |
0.6684770 |
-2.5422028 |
0.0872245 |
2248.008 |
1.004081 |
- |
| Previdiosyncratic:Age_GroupChild |
0.5816451 |
1.0293229 |
-1.4697554 |
2.6086211 |
2528.762 |
1.001420 |
- |
kable(convert_stan_to_dataframe(func_prev_children),
caption = "Function Prevalence logistic regression for children")
Function Prevalence logistic regression for children
| Intercept |
0.0387044 |
0.3681217 |
-0.7028225 |
0.740034 |
1268.346 |
1.001893 |
- |
| Previdiosyncratic |
2.8862707 |
0.5864400 |
1.8210975 |
4.130597 |
1458.678 |
1.000917 |
* |
kable(convert_stan_to_dataframe(func_prev_children_Conventional),
caption = "Function Prevalence logistic regression for child Conventional function")
Function Prevalence logistic regression for child Conventional function
| Intercept |
-0.0045274 |
0.4365333 |
-0.8775804 |
0.8535145 |
934.1662 |
1.003941 |
- |
kable(convert_stan_to_dataframe(func_prev_children_Idio),
caption = "Function Prevalence logistic regression for child Idio function")
Function Prevalence logistic regression for child Idio function
| Intercept |
3.010357 |
0.8248917 |
1.589812 |
4.849324 |
1120.819 |
1.003421 |
* |
Prevalence affects function judgments for both children and adults.
Function – label first or second
func_label_model = brm(accuracy ~ Prev*Age_Group + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Task == "Function" & Prev
%in% c("first","second") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
func_label_children = brm(accuracy ~ Prev + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("first","second") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd),
prior(normal(0, 2.5), class = b)))
func_label_children_first = brm(accuracy ~ 1 + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("first") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd)))
func_label_children_second = brm(accuracy ~ 1 + (1|subject_id)+(1|trial_id),
data = subset(des_expt1, Age_Group == "Child" & Task == "Function" & Prev
%in% c("second") & trial_type == "critical"),
family = "bernoulli", refresh = 0,
prior= c(prior(normal(0, 2.5), class = sd)))

kable(convert_stan_to_dataframe(func_label_model),
caption = "Function Label logistic regression")
Function Label logistic regression
| Intercept |
2.2394556 |
0.6618053 |
0.9665637 |
3.5737913 |
1992.327 |
1.002336 |
* |
| Prevsecond |
-0.2304119 |
0.8856856 |
-1.9569408 |
1.5667046 |
2156.848 |
1.001031 |
- |
| Age_GroupChild |
-1.6161402 |
0.7419416 |
-3.1072027 |
-0.1619075 |
1928.534 |
1.001846 |
* |
| Prevsecond:Age_GroupChild |
-0.3776143 |
1.0304924 |
-2.4847854 |
1.6389768 |
1913.877 |
1.001201 |
- |
kable(convert_stan_to_dataframe(func_label_children),
caption = "Function Label logistic regression for children")
Function Label logistic regression for children
| Intercept |
0.4880208 |
0.4209073 |
-0.2813237 |
1.2419417 |
175.3606 |
1.025150 |
- |
| Prevsecond |
-0.4797266 |
0.4676262 |
-1.3812218 |
0.5268622 |
563.1732 |
1.006677 |
- |
kable(convert_stan_to_dataframe(func_label_children_first),
caption = "Function Label logistic regression for child label first")
Function Label logistic regression for child label first
| Intercept |
0.5471596 |
0.4285902 |
-0.2668054 |
1.403815 |
1151.176 |
1.000546 |
- |
kable(convert_stan_to_dataframe(func_label_children_second),
caption = "Function Label logistic regression for child label second")
Function Label logistic regression for child label second
| Intercept |
0.0241513 |
0.3759905 |
-0.7477375 |
0.7814655 |
1491.577 |
1.000231 |
- |
nb. Small samples here!!
Whether the label affects the first or second function does not appear to affect function judgments for adults. Some trending evidence that it affects judgments for children, making the first function appear more likely to be the true function.