-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.qmd
291 lines (250 loc) · 8.92 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
---
title: "ManyBabies 1"
subtitle: "Infant-Directed Speech Preference"
description: |
In the first ManyBabies project, we replicated a robust finding from developmental literature: infants’ preference for infant-directed speech (IDS) over adult-directed speech (ADS). IDS is characterized by a higher pitch, greater pitch excursions, and shorter utterances when compared to ADS. Exposure to IDS has been shown to improve word segmentation and word learning. We asked if infants have a preference for IDS, and how this preference varies across age, native language background, and method.
Sixty-nine labs from 16 countries participated and collected data from 2,329 infants (range: 3-15 months old). We focused on three primary methods for assessing infants’ interest: single-screen central fixation, eye tracking, and the head-turn preference procedure (HPP).
title-block-banner: "#9687A3"
title-block-banner-color: white
---
```{r setup}
library(readr)
library(stringr)
library(dplyr)
library(glue)
```
```{r meta}
project <- redivis::user("mikabr")$project("mb1")
forest_table <- project$table("mb1-meta_output")$to_tibble()
forest_data <- forest_table |>
mutate(Method = if_else(method == "", "(Global)", method),
meta = str_detect(lab, "Meta-analytic"),
lab = if_else(meta, glue("({lab})"), lab),
inverse_vars = if_else(meta, max(inverse_vars, na.rm = TRUE),
inverse_vars),
age_label = if_else(is.na(age_group), "", glue("[{age_group}]")),
y_label = paste(lab, age_label)) |>
arrange(Method, desc(meta), effects) |>
mutate(order = 1:n())
# arrange(age_group)
# rename_with(\(s) str_replace_all(s, "\\.", "_"), .cols = everything())
ojs_define(forest_data = forest_data)
```
```{r trials}
lt_fits <- project$table("mb1-lt-model_output")$to_tibble() |>
mutate(nae = if_else(nae, "NAE", "non-NAE"),
type_nae = paste(trial_type, nae, sep = ", "))
ojs_define(lt_fits = lt_fits)
dataset <- redivis::user("datapages")$dataset("many_babies_1")
trial_table <- dataset$table("03_data_trial_main")$to_tibble()
trial_data <- trial_table |>
filter(!is.na(looking_time),
trial_type != "train") |>
mutate(nae = if_else(nae, "NAE", "non-NAE"),
type_nae = paste(trial_type, nae, sep = ", ")) |>
mutate(method = case_when(
method == "singlescreen" ~ "Central fixation",
method == "eyetracking" ~ "Eye tracking",
method == "hpp" ~ "HPP",
TRUE ~ method))
ojs_define(trial_data = trial_data)
```
:::: {.panel-tabset}
## Meta-analysis
::: {.panel-tabset .nav-pills}
### Plot
::: {.caption}
Forest plot of the meta-analytic results for infant-directed-speech preference. The standardized __effect size__ [x axis] is shown for each __lab__ and __age group__ [y axis]; error bars indicate 95% confidence intervals. Effects are grouped by __method__ [colors]: central fixation, eye tracking, or head-turn preference procedure (HPP). Larger plotted points correspond to greater __inverse variance__. For each method, the diamond and associated error bars represent the __meta-analytic estimate__ from the method-moderated model and the estimate's 95% confidence interval. The top diamond shows the global meta-analytic estimate and 95% confidence interval from the unmoderated model.
:::
```{ojs}
Plot = import("https://esm.sh/@observablehq/[email protected]")
fontFamily = "Source Sans Pro"
fontSize = ".75rem"
d = transpose(forest_data)
maxX = d3.max(forest_data.effects_cih)
pad = 0.1
methodIndeces = d3.rollup(
d,
(values) => ({Method: values[0].Method, order: d3.min(values, (d) => d.order)}),
(d) => d.Method
)
method_vals = Array.from(methodIndeces.keys()).filter(x => x)
age_sort = (a, b) => parseInt(a.split('-')[0], 10) - parseInt(b.split('-')[0], 10)
age_vals = Array.from(new Set(forest_data.age_group)).filter(d => d).sort(age_sort)
```
```{ojs}
//| panel: input
viewof methods = Inputs.checkbox(method_vals, {value: method_vals, label: "Methods"})
viewof ages = Inputs.checkbox(age_vals, {value: age_vals, label: "Age groups"})
```
```{ojs}
methodLabels = Array.from(methodIndeces.values()).filter(x => methods.includes(x.Method))
fd = d.filter(d => methods.includes(d.Method))
.filter(d => !d.age_group | ages.includes(d.age_group))
```
```{ojs}
Plot.plot({
style: { fontFamily: fontFamily },
marginLeft: 155,
width: 800,
x: {
label: "Effect size",
line: true,
domain: [d3.min(forest_data.effects_cil) - pad, d3.max(forest_data.effects_cih) + pad],
},
y: {
grid: true,
line: true,
label: "Lab and age group",
labelAnchor: "top",
padding: 1,
type: "point",
fontVariant: (d) => d.meta ? "small-caps" : "normal",
tickFormat: (value) => fd.find((d) => d.order === value).y_label,
},
marks: [
Plot.ruleX([0], {stroke: "lightgrey", strokeDasharray: [3, 3]}),
Plot.ruleY(fd.filter(d => d.meta), {
y: "order",
stroke: "lightgrey"
}),
Plot.ruleX(fd, Plot.pointerY({x: "effects", py: "order", stroke: "Method"})),
Plot.ruleY(fd, Plot.pointerY({px: "effects", y: "order", stroke: "lightgrey"})),
Plot.link(fd, {
y: "order",
x1: "effects_cil",
x2: "effects_cih"
}),
Plot.dot(fd.filter(d => d.meta), {
x: "effects",
y: "order",
stroke: "Method",
fill: "white",
symbol: "diamond",
strokeWidth: 2,
r: "inverse_vars",
}),
Plot.dot(fd.filter(d => !d.meta), {
x: "effects",
y: "order",
stroke: "Method",
fill: "Method",
symbol: "circle",
strokeWidth: 2,
r: "inverse_vars",
}),
Plot.text(methodLabels.filter((d) => d.Method == "(Global)"), {
x: maxX + 0.1,
y: "order",
text: "Method",
fill: "Method",
stroke: "white",
strokeWidth: 12,
fontWeight: "bold",
dy: -6,
fontSize: 18,
textAnchor: "end"
}),
Plot.text(methodLabels.filter((d) => d.Method !== "(Global)"), {
x: maxX + 0.1,
y: "order",
text: "Method",
fill: "Method",
stroke: "white",
strokeWidth: 12,
fontWeight: "bold",
dy: 6,
fontSize: 18,
textAnchor: "end"
}),
Plot.tip(fd, Plot.pointerY({
x: "effects",
y: "order",
stroke: "Method",
format: { y: null },
channels: {
Lab: "lab",
"Age group": "age_group",
"Effect size": (d) => d.effects.toFixed(2),
CI: (d) => `[${d.effects_cil.toFixed(2)}, ${d.effects_cih.toFixed(2)}]`,
},
})),
]
})
```
### Data
<iframe width="100%" height="500" allowfullscreen src="https://redivis.com/embed/tables/wjz0-3avcrf1gh" style="border:0;"></iframe>
:::
## Aggregated
::: {.panel-tabset .nav-pills}
## Plot
::: {.caption}
The lines on this plot shows fitted values from a mixed effects model predicting __looking time__ [y axis] from __trial number__ [x axis], __age__ [columns], __method__ [rows], __trial type__ [IDS red vs. ADS blue], and __language group__ [NAE dark vs. non-NAE light].
:::
```{ojs}
lt = transpose(lt_fits)
age_groups = ["3-6 mo", "6-9 mo", "9-12 mo", "12-15 mo"]
nae_vals = new Map([["North American English (NAE)", "NAE"],
["Not North American English (non-NAE)", "non-NAE"]])
td = transpose(trial_data)
```
```{ojs}
//| panel: input
viewof points = Inputs.toggle({label: "Show data points"})
viewof nae = Inputs.checkbox(nae_vals, {value: Array.from(nae_vals.values())})
```
```{ojs}
ltf = lt.filter(d => nae.includes(d.nae))
tdf = td.filter(d => nae.includes(d.nae))
Plot.plot({
style: { fontFamily: fontFamily },
marginRight: 90,
width: 800,
x: { label: "Trial number", ticks: 4 },
y: {
label: "Looking time (seconds)",
domain: [d3.min(trial_data.looking_time), d3.max(trial_data.looking_time)]
},
fx: { label: "", domain: age_groups },
fy: { label: "" },
color: {
legend: true,
range: ["#CA0020", "#F4A582", "#0571B0", "#92C5DE"], // RdBu for 4 values
domain: ["IDS, NAE", "IDS, non-NAE", "ADS, NAE", "ADS, non-NAE"]
},
marks: [
Plot.dot(points ? tdf : [], {
x: "trial_num",
y: "looking_time",
fill: "type_nae",
fx: "age_group",
fy: "method",
opacity: 0.4,
r: 1
}),
Plot.line(ltf, {
x: "trial_num",
y: "fitted",
stroke: "type_nae",
z: (d) => `${d.trial_type} + ${d.nae}`,
fx: "age_group",
fy: "method",
}),
Plot.tip(ltf, Plot.pointer({
x: "trial_num",
y: "fitted",
stroke: "type_nae",
z: (d) => `${d.trial_type} + ${d.nae}`,
fx: "age_group",
fy: "method",
format: { x: null, y: null, fx: null, fy: null, stroke: null },
channels: { "Trial type": "trial_type", "Language group": "nae" },
})),
]
})
```
## Data
<iframe width="100%" height="500" allowfullscreen src="https://redivis.com/embed/tables/hkp7-3m6rj4xt8" style="border:0;"></iframe>
<iframe width="100%" height="500" allowfullscreen src="https://redivis.com/embed/tables/nh93-awnnkv49p" style="border:0;"></iframe>
:::
::::