Created
August 27, 2015 13:03
-
-
Save vasishth/d85f06640346d1033a8e to your computer and use it in GitHub Desktop.
Simulating Type S and Type M errors
This file contains hidden or 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
## probable effect size derived from past studies: | |
D<-15 | |
## SE from the study of interest: | |
se<-46 | |
stddev<-se*sqrt(37) | |
nsim<-10000 | |
drep<-rep(NA,nsim) | |
for(i in 1:nsim){ | |
drep[i]<-mean(rnorm(37,mean=D,sd=stddev)) | |
} | |
## which cells in drep are significant at alpha=0.05? | |
signif<-which(abs(drep/se)>2) | |
## Type S error rate | signif: | |
types_sig<-mean(drep[signif]<0) | |
## Type S error rate | non-signif: | |
types_nonsig<-mean(drep[-signif]<0) | |
## Type M error rate | signif: | |
typem_sig<-mean(abs(drep[signif])/D) | |
## Type M error rate | not-signif: | |
typem_nonsig<-mean(abs(drep[-signif])/D) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment