CrumpLab / psyc7709_2019

Course website for PSYC 7709 - Using R for Reproducible Research (taught by Matt Crump 2019)
https://crumplab.github.io/psyc7709_2019/
1 stars 7 forks source link

Saving p values in power simulation #15

Open mhorger opened 5 years ago

mhorger commented 5 years ago

Hi! I'm trying to run the simulated power curve and I can't get the p value from my ANOVA table (2x2 between and within subs).

Here's the code: sim_power <- function(x){ TDsleep <- rnorm(n = 25, mean=-0.1, sd = 0.2) DSsleep <- rnorm(n = 25, mean=-0.5, sd = 0.2) TDwake <- rnorm(n = 25, mean=-0.4, sd = 0.2) DSwake <- rnorm(n = 25, mean=-0.2, sd = 0.2) scores <- c(TDsleep, TDwake,DSsleep, DSwake ) cond<- rep(rep(c("SLEEP", "WAKE"), each = 25), 4) gru<- rep(rep(c("TD", "DS"), each = 50), 2) subs<-as.factor(rep(seq(1:50), 2)) DF<- data.frame(subs, scores, cond, gru) novaresults<- summary(aov(scores~gru*cond + Error(subs/(cond)), DF) ) novaresults<-str(novaresults) return(novaresults[[1]][["Pr(>F)"]][1]) }

Every other piece of the function seems to work when I run it independently, but I get NULL when I try indexing the p value.

mhorger commented 5 years ago

I also get this error Error in FUN(X[[i]], ...) : (list) object cannot be coerced to type 'double'