Commit 76d00803 authored by Andero Uusberg's avatar Andero Uusberg

added a couple of visualization lines

parent 061411f5
......@@ -10,7 +10,25 @@ output: html_document
library (ggplot2) ; library ('lme4'); library ('lmerTest'); library ('plyr'); library ('dplyr'); library ('psych'); library ('car'); library("tidyr");
library('lmerTest'); library('coefplot2')
library('lmerTest'); library('coefplot2'); library('Rmisc'); library('ez')
pl1way <- function(dat,y,x) {
pld <- summarySEwithin(dat,y,withinvars = x, idvar = "subject")
tmp <- dat
colnames(tmp) <- gsub(as.name(y),"y",colnames(tmp))
colnames(tmp) <- gsub(as.name(x),"x",colnames(tmp))
res <- ezANOVA(data=tmp,dv=y, wid=subject, within=.(x), type=3)$ANOVA # ANOVA
result <- paste0("F(",res$DFn,",",res$DFd,")=",round(res$F,2), ", GES=", round(res$ges,2), ", p=", round(res$p,3))
ggplot(pld,aes(x=pld[,x],y=pld[,y], ymin=pld[,y]-ci,ymax=pld[,y]+ci)) + geom_pointrange(fatten = 8) +
labs(x=x,y=y, title = result)
}
```
```{r get file, include=FALSE}
......@@ -35,10 +53,27 @@ D3 <- merge(a[,c("subject", "photo", "order", "rt", "P3", "LPP", "SLW")],b,by=c(
colnames(D3) <- gsub(".x", ".indiv", colnames(D3), fixed =T)
colnames(D3) <- gsub(".y", ".social", colnames(D3), fixed =T)
# DESCRIPTIVES
table(D3$subject, D3$condition)
ggplot(d, aes(P3)) + geom_density()
ggplot(d, aes(LPP)) + geom_density()
ggplot(d, aes(SLW)) + geom_density()
# AFFECTIVE MAIN EFFECT
summary(fit <- lmer(P3.indiv ~ photoType + (1|subject) + (1|photo), data = D3))
pl1way(D3,"P3.indiv","photoType")
pl1way(D3,"LPP.indiv","photoType")
pl1way(D3,"LPP.indiv","photoType")
# continuous model
summary(fit <- lmer(LPP.social ~ LPP.indiv + rate*grate + (1|subject) + (1|photo), data = D3))
summary(fit <- lmer(SLW.social ~ SLW.indiv + rate*grate + (1|subject) + (1|photo), data = D3))
coefplot2(fit)
visreg(fit, xvar = "grate", by = "rate")
# categorical model
summary(fit <- lmer(SLW.social ~ SLW.social + photoType*condition + (1|subject) + (1|photo), data = D3))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment