1 |
x |
|
y |
|
HC4 |
|
alpha |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ##---- 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, HC4 = FALSE, alpha = 0.05)
{
if (!HC4 && alpha != 0.05)
stop("For alpha not equal to .05, must use HC4=TRUE")
if (!is.matrix(x))
stop("x should be a matrix")
if (!is.matrix(y))
stop("y should be a matrix")
if (ncol(x) != 2)
stop("x should be a matrix with 2 columns")
if (ncol(y) != 2)
stop("y should be a matrix with 2 columns")
xy = elimna(cbind(x, y))
x1 = xy[, 1]
x2 = xy[, 2]
y1 = xy[, 3]
y2 = xy[, 4]
r12 = cor(x1, x2)
r13 = cor(x1, y1)
r14 = cor(x1, y2)
r23 = cor(x2, y1)
r24 = cor(x2, y2)
r34 = cor(y1, y2)
term1 = 0.5 * r12 * r34 * (r13^2 + r14^2 + r23^2 + r24^2)
term2 = r12 * r13 * r14 + r12 * r23 * r24 + r13 * r23 * r34 +
r14 * r24 * r34
corhat = (term1 + r13 * r24 + r14 * r23 - term2)/((1 - r12^2) *
(1 - r34^2))
if (!HC4)
temp = pcorbv4(x1, x2, SEED = FALSE)
if (HC4)
temp = pcorhc4(x1, x2, alpha = alpha)
ci12 = temp$ci[1]
ci12[2] = temp$ci[2]
if (!HC4)
temp = pcorbv4(y1, y2, SEED = FALSE)
if (HC4)
temp = pcorhc4(y1, y2, alpha = alpha)
ci34 = temp$ci[1]
ci34[2] = temp$ci[2]
terml = 2 * corhat * (r12 - ci12[1]) * (ci34[2] - r34)
termu = 2 * corhat * (ci12[2] - r12) * (r34 - ci34[1])
L = r12 - r34 - sqrt((r12 - ci12[1])^2 + (ci34[2] - r34)^2 -
terml)
U = r12 - r34 + sqrt((r12 - ci12[2])^2 + (ci34[1] - r34)^2 -
termu)
list(est.1 = r12, est.2 = r34, ci.lower = L, ci.upper = U)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.