Package 'NCmisc' - HEAnet Mirror Service
Package 'NCmisc' - HEAnet Mirror Service
Package 'NCmisc' - HEAnet Mirror Service
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
6 cor.withcor.withSimulate a correlated variableDescriptionSimulate a variable correlated at level ’r’ with cector x (of the same length). Can either ’preserve’ themean and standard-deviation, leave standardizeed, or select new mean ’mn’ and standard deviation’st’.Usagecor.with(x, r = 0.5, preserve = FALSE, mn = NA, st = NA)Argumentsxrpreservemnstexisting variable, to which you want to simulate a new correlated variablethe ’expected’ correlation you want to target (randomness will mean that theactual correlation will vary around this value)logical, whether to preserve the same mean and standard deviation(SD) as x, forthe new variableoptional, set the mean for the new simulated variable [must also set st if usingthis]optional, set the SD for the new simulated variable [must also set mn if usingthis]Valuereturn the new variable with an expected correlation of ’r’ with xAuthor(s)Nicholas CooperReferenceshttp://www.uvm.edu/~dhowell/StatPages/More_Stuff/CorrGen.htmlSee Alsosim.cor