1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
fr1 |
|
fr2 |
|
tr |
|
alpha |
|
pts |
|
SEED |
|
DIF |
|
cov.fun |
|
... |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | ##---- 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 (x1, y1, x2, y2, fr1 = 1.5, fr2 = 1.5, tr = 0.2, alpha = 0.05,
pts = NULL, SEED = TRUE, DIF = TRUE, cov.fun = skipcov, ...)
{
flag = identical(cov.fun, cov.mve)
if (flag)
if (SEED)
set.seed(2)
x1 = as.matrix(x1)
x2 = as.matrix(x2)
if (ncol(x1) != ncol(x2))
stop("x1 and x2 should have same number of columns")
if (ncol(x1) == 1)
stop("For one covariate, use Dancova")
if (nrow(x1) != nrow(x2))
stop("x1 and x2 should have same number of rows")
if (length(y1) != length(y2))
stop("y1 and y2 should have same length")
p = ncol(x1)
p1 = p + 1
m1 = elimna(cbind(x1, y1, x2, y2))
x1 = m1[, 1:p]
y1 = m1[, p1]
p2 = p1 + 1
p3 = p2 + p - 1
p4 = p3 + 1
x2 = m1[, p2:p3]
y2 = m1[, p4]
if (is.null(pts[1])) {
x1 <- as.matrix(x1)
x2 <- as.matrix(x2)
pts <- ancdes(x1)
}
pts <- as.matrix(pts)
flag <- rep(T, nrow(pts))
if (!DIF) {
mat <- matrix(NA, nrow(pts), 9)
dimnames(mat) <- list(NULL, c("n", "est1", "est2", "DIF",
"TEST", "se", "ci.low", "ci.hi", "p.value"))
}
if (DIF) {
mat <- matrix(NA, nrow(pts), 7)
dimnames(mat) <- list(NULL, c("n", "DIF", "TEST", "se",
"ci.low", "ci.hi", "p.value"))
}
n <- 1
vecn <- 1
mval1 <- cov.funl(cov.fun(x1, ...))
mval2 <- cov.funl(cov.fun(x2, ...))
for (i in 1:nrow(pts)) {
t1 = near3d(x1, pts[i, ], fr1, mval1)
t2 = near3d(x2, pts[i, ], fr2, mval2)
pick = as.logical(t1 * t2)
n[i] <- length(y1[pick])
if (n[i] < 5)
flag[i] <- F
if (n[i] >= 5) {
if (!DIF) {
test <- yuend(y1[pick], y2[pick], tr = tr, alpha = alpha)
mat[i, 2] = test$est1
mat[i, 3] = test$est2
mat[i, 4] = test$dif
mat[i, 5] = test$teststat
mat[i, 6] = test$se
mat[i, 7] = test$ci[1]
mat[i, 8] = test$ci[2]
mat[i, 9] = test$p.value
}
if (DIF) {
test <- trimci(y1[pick] - y2[pick], tr = tr,
pr = FALSE, alpha = alpha)
mat[i, 2] = test$estimate
mat[i, 3] = test$test.stat
mat[i, 4] = test$se
mat[i, 5] = test$ci[1]
mat[i, 6] = test$ci[2]
mat[i, 7] = test$p.value
}
}
mat[i, 1] <- n[i]
}
if (sum(flag) == 0)
print("No comparable design points found, might increase span.")
list(pts = pts, output = mat)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.