1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
tr |
|
test |
|
cr |
|
pr |
|
DETAILS |
|
cp.value |
|
plotit |
|
xlab |
|
ylab |
|
zlab |
|
span |
|
PV |
|
FRAC |
|
MC |
|
q |
|
iter |
|
alpha |
|
TPM |
|
tau |
|
est |
|
fr |
|
... |
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 90 91 92 93 94 95 96 97 98 99 100 101 102 | ##---- 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, tr = 0.2, test = yuen, cr = NULL, pr = TRUE,
DETAILS = FALSE, cp.value = FALSE, plotit = FALSE, xlab = "X",
ylab = "Y", zlab = NULL, span = 0.75, PV = TRUE, FRAC = 0.5,
MC = FALSE, q = 0.5, iter = 1000, alpha = 0.05, TPM = FALSE,
tau = 0.05, est = tmean, fr = 1, ...)
{
com.p.value = cp.value
if (pr)
print("Reject if test.stat is less than or equal to crit.value")
if (FRAC <= 0 || FRAC >= 1)
stop("FRAC should be a value between 0 and 1.")
if (ncol(x1) != 2)
stop("Should have two covariates")
xy1 = elimna(cbind(x1, y1))
x1 = xy1[, 1:2]
y1 = xy1[, 3]
xy2 = elimna(cbind(x2, y2))
x2 = xy2[, 1:2]
y2 = xy2[, 3]
n = min(c(nrow(x1), nrow(x2)))
if (n < 50) {
if (pr)
print("Warning: sample size is less than 50; critical value unknown")
}
if (is.null(cr)) {
if (n >= 50 & n <= 80)
cr = as.vector(regYhat(c(50, 75), c(0.23, 0.264),
xr = n))
if (n > 80)
cr = 0.27
}
flag0 = is.null(cr)
flag1 = FRAC != 0.5
flag3 = flag0 + flag1 + com.p.value + TPM
if (flag3 > 0) {
comp.pv = anc2COV.CV(nrow(x1), nrow(x2), iter = iter,
MC = MC, TPM = TPM, tau = tau)
MV = sort(comp.pv$M)
ic = round(alpha * iter)
cr = MV[ic]
}
DONE = FALSE
if (identical(test, qcomhd)) {
val = ancovampG(x1, y1, x2, y2, DH = TRUE, SEED = TRUE,
test = qcomhd, q = q, FRAC = FRAC)
DONE = TRUE
}
if (!DONE) {
if (identical(test, yuen))
val = ancovampG(x1, y1, x2, y2, DH = TRUE, SEED = TRUE,
test = yuen, tr = tr, FRAC = FRAC)
if (!identical(test, yuen))
val = ancovampG(x1, y1, x2, y2, DH = TRUE, SEED = TRUE,
test = test, FRAC = FRAC, ...)
}
est.dif = rung3hat(x1, y1, fr = fr, pts = val$points, est = est)$rmd -
rung3hat(x2, y2, pts = val$points, fr = fr, est = est)$rmd
pavg = mean(val$results[, 3])
if (TPM) {
vals = val$results[, 3]
vals = elimna(vals)
pavg = sum(log(vals[vals <= tau]))
}
mpv = which(val$results[, 3] == min(val$results[, 3]))
points = val$points
results = val$results
rem.res = results[mpv, 3]
rem.points = points[mpv, ]
points = cbind(points, est.dif)
dimnames(points) = list(NULL, c("COV 1", "COV 2", "EST.DIF"))
if (plotit) {
if (is.null(zlab)) {
if (PV)
zlab = "P-Value"
if (!PV)
zlab = "Est.Dif"
}
if (PV)
lplot(points[, 1:2], results[, 3], xlab = xlab, ylab = ylab,
zlab = zlab, tick = "det", span = span)
if (!PV)
lplot(points[, 1:2], est.dif, xlab = xlab, ylab = ylab,
zlab = zlab, tick = "det", span = span)
}
nk = nrow(points)
if (!DETAILS) {
points = NULL
results = NULL
}
pval = NULL
if (com.p.value || TPM)
pval = 1 - mean(pavg <= comp.pv$M)
list(num.points.used = nk, test.stat = pavg, crit.value = cr,
GLOBAL.p.value = pval, min.p.val.point = rem.points,
min.p.value = rem.res, all.points.used = points, all.results = results[,
1:3])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.