Last active
January 19, 2017 23:27
-
-
Save bwengals/a7c27edfb951f8a712fe31a420fb6d39 to your computer and use it in GitHub Desktop.
R code for Gelman & Carlin --- Beyond Power Calculations
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
retrodesign <- function(A, s, alpha=.05, df=Inf, n.sims=10000){ | |
z <- qt(1-alpha/2, df) | |
p.hi <- 1 - pt(z-A/s, df) | |
p.lo <- pt(-z-A/s, df) | |
power <- p.hi + p.lo | |
typeS <- p.lo/power | |
estimate <- A + s*rt(n.sims,df) | |
significant <- abs(estimate) > s*z | |
exaggeration <- mean(abs(estimate)[significant])/A | |
return(list(power=power, typeS=typeS, exaggeration=exaggeration)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment