1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
regfun |
|
alpha |
|
pts |
|
SEED |
|
nboot |
|
xout |
|
outfun |
|
... |
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 | ##---- 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, regfun = tsreg, alpha = 0.05, pts = NULL,
SEED = TRUE, nboot = 100, xout = FALSE, outfun = out, ...)
{
if (SEED)
set.seed(2)
x1 = as.matrix(x1)
p = ncol(x1)
p1 = p + 1
m1 = elimna(cbind(x1, y1))
x1 = m1[, 1:p]
y1 = m1[, p1]
x2 = as.matrix(x2)
p = ncol(x2)
p1 = p + 1
m2 = elimna(cbind(x2, y2))
x2 = m2[, 1:p]
y2 = m2[, p1]
if (xout) {
m <- cbind(x1, y1)
flag <- outfun(x1, plotit = FALSE, ...)$keep
m <- m[flag, ]
x1 <- m[, 1:p]
y1 <- m[, p1]
m <- cbind(x2, y2)
flag <- outfun(x2, plotit = FALSE, ...)$keep
m <- m[flag, ]
x2 <- m[, 1:p]
y2 <- m[, p1]
}
nv = c(length(y1), length(y2))
if (is.null(pts[1])) {
x1 <- as.matrix(x1)
pts <- ancdes(x1)
}
pts <- as.matrix(pts)
ntests = nrow(pts)
mat <- matrix(NA, ntests, 8)
dimnames(mat) <- list(NULL, c("Est 1", "Est 2", "DIF", "TEST",
"se", "ci.low", "ci.hi", "p.value"))
sqsd1 = regYvar(x1, y1, pts = pts, regfun = regfun, nboot = nboot,
SEED = FALSE, xout = FALSE, outfun = outfun, ...)
sqsd2 = regYvar(x2, y2, pts = pts, regfun = regfun, nboot = nboot,
SEED = FALSE, xout = FALSE, outfun = outfun, ...)
est1 = regYhat(x1, y1, regfun = regfun, xr = pts, xout = FALSE,
outfun = outfun, ...)
est2 = regYhat(x2, y2, regfun = regfun, xr = pts, xout = FALSE,
outfun = outfun, ...)
mat[, 1] = est1
mat[, 2] = est2
est = est1 - est2
mat[, 3] = est
sd = sqrt(sqsd1 + sqsd2)
mat[, 5] = sd
tests = (est1 - est2)/sd
mat[, 4] = tests
pv = 2 * (1 - pnorm(abs(tests)))
mat[, 8] = pv
crit = NULL
if (ntests == 1)
crit = qnorm(1 - alpha/2)
if (length(pts) > 1) {
if (ntests <= 28) {
if (alpha == 0.05)
crit <- smmcrit(Inf, ntests)
if (alpha == 0.01)
crit <- smmcrit01(Inf, ntests)
}
if (ntests > 28)
crit = smmvalv2(dfvec = rep(Inf, nrow(pts)), alpha = alpha)
if (is.null(crit))
crit = smmvalv2(dfvec = rep(Inf, nrow(pts)), alpha = alpha)
}
mat[, 6] = est - crit * sd
mat[, 7] = est + crit * sd
list(n = nv, points = pts, output = mat)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.