Skip to content

Commit c866b4c

Browse files
author
mhtess
committed
clean up expt 1 script
1 parent e724cf7 commit c866b4c

File tree

1 file changed

+27
-68
lines changed

1 file changed

+27
-68
lines changed

writing/cogsci/analysis/implicitAlternatives.Rmd writing/cogsci/analysis/expt1.Rmd

+27-68
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "4_L1"
2+
title: "Analysis for Expt. 2 in 'Not unreasonable' (cogsci)"
33
output: github_document
44
---
55

@@ -12,11 +12,11 @@ library(lme4)
1212
library(lmerTest)
1313
theme_set(theme_few())
1414
project.prefix <- "4_L1_1slider"
15-
#project.prefix.lex <- "7_1slider_lex"
1615
1716
orange.purple.color.palette <-
1817
c("#e66101", "#b2abd2", "#fdb863", "#5e3c99")
1918
```
19+
# Load Data
2020

2121
```{r loadDataAndTime}
2222
d.l1.7 <- read.csv(paste("../data/", project.prefix,"/",project.prefix,"-trials.csv",
@@ -30,10 +30,10 @@ d.l1.7 <- read.csv(paste("../data/", project.prefix,"/",project.prefix,"-trials.
3030
"positive")))
3131
3232
d.l1.7.time <- read.csv(paste("../data/", project.prefix,"/",project.prefix,"-time.csv", sep = ""))
33-
summary(d.l1.7)
33+
#summary(d.l1.7)
3434
```
3535

36-
Table of items
36+
#### Table of items
3737

3838
```{r itemTable}
3939
d.items.lex <- d.l1.7 %>%
@@ -42,7 +42,7 @@ d.items.lex <- d.l1.7 %>%
4242
select(adj_pair) %>%
4343
distinct()
4444
45-
d.items.lex <- data.frame(adj_pair = d.items.lex[with(d.items.lex, order(adj_pair)), ]) %>% rename("Negative opposites" = adj_pair)
45+
d.items.lex <- data.frame(adj_pair = d.items.lex[with(d.items.lex, order(adj_pair)), ]) %>% rename("Lexical antonyms" = adj_pair)
4646
4747
4848
d.items.morph <- d.l1.7 %>%
@@ -52,42 +52,33 @@ d.items.morph <- d.l1.7 %>%
5252
distinct()
5353
5454
d.items.morph <- data.frame(adj_pair = d.items.morph[with(d.items.morph, order(adj_pair)), ])%>%
55-
rename("Antonym opposites" = adj_pair)
55+
rename("Morphological antonyms" = adj_pair)
5656
5757
58-
# d.items <- d.items[with(d.items, order(positive)),] %>%
59-
# rename("Positive adjective" = positive, "Morphological antonym" = morphant,
60-
# "Lexical antonym" = lexant)
61-
6258
tab1 <- xtable::xtable(
6359
cbind(as.matrix(d.items.morph), as.matrix(d.items.lex)),
6460
caption = "Items in Experiment 1.")
65-
save(tab1, file = "../cached_results/item_table_e12.RData")
66-
#print(tab1, type="latex", comment = F, table.placement = "H", include.rownames=FALSE)
67-
#d.items
68-
#d.items.morph
6961
70-
#tab1
62+
#save(tab1, file = "../cached_results/item_table_e12.RData")
7163
7264
```
7365

7466

75-
Time to complete task
67+
#### Time to complete task
7668

7769
```{r fig_timeInMinutes}
78-
7970
d.expt1.time.summary <- d.l1.7.time %>%
8071
summarize(aveTime = mean(time),
8172
sdTime = sd(time))
8273
83-
s#ave(d.expt1.time.summary, file = "../cached_results/time_summary_e1.RData")
84-
#
74+
#save(d.expt1.time.summary, file = "../cached_results/time_summary_e1.RData")
8575
8676
ggplot(d.l1.7.time, aes(x = time)) +
8777
geom_histogram()+
8878
xlab("time in minutes")
8979
```
9080

81+
#### Participant comments
9182

9283
```{r subjectComments}
9384
d.l1.7.comments <- read.csv(paste("../data/",
@@ -98,7 +89,7 @@ d.l1.7.comments <- read.csv(paste("../data/",
9889
d.l1.7.comments %>% select(comments) %>% filter(comments != "") %>% kable()
9990
```
10091

101-
Self-reported native language
92+
#### Self-reported native language
10293

10394
```{r selfReportEnglishNative}
10495
d.l1.7.nativeEnglish <- d.l1.7.comments %>%
@@ -128,11 +119,14 @@ d.l1.natEng <- left_join(
128119
## check that i've done the filtering correctly
129120
length(unique(d.l1.natEng$workerid))
130121
```
122+
123+
#### Number of ratings per item
124+
131125
```{r}
132126
table(d.l1.natEng$positive, d.l1.natEng$adjective_type)
133127
```
134128

135-
Normalize ratings (by subject, subject off mean and divide by SD)
129+
#### Normalize ratings (by subject, subject off mean and divide by SD)
136130

137131
```{r}
138132
d.l1.natEng <- d.l1.natEng %>%
@@ -153,29 +147,21 @@ Raw histograms
153147
d.l1.natEng %>%
154148
ggplot(., aes( x = normalizedResponse,
155149
fill = adjective_type))+
156-
#geom_histogram(position = position_dodge(), bins = 20)+
157150
geom_density(alpha = 0.5)+
158151
facet_wrap(~antonym_type, scales = 'free')+
159152
scale_fill_manual(values = orange.purple.color.palette)+
160-
#facet_grid(antonym_type~adjective_type, scales = 'free')+
161-
#scale_fill_manual(values = orange.purple.color.palette)+
162-
#ylab("counts")+
163153
xlab("slider ratings")
164-
165-
ggsave(paste(
166-
"~/Documents/research/negant/analysis/figs/cogsci_expt1_densities.pdf", sep = ""),
167-
width = 6, height = 3)
168-
169-
##scale_x_continuous(limits = c(-0.01, 1.01), breaks = c(0, 1))+
170-
guides(fill = F)
154+
#
171155
# ggsave(paste(
172-
# "~/Documents/research/talks/vagueness/frisem-2018-01/img/", project.prefix, "_histograms.pdf", sep = ""),
173-
# width = 7, height = 3)
156+
# "~/Documents/research/negant/analysis/figs/cogsci_expt1_densities.pdf", sep = ""),
157+
# width = 6, height = 3)
158+
174159
```
175160

176-
By item histograms
161+
#### Exploratory: By item histograms
177162

178163
```{r}
164+
# how many participants rate a morphological negated antonym below average?
179165
d.l1.natEng %>%
180166
filter(adjective_type == "neg_antonym",
181167
antonym_type == "morphological") %>%
@@ -203,7 +189,7 @@ d.l1.natEng %>%
203189
```
204190

205191

206-
Bootstrapped CIs
192+
#### Bootstrapped CIs
207193

208194
```{r fig_bootstrappedCIs}
209195
d.l1.4.boot <- d.l1.natEng %>%
@@ -249,10 +235,9 @@ d.l1.4.boot %>%
249235
# width = 6, height = 3.75)
250236
```
251237

252-
By item
238+
#### By item
253239

254240
```{r fig.width = 7, fig.height = 5}
255-
256241
d.l1.7.boot.adj <- d.l1.natEng %>%
257242
group_by(positive, adjective, adjective_type) %>%
258243
multi_boot_standard(col = "normalizedResponse") %>%
@@ -266,11 +251,6 @@ d.l1.7.boot.adj <- d.l1.natEng %>%
266251
"positive")))
267252
268253
269-
# %>%
270-
# filter(adjective_type %in% c("lexant",
271-
# "morphant",
272-
# "neg_positive"))
273-
274254
d.l1.7.boot.adj %>%
275255
ggplot(., aes(x = adjective,
276256
y = mean,
@@ -303,23 +283,6 @@ d.l1.7.boot.adj %>%
303283

304284
Helmert coding, maximal model, and model comparison to simpler model.
305285

306-
```{r}
307-
308-
summary(lmer(
309-
response ~ adjective_type +
310-
(1 | workerid) +
311-
(1 | positive),
312-
data = d.l1.natEng %>%
313-
mutate(adjective_type = factor(adjective_type,
314-
levels = c("neg_positive",
315-
"lexant",
316-
"morphant",
317-
"neg_lexant",
318-
"neg_morphant",
319-
"positive")))
320-
))
321-
322-
```
323286

324287

325288
```{r}
@@ -362,25 +325,23 @@ summary(rs.7.helmert)
362325
# "../cached_results/regression_antTypeXadjType_expt1.RData")
363326
364327
365-
366-
328+
## more limited random effects structure
367329
rs.7.helmert.0 <- lmer(response ~ antonym_type * st +
368330
(1 + st | workerid) +
369331
(1 | positive),
370332
data = d.l1.natEng.rescaled)
371333
# extra random effect of sentence_type by item accounts for significantly more variance
372334
anova(rs.7.helmert.0, rs.7.helmert)
373-
374-
# try model with inverse random effect structure?
375335
```
376336

337+
Examine residuals
338+
377339
```{r}
378340
plot(rs.7.helmert)
379341
qqnorm(residuals(rs.7.helmert))
380342
```
381343

382-
383-
"Simple effects"
344+
### "Simple effects"
384345

385346
```{r reg.simple.morph}
386347
@@ -451,7 +412,6 @@ ggplot(d.l1.4.splithalf,
451412
### First vs. last rating
452413

453414
```{r}
454-
455415
d.l1.4.first.last <- bind_rows(
456416
d.l1.4 %>%
457417
group_by(workerid, negation, sentence_type) %>%
@@ -475,5 +435,4 @@ ggplot(d.l1.4.first.last.summary, aes(x = presentation, fill = sentence_type,
475435
geom_errorbar(position = position_dodge())+
476436
facet_wrap(~negation)
477437
478-
#ggsave("~/Documents/research/negant/analysis/figs/split_half-3_L1.pdf", width =6 , height = 4)
479438
```

0 commit comments

Comments
 (0)