Description Usage Arguments Details Value Note Examples
View source: R/pub01_utilityFuncs.R
Compute a bivariate sample distribution drawn from a population with a given . It either computes two random variables, or it takes one existing variable (passed as parameter x) and creates a second variable with the desired correlation.
1 |
n |
a integer. number of observations |
rho |
a numeric. the desired correlation |
mar.fun |
the marginal distribution function |
x |
a vector. the existing variable. |
drop.x |
logical. If true, then return a vector of the generated variable. |
... |
other arguments to mar.fun |
Get from a forum post: http://stats.stackexchange.com/questions/15011/generate-a-random-variable-with-a-defined-correlation-to-an-existing-variable/15035#15035
a data frame of two variables which correlate with a population correlation of rho, or a vector when drop.x is true.
this is only an approximate solution, i.e., the empirical correlation is not exactly equal to rho.
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.