1 |
x |
|
y |
|
alpha |
|
CN |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y, alpha = 0.05, CN = FALSE)
{
if (ncol(x) != 2)
stop("x should be a matrix with two columns")
x1y = elimna(cbind(x[, 1], y))
x2y = elimna(cbind(x[, 2], y))
xx = elimna(x)
r12 = cor(x1y[, 1], x1y[, 2])
r13 = cor(x2y[, 1], x2y[, 2])
r23 = cor(xx[, 1], xx[, 2])
ci12 = pcorhc4(x1y[, 1], x1y[, 2], alpha = alpha, CN = CN)$ci
ci13 = pcorhc4(x2y[, 1], x2y[, 2], alpha = alpha, CN = CN)$ci
corhat = ((r23 - 0.5 * r12 * r13) * (1 - r12^2 - r13^2 -
r23^2) + r23^3)/((1 - r12^2) * (1 - r13^2))
term1 = 2 * corhat * (r12 - ci12[1]) * (ci13[2] - r13)
term2 = 2 * corhat * (r12 - ci12[2]) * (ci13[1] - r13)
L = r12 - r13 - sqrt((r12 - ci12[1])^2 + (ci13[2] - r13)^2 -
term1)
U = r12 - r13 + sqrt((r12 - ci12[2])^2 + (ci13[1] - r13)^2 -
term2)
list(est.rho1 = r12, est.rho2 = r13, ci = c(L, U))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.