[R] Monte Carlo Simulation

From: Shane Phillips <SPhillips_at_Lexington1.net>
Date: Fri, 15 Apr 2011 14:49:48 -0400


Hello, R friends...

I am very new to R, and I need some help. I am trying to construct a simulation for my dissertation.

I need to create 1000 datasets of 1000 subjects with the following variables...

Treatment variable - Drawn from a binomial distribution (1 run, prob=.13) Covariate 1 - Drawn from a normal distribution (mean=100, sd=16) Covariate 2 - Drawn from a normal distribution (mean=200, sd=9) Covariates 1 and 2 need to be correlated (say, r=.80)

Covariate 3 - Drawn from a binomial distribution (1 run, prob=.5)
Covariate 4 - Drawn from a distribution of discrete variables where 1 has an 80% chance of being selected, 2  - 10%, 3 - 5% and 4 - 5%.  This variable would need to be recoded into 4 binary variables.
Covariate 5 - Drawn from a normal distribution (mean=84, sd=2)
Covariate 6 - Drawn from a binomial distribution (1 run, prob=.15)
Covariate 6 needs to correlate with Covariate 2 (r=.70, or so)

I need each dataset saved as a new datafile with an iterative filename (e.g. sample1, sample2, etc.).

Please help!

Thanks!

Shane



R-help_at_r-project.org 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 Fri 15 Apr 2011 - 18:53:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 15 Apr 2011 - 23:20:31 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.

list of date sections of archive