library(readr)
library(magrittr)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
##
## Attaching package: 'tidyr'
##
## The following object is masked from 'package:magrittr':
##
## extract
library(ggplot2)
library(langcog)
##
## Attaching package: 'langcog'
##
## The following object is masked from 'package:base':
##
## scale
theme_set(theme_bw())
rm(list=ls())
Read data.
d <- read_csv("processed_data/summary/wide_form_asd.csv")
Reformat.
d %<>%
gather(variable, value, starts_with("reflook"),
starts_with("kitchen"), starts_with("birthday")) %>%
separate(variable, c("stim","dv"), sep = "_") %>%
mutate(time = ifelse(stim == "reflook", 0,
ifelse(stim == "kitchen", 12, 24)))
qplot(time, value, group = subj,
col = group,
geom = "line",
facets = . ~ dv,
data = d)
## Warning: Removed 3 rows containing missing values (geom_path).
## Warning: Removed 4 rows containing missing values (geom_path).
## Warning: Removed 4 rows containing missing values (geom_path).
## Warning: Removed 3 rows containing missing values (geom_path).
First do groupings.
ms <- d %>%
group_by(group, dv, time) %>%
summarise(sem = sem(value, na.rm=TRUE),
value = mean(value, na.rm=TRUE),
n = n()) %>%
ungroup() %>%
mutate(group = factor(group, levels = c("control","tx"),
labels = c("Control","Treatment")))
All DVs.
qplot(time, value, ymin = value - sem, ymax = value + sem,
col = group, group = group,
position = position_dodge(width = .5),
geom = c("line", "pointrange"),
facets = ~ dv,
data = ms)
Just faces.
qplot(time, value, ymin = value - sem, ymax = value + sem,
col = group, group = group,
position = position_dodge(width = .5),
geom = c("line", "pointrange"),
data = filter(ms, dv %in% c("Face"))) +
ylim(c(0, .3)) +
xlab("Time (weeks)") +
ylab("Proportion looking at faces")
Just novel word learning.
qplot(time, value, ymin = value - sem, ymax = value + sem,
col = group, group = group,
position = position_dodge(width = .5),
geom = c("line", "pointrange"),
data = filter(ms, dv %in% c("Novel"))) +
ylim(c(.2, .9)) +
geom_hline(yintercept = .5, lty = 2, col = "black") +
xlab("Time (weeks)") +
ylab("Proportion looking at novel word")
Reshape data.
subs <- d %>% select(-stim) %>% spread(time, value)
Now make a correlaton plot.
face <- filter(subs, dv == "Face") %>%
select(-group, -dv, -subj) %>%
data.frame
ggcorplot(face %>% filter(complete.cases(face)))
And novel word learning.
novel <- filter(subs, dv == "Novel") %>%
select(-group, -dv, -subj) %>%
data.frame
ggcorplot(novel %>% filter(complete.cases(novel)))