Commit a91e927f authored by Amit Goldenberg's avatar Amit Goldenberg

Organized the file. Check out the difference score. I think that if we control...

Organized the file. Check out the difference score. I think that if we control order we can get it to where we want it.
parent 76d00803
......@@ -10,21 +10,17 @@ output: html_document
library (ggplot2) ; library ('lme4'); library ('lmerTest'); library ('plyr'); library ('dplyr'); library ('psych'); library ('car'); library("tidyr");
library('lmerTest'); library('coefplot2'); library('Rmisc'); library('ez')
library('lmerTest'); library('Rmisc'); library('ez') ; library ("visreg")
pl1way <- function(dat,y,x) {
library('coefplot');
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
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)
}
......@@ -44,16 +40,23 @@ head(d)
### Andero's stuff ####
```{r convert the file ,include=FALSE}
# separate phases
a <- d[d$phase=="indiv",]
b <- d[d$phase=="social",]
# make a wide format with each picture in a separate row and the phases in separate columns
D3 <- merge(a[,c("subject", "photo", "order", "rt", "P3", "LPP", "SLW")],b,by=c("subject", "photo"))
head(D3)
colnames(D3) <- gsub(".x", ".indiv", colnames(D3), fixed =T)
colnames(D3) <- gsub(".y", ".social", colnames(D3), fixed =T)
head(D3)
# DESCRIPTIVES
table(D3$subject, D3$condition)
ggplot(d, aes(P3)) + geom_density()
......@@ -61,31 +64,110 @@ 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))
```
```{r analysis p3}
pl1way(D3,"P3.indiv","photoType")
pl1way(D3,"LPP.indiv","photoType")
pl1way(D3,"LPP.indiv","photoType")
# continuous model
summary(fit <- lmer(SLW.social ~ SLW.indiv + rate*grate + (1|subject) + (1|photo), data = D3))
coefplot(fit)
visreg(fit, xvar = "grate", by = "rate")
# categorical model
summary(fit <- lmer(SLW.social ~ SLW.indiv + photoType*condition + (1|subject) + (1|photo), data = D3))
coefplot(fit)
# model without neutral pictures
summary(fit <- lmer(P3.social ~ P3.indiv + condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
coefplot(fit)
hea
mean (D3$P3.dif)
```
```{r dif}
head(D3)
D3$P3.dif = D3$P3.social-D3$P3.indiv
D3$LPP.dif = D3$LPP.social-D3$LPP.indiv
D3$SLW.dif = D3$SLW.social-D3$SLW.indiv
summary(fit <- lmer(P3.dif ~ condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
summary(fit <- lmer(LPP.dif ~ condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
summary(fit <- lmer(SLW.dif ~ condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
```
```{r analysis slw }
head(pl1way)
# AFFECTIVE MAIN EFFECT
summary(fit <- lmer(SLW.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(SLW.social ~ SLW.indiv + rate*grate + (1|subject) + (1|photo), data = D3))
coefplot2(fit)
coefplot(fit)
visreg(fit, xvar = "grate", by = "rate")
# categorical model
summary(fit <- lmer(SLW.social ~ SLW.social + photoType*condition + (1|subject) + (1|photo), data = D3))
summary(fit <- lmer(SLW.social ~ SLW.indiv + photoType*condition + (1|subject) + (1|photo), data = D3))
coefplot2(fit)
coefplot(fit)
# model without neutral pictures
summary(fit <- lmer(SLW.social ~ SLW.indiv + condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
coefplot2(fit)
coefplot(fit)
```
```{r LPP}
# continuous model
summary(fit <- lmer(LPP.social ~ LPP.indiv + rate*grate + (1|subject) + (1|photo), data = D3))
coefplot(fit)
visreg(fit, xvar = "grate", by = "rate")
# categorical model
summary(fit <- lmer(LPP.social ~ LPP.indiv + photoType*condition + (1|subject) + (1|photo), data = D3))
coefplot(fit)
# model without neutral pictures
summary(fit <- lmer(LPP.social ~ LPP.indiv + condition + (1|subject) + (1|photo), data = D3[D3$photoType=="emo",]))
coefplot(fit)
```
### my plan is to create two wide formats
####1. will allow me to create a difference score from the first phase to the second
......
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