'https://vincentarelbundock.github.io/Rdatasets/csv/carData/TitanicSurvival.csv code example

Example: process control dataset CSV file

##***part020e;
sink()

# Look at how many years are needed to detect a -5% trend/year with 80% power?
sink("monitor-example1-R-030.txt", split=TRUE)
##***part030b;
poweryears.stroup <- ddply(data.frame(Nyears=4:10), "Nyears", 
   function(x, Ivalue, Trend, Process.SD, Sampling.SD, alpha=0.05){
   # run the simulations
   myres <- slr.power.stroup(Ivalue=Ivalue, Trend=Trend, Xvalues=rep(0:x$Nyears,2), 
                 Process.SD=Process.SD, Sampling.SD=Sampling.SD, alpha=alpha)

   return(myres)
}, Ivalue=Ivalue, Trend=Trend, Process.SD=0, Sampling.SD=Sampling.SD, alpha=0.05)

poweryears.stroup[,c("Nyears","power")]

Tags:

Misc Example