[R] Simulation help

From: Zodet, Marc W. (AHRQ) <Marc.Zodet_at_ahrq.hhs.gov>
Date: Wed 20 Sep 2006 - 13:29:25 GMT


I'm trying to simulate trend data over a five year period. I want different trend profiles...the simplest being a linear trend. I've been using the following code:  

patBdta1 <- NULL

for(i in 1:100)

patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)),

                             yr2 =mean(rbinom(50,1,.51)),

                             yr3 =mean(rbinom(50,1,.52)),

                             yr4 =mean(rbinom(50,1,.53)),

                             yr5 =mean(rbinom(50,1,.54))))

 

This code creates 100 data sets each with a 5 yr binomial trend profile with a slope of approximately .01.  

Now, what I want to do is pass this code (or some code) in such a way that I can simulate various trend slopes (i.e., pass in a loop or vectorize vs. copying/repeating code for each slope).  

Any guidance is much appreciated. Thanks!  

Marc  

Marc W. Zodet, MS

Senior Health Statistician

Agency for Healthcare Research and Quality

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Sep 20 23:33:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 20 Sep 2006 - 14:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.