Created
September 29, 2017 02:16
-
-
Save SCgeeker/7cbfaeb69c1b1708382a8ca8f6f64f28 to your computer and use it in GitHub Desktop.
Compute effect size and VPC for PANGEA from quasif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Load Raaijmakers 1999 data set from languageR | |
library(languageR) | |
data(quasif) | |
summary(quasif) | |
## Compute the variance of random effect | |
library(lme4) | |
## Parameters for the general effect size | |
cells_number <- nlevels(quasif$SOA) | |
contrast_means <- with(data = quasif, tapply(RT, SOA, mean)) | |
contrast_code <- c(1, -1) | |
b_adj <- max(contrast_code) | |
a_adj <- min(contrast_code) | |
## Compute the variances for VPC | |
Raaijmakers1999_lm <- lmer(RT ~ SOA + (1|Item) + (1 + SOA|Subject), data = quasif) | |
## Compute Residual variance | |
VAR_Residual <- var(resid(Raaijmakers1999_lm)) | |
## Compute Variances of subject intercepts and slopes | |
VAR_Subject <- apply(ranef(Raaijmakers1999_lm)$Subject,2,var) | |
## ComputeVariances of item intercepts | |
VAR_Item <- var(ranef(Raaijmakers1999_lm)$Item) | |
## Compute generalized effect size | |
ES <- t(contrast_code) %*% contrast_means*(b_adj - a_adj)/sum(contrast_code^2 * sqrt(sum(VAR_Residual, VAR_Subject, VAR_Item))) | |
ES | |
## Compute VPCs | |
VPC_Residual <- (VAR_Residual+VAR_Subject[1])/sum(VAR_Residual, VAR_Subject, VAR_Item) | |
VPC_Subject_Slope <- VAR_Subject[2]/sum(VAR_Residual, VAR_Subject, VAR_Item) | |
VPC_Item_Intercept <- VAR_Item/sum(VAR_Residual, VAR_Subject, VAR_Item) | |
print(c(VPC_Item_Intercept, VPC_Subject_Slope, VPC_Residual)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment