Re: [R] Generating Data for Simulation

From: Ben Bolker <bolker_at_ufl.edu>
Date: Wed, 12 Nov 2008 14:48:36 +0000 (UTC)

Brett Magill <magillb <at> sbcglobal.net> writes:

>
> Are there any R packages that could be used to generate random data given a
> set of parameters? Or, if not a package, how would one generate such data?
> What I would like to do is simulate some sample data for a regression model
> given a set of population covariances and distribution parameters to be used
> in a MC simulation.
>
> Thanks for any tips.
>

  This is very definitely doable, don't know of any end-user packages to do it.

  Simple example: generate data according to

n=100
X ~ Uniform(0,10)
Y ~ Normal(1+2*X,sigma=0.1)

set.seed(1001) ## for reproducibility

n <- 100
x <- runif(n,0,10)
y <- rnorm(n,mean=1+2*x,sigma=0.1)

  You can look at chapter 5 of
http://www.zoology.ufl.edu/bolker/emdbook/book.pdf (or buy the book) for more information ...

  cheers
    Ben Bolker



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 Wed 12 Nov 2008 - 14:56:10 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 Wed 12 Nov 2008 - 16:30:24 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