Hello,
I want simulate many different datasets with numbes of objects per group
from ni.min to ni.max, and numbes of repeated measurements from t.min
to t-max), with s=10000 simulations each, to examine the power.
Can someone help me to optimize my program?
sim.power <- function(s, ni.min, ni.max, t.min, t.max, delta)
{
sim_data.frame("ni"=1,"t"=1,"power"=1)
for (ni in ni.min:ni.max) # loop for number of objects
{
for (t in t.min:t.max) # loop for timepoints
{
sum_0
for(i in 1:s) # simulation loop
{
m_matrix(0, 2*ni, t)
m[1:ni,]_matrix(rnorm(ni*t), ni, t) # 1st subgroup
m[(ni+1):(2*ni),]_matrix(rnorm(ni*t, mean=delta), ni, t) # 2nd
subgroup
b_f1ldf1.sim(m, 2, ni, t)
sum_sum+b
}
power_sum/s
erg_data.frame(ni,t,power)
sim_rbind(sim, erg)
}
}
return(sim.ergebnis)
}
Thank you very much,
Tania Schink
|