Uses a Gaussian copula to produce a draw from draw_handler whose
rank correlation with given is approximately rho. Works with
any draw_* function that accepts a quantile_y argument, and
with base R random-number generators (e.g. rnorm, rpois).
Arguments
- draw_handler
Unquoted function name. Either one of the three
draw_*functions that take aquantile_yargument (draw_binary,draw_binomial,draw_count) or a base Rr*generator with aq*counterpart (rnorm,rpois,rbinom, and the rest of the stats family).draw_ordered,draw_likert,draw_categorical,draw_quantile, and the two ICC draws take no quantile argument and are refused with a message saying so.- ...
Arguments forwarded to
draw_handler(e.g.prob,mean).- given
Reference vector; the new variable will be rank-correlated with this.
- rho
Correlation of the Gaussian copula, in \([-1, 1]\). It is not the realized Spearman correlation, which is smaller by the copula's own relation, \((6/\pi)\arcsin(\rho/2)\):
rho = 0.7lands at 0.68 andrho = 0.3at 0.288. The realized Pearson correlation isrho. fabricatr 1.x behaves identically.
Value
A double vector of length length(given). Note that the type
is double whatever draw_handler is: draw_binary,
draw_binomial, and draw_count each return an integer vector
when called directly and a double one when routed through here, because
the copula reaches them through a quantile function. The values are
unaffected. An NA in given yields an NA in the
result at that position.