[R] Simple simulation in R

Peter Flom flom at ndri.org
Tue Aug 26 16:31:06 CEST 2003


Hello all

I have a feeling this is very simple......but I am not sure how to do
it

My boss has two variables, one is an average of 4 numbers, the other is
an average of 3 of those numbers i.e

var1 = (X1 + X2 + X3 + X4)/4
var2 = (X1 + X2 + X3)/3

all of the X variables are supposed to be measuring similar constructs

not surprisingly, these are highly correlated (r = .98), the question
is how much of  this correlation is due to the fact that the X's are
related, and how much to the fact that the two VARs are similarly
constructed

What I want to do is simulate this with normally distributed data for
the X's.  That is, generate (say) 1000 sets of X1 through X4, use those
to caluculate 1000 var1 and var2, and then 1000 correlations between
var1 and var2, and then plot those results.

Any help appreciated

Peter Flom

Peter L. Flom, PhD
Assistant Director, Statistics and Data Analysis Core
Center for Drug Use and HIV Research
National Development and Research Institutes
71 W. 23rd St
www.peterflom.com
New York, NY 10010
(212) 845-4485 (voice)
(917) 438-0894 (fax)




More information about the R-help mailing list