s-news
[Top] [All Lists]

optimize a simulation

To: s-news@lists.biostat.wustl.edu
Subject: optimize a simulation
From: Tania Schink <tania.schink@charite.de>
Date: Wed, 19 Feb 2003 10:22:42 +0100
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


<Prev in Thread] Current Thread [Next in Thread>
  • optimize a simulation, Tania Schink <=