Repository navigation
Expand file tree
/
Copy pathStats.Rmd
More file actions
306 lines (234 loc) · 11.4 KB
/
Copy pathStats.Rmd
File metadata and controls
306 lines (234 loc) · 11.4 KB
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
292
293
294
295
296
297
298
299
300
301
302
303
304
---
title: "Infant Social Attention During Goal-Directed Action"
author: "Jordan Martin"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
code_folding: hide
---
```{r Load Libraries, cache=FALSE, include=FALSE}
library(tidyverse)
library(stats)
library(knitr)
library(modelr)
library(broom)
library(ROCR)
```
```{r helper function}
# Cleans up an lm output for pretty printing
tidy_x <- function(x, predictors = NA) {
tidy(x) %>%
rowwise() %>%
mutate(p.value = sprintf("%.3f", p.value),
p.value = ifelse(p.value == "0.000", "< .001", p.value)) %>%
select(term, estimate, std.error, statistic, p.value) %>%
rename(`$z$ value` = statistic,
`$p$ value` = p.value,
`std. error` = std.error)
}
```
<h2> Method </h2>
<h3> Eye-tracking Paradigm </h3>
Eighteen-month-old infants were shown an eye-tracking paradigm in which a female agent reached for one of two toys on familiarization. On test, the agent raised her hand to midline, but did not complete a reaching action. Progression to the next scene was contingent on the infant making either a location- or goal-based prediction, as previously described. If the infant did not generate sufficient fixation, the scene progressed after a total of 8 seconds had elapsed from initial presentation. The task included four different agents and toy-pairs. Test trials were shown twice, each after a familiarization scene, for a total of 8 Test Trials. Two datasets of gaze-fixations were generated to investigate potential differences in the prescribed definition of a prediction from either the Hand AOI or Body AOI, as pictured below.


