[R] R question: generating data using MASS
uf_mike
michael.parent at ufl.edu
Mon Aug 29 00:21:52 CEST 2011
Hi, all! I'm new to R but need to use it to solve a little problem I'm having
with a paper I'm writing. The question has a few components and I'd
appreciate guidance on any of them.
1. The most essential thing is that I need to generate some multivariate
normal data on a restricted integer range (1 to 7). I know I can use MASS
mvrnorm command to do this but have a couple questions about that:
-I can make the simulated data but I don't know how to issue a command that
restricts the generated data to be between a specific range (1 to 7), and
integer-only.
-Is there a way to specify a single desired correlation between all the
variables (i.e., I want, say, five variables to all be correlated about .30
with each other), rather than input the entire covariance matrix as sigma?
2. I need to introduce missing data (NA) AFTER generating the data set, and
I need it to be random and at a specific prevalence (say, 5%). Is there a
simple way to take the initial data set and randomly replace 5% of values
with NA missing values?
Thanks, I appreciate any guidance folks can offer. :-)
--
View this message in context: http://r.789695.n4.nabble.com/R-question-generating-data-using-MASS-tp3775093p3775093.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list