draft power analysis for milestones

This commit is contained in:
mjgaughan 2023-11-15 13:50:43 -06:00
parent 8f26cae949
commit e72374fec0

View File

@ -56,7 +56,8 @@ powerCheck <- function(n, nSims) { #run a power calculation on the dataset given
simData <- makeDataNew(n) # make some data simData <- makeDataNew(n) # make some data
## outcome goes here --v ## outcome goes here --v
# e.g. simData$up.fac.mean <- (usefuleffsizeA * mmt) + (usefuleffsizeB * milestones) + rnorm(n=1, mean=0, sd=1) ##plus some noise # e.g. simData$up.fac.mean <- (usefuleffsizeA * mmt) + (usefuleffsizeB * milestones) + rnorm(n=1, mean=0, sd=1) ##plus some noise
simData$up.fac.mean <- (-2.075 * simData$mmt) + (0.4284 * simData$milestones) + rnorm(n=1, mean=0, sd=1) #simData$up.fac.mean <- (-2.075 * simData$mmt) + (0.4284 * simData$milestones) + rnorm(n=1, mean=0, sd=1)
simData$up.fac.mean <- (0.4284 * simData$milestones) + rnorm(n=1, mean=0, sd=1)
#have updated for kkex through here, now need to look at the underproduction work #have updated for kkex through here, now need to look at the underproduction work
#m1.sim <- lm(up.fac.mean ~ ((mmt)/ (milestones/age)), data=simData) #m1.sim <- lm(up.fac.mean ~ ((mmt)/ (milestones/age)), data=simData)
## could leave age out for now? ## could leave age out for now?
@ -64,13 +65,13 @@ powerCheck <- function(n, nSims) { #run a power calculation on the dataset given
m1.sim <- lm(up.fac.mean ~ mmt + milestones, data=simData) m1.sim <- lm(up.fac.mean ~ mmt + milestones, data=simData)
p0 <- coef(summary(m1.sim))[1,4] #intercept p0 <- coef(summary(m1.sim))[1,4] #intercept
p1 <- coef(summary(m1.sim))[2,4] #mmt p1 <- coef(summary(m1.sim))[2,4] #mmt
p2 <- coef(summary(m1.sim))[3,4] #milestones #p2 <- coef(summary(m1.sim))[3,4] #milestones
#p3 <- coef(summary(m1.sim))[4,4] #age #p3 <- coef(summary(m1.sim))[4,4] #age
signif0[s] <- p0 <=.05 signif0[s] <- p0 <=.05
signif1[s] <- p1 <=.05 signif1[s] <- p1 <=.05
signif2[s] <- p2 <=.05 #signif2[s] <- p2 <=.05
#signif3[s] <- p3 <=.05 #signif3[s] <- p3 <=.05
signifM[s] <- p0 <=.05 & p1 <=.05 & p2 <=.05 #& p3 <=.05 signifM[s] <- p0 <=.05 & p1 <=.05 #& p2 <=.05 #& p3 <=.05
} }
power <- c(mean(signif0), mean(signif1), mean(signif2), mean(signif3), mean(signifM)) power <- c(mean(signif0), mean(signif1), mean(signif2), mean(signif3), mean(signifM))
return(power) return(power)