<h3> [Data Reduction](Tidying.html) </h3>
Load in data.
```{r Load Data, echo=TRUE, message=FALSE, warning=FALSE}
MOAP <- read_csv("data/MOAP.csv")
# Fix pesky `` issue
names(MOAP)[1] <- "Test"
# Drop NA rows
MOAP <- drop_na(MOAP, Hand_Prediction, Body_Prediction)
```
<h3> Exclusions </h3>
A total of 12 infants were excluded from analysis due to low calibration (n = 4), fussiness (n = 2), and sample rate < 50% (n = 6).
```{r Exclusions, echo=TRUE, message=FALSE, warning=FALSE}
filtered <- MOAP %>%
filter(ID != "M08" & ID != "M11" & ID != "M14" & ID != "M17" & ID != "M18" & ID != "M25" & ID != "M26" & ID != "M27" & ID != "M30" & ID != "M31" & ID != "M32" & ID != "M33")
ValidTrials <- filtered %>%
summarise(n = n())
kable(ValidTrials,
col.names = c("Total"),
caption = "Number of Valid Trials")
```
<h2> Analysis </h2>
<h3> Summary </h3>
<h4> Hand AOI </h4>
```{r Hand AOI Summary}
HandSummary <- filtered %>%
group_by(Hand_Prediction)%>%
summarise(n = n())
kable(HandSummary,
col.names = c("Prediction Type", "Num Predictions"),
caption = "Number of Predictions from Hand AOI")
```
<h4> Body AOI </h4>
```{r Body AOI Summary}
BodySummary <- filtered %>%
group_by(Body_Prediction)%>%
summarise(n = n())
kable(BodySummary,
col.names = c("Prediction Type", "Num Predictions"),
caption = "Number of Predictions from Body AOI")
```
<h3> Question #1 </h3>
Does varying initial fixation AOI from hand to body change prediction response?
```{r Prediction Proportions, echo=TRUE, message=FALSE, warning=FALSE}
# Graph Proportion of Predictions for each initial AOI
HandProp <- HandSummary %>%
mutate(AOI = "Hand")%>%
rename(Prediction = Hand_Prediction)
BodyProp <- BodySummary %>%
mutate(AOI = "Body")%>%
rename(Prediction = Body_Prediction)
AOIProp <- rbind(HandProp, BodyProp)%>%
group_by(AOI)%>%
mutate(prop = prop.table(n))
ggplot(AOIProp,
aes(x=Prediction, y=prop, fill=AOI)) +
facet_grid(. ~ AOI) +
geom_bar(stat = 'identity', position = 'dodge')+
labs(title = "Predictions by AOI", x = "Prediction", y = "Proportion of Predictive Fixations")
```
The graphs indicate that more predictions are revealed by an anlysis of fixations originating from the body than the hand.
<h4> Compare AOIs </h4>
```{r Compare AOI, echo=TRUE, message=FALSE, warning=FALSE}
# Recode Predictions
HP <- filtered %>%
filter(Hand_Prediction != "No Prediction")%>%
select(ID, Trial_Num, Hand_Prediction, Hand_Latency, FamTrialLength_ms, Fam_Screen)%>%
na.omit()%>%
mutate(Prediction = ifelse(Hand_Prediction == "Distracter", 0, 1))%>%
select(Prediction)
BP <- filtered %>%
filter(Body_Prediction != "No Prediction")%>%
select(ID, Trial_Num, Body_Prediction, Body_Latency, FamTrialLength_ms, Fam_Screen)%>%
na.omit()%>%
mutate(Prediction = ifelse(Body_Prediction == "Distracter", 0, 1))%>%
select(Prediction)
tests <- list()
tests[[1]] <- t.test(HP$Prediction, mu=.5)
tests[[2]] <- t.test(BP$Prediction, mu=.5)
df <- sapply(tests, function(x) {
c(x$statistic,
x$parameter,
x$estimate[1],
ci.lower = x$conf.int[1],
ci.upper = x$conf.int[2],
`$p$ value` = x$p.value)
})
colnames(df)<- c("Hand", "Body")
kable(t(df),
caption = "Comparison of AOI Means")
```
Planned comparisons against chance (.5) revealed that when using the Body definition, infants launched predictive fixations systematically to the prior goal (M=0.60, SD=.49, t(88)=2.04, p = .04*), whereas, when using the Hand definition, infants responded at chance levels (M=0.48, SD=.50, t(49)=-0.28, p = .78). Therefore, remaining analyses will be performed on data generated from an initial fixation to the Body AOI.
<h3> Question #2 </h3>
Does latency vary between type of prediction?
```{r Latency, message=FALSE, warning=FALSE}
PredLat <- filtered %>%
filter(Body_Prediction != "No Prediction")%>%
select(ID, Trial_Num, Body_Prediction, Body_Latency, FamTrialLength_ms, Fam_Screen)%>%
na.omit()%>%
mutate(Prediction = ifelse(Body_Prediction == "Distracter", 0, 1))%>%
group_by(Prediction)
ggplot(PredLat, aes(Body_Prediction, Body_Latency))+
geom_boxplot(group = "Body_Prediction")+
labs(title = "Latency Between Object Predictions", x = "Prediction", y = "Latency to Predict (ms)")
tests <- list()
tests[[1]] <- t.test(Body_Latency ~ Prediction, data = PredLat)
df <- sapply(tests, function(x) {
c(x$statistic,
x$parameter,
x$estimate[1],
x$estimate[2],
ci.lower = x$conf.int[1],
ci.upper = x$conf.int[2],
`$p$ value` = x$p.value)
})
kable(t(df),
caption = "Comparison of latency between predictions")
```
Planned comparisons against chance (.5) revealed that infants did not differ reliably in the time required to generate prior goal predictions (M=1628, SD=1591) compared to prior location predictions (M=2051, SD=2011; t(60)=1.04, p =.29). This sample fails to replicate findings that infants demonstrate significantly longer latencies when generating goal predictions. Perhaps attention to the familiarization scene will mediate differences in both proportional prediction and latencies to predict.
<h3> Question #3 </h3>
Can attention to the scene during the Familiarization trial predict whether or not an infant will generate any prediction?
```{r Attention Prediction, message=FALSE, warning=FALSE}
# Calculate % attention
AttPrediction <- filtered %>%
select(ID, Trial_Num, Body_Prediction, Body_Latency, FamTrialLength_ms, Fam_Screen)%>%
mutate(Attention = Fam_Screen / FamTrialLength_ms)%>%
mutate(Prediction = ifelse(Body_Prediction == "No Prediction", 0, 1))%>%
arrange(FamTrialLength_ms)
# Convert to factor for analysis
AttPrediction$Prediction <- as.factor(AttPrediction$Prediction)
# Split model into Train and Test
train <- AttPrediction[1:110,]
test <- AttPrediction[111:130,]
# Fit the model
model <- glm(Prediction ~ Attention, family=binomial, data=train)
# Function to transform logit
logit2prob <- function(x){
exp(x) / (1 + exp(x))
}
# Add predictions
AP_attention <- AttPrediction %>%
add_predictions(model) %>%
mutate(pred = logit2prob(pred))
# Visualize
ggplot(AP_attention, aes(Attention)) +
geom_line(aes(y = pred)) +
labs(title = "Relationship Between Proportional Attention and Generating Visual Predictions",
y = "Predicted Probability of Generating a Visual Prediction")
kable(tidy_x(model),
caption = "Model Fit")
# Test variance
kable(tidy(anova(model, test="Chisq")),
caption = "Model Variance")
```
According to the model, proportional attention to familiarization can be used to estimate the likelihood of an infant generating a visual prediction (p = .02). This does not answer whether or not their attention in familiarization has a any relevance to detecting the social and intentional aspect of the test scene (that this agent will continue to act on the previous "goal" object).
<h3> Question #4 </h3>
Can attention to the scene during the Familiarization trial predict what type of prediction infants will generate when they do make a prediction?
```{r Attention Prediction-Type, message=FALSE, warning=FALSE}
AttPredictionType <- filtered %>%
filter(Body_Prediction != "No Prediction")%>%
select(ID, Trial_Num, Body_Prediction, Body_Latency, FamTrialLength_ms, Fam_Screen)%>%
mutate(Attention = Fam_Screen / FamTrialLength_ms)%>%
arrange(FamTrialLength_ms)
# Convert to factor for analysis
AttPredictionType$Body_Prediction <- as.factor(AttPredictionType$Body_Prediction)
# Split model into Train and Test
train <- AttPredictionType[1:79,]
test <- AttPredictionType[80:95,]
# Fit the model
model <- glm(Body_Prediction ~ Attention,
family=binomial(link='logit'),data=train)
kable(tidy_x(model),
caption = "Model Fit")
# Test variance
kable(tidy(anova(model, test="Chisq")),
caption = "Model Variance")
```
According to the model, proportional attention to familiarization cannot be used to estimate the likelihood of an infant generating a specific visual prediction to the goal or distracter objects (p = .46). The question still remains as to whether attention to familiarization can reveal a relationship between latency and prediction.
<h3> Question #5 </h3>
Can attention to the scene during the Familiarization trial predict the latency with which infant generate a prediction?
```{r Attention Latency, message=FALSE, warning=FALSE}
AttLatency <- filtered %>%
filter(Body_Prediction != "No Prediction") %>%
select(ID, Trial_Num, Body_Prediction, Body_Latency, FamTrialLength_ms, Fam_Screen)%>%
mutate(Attention = Fam_Screen / FamTrialLength_ms)%>%
arrange(FamTrialLength_ms)
# Convert to factor for analysis
AttLatency$Body_Prediction <- as.factor(AttLatency$Body_Prediction)
ggplot(AttLatency, aes(x = Attention)) +
geom_point(aes(y = Body_Latency))+
facet_grid(. ~ Body_Prediction)+
labs(title = "Attention and Latency to Predict",
x = "Proportional Attention to the Familiarization Scene",
y = "Latency (ms)")
Latency_lm <- lm(Body_Latency ~ Attention * Body_Prediction, AttLatency)
kable(tidy_x(Latency_lm),
caption = "Model")
```
According to the model, proportional attention to familiarization cannot be used to estimate the latency of visual prediction to the goal or distracter objects (p = .44). Further analysis should seek to explore which elements of the familiarization scene might be influential in determining whether or not an infant will generate any visual prediction. Though it was beyond the scope of the current study, with only 130 valid test trials, further analysis into the variables that did not remain constant should be conducted. It may be the case that particular agents or particular toys had a greater influence on infants' attentional cueing to the social information of the scene.