1 |
x |
|
y |
|
nboot |
|
alpha |
|
qval |
|
plotit |
|
SEED |
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 | ##---- 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, nboot = 100, alpha = 0.05, qval = c(0.2, 0.8),
plotit = TRUE, SEED = TRUE)
{
print("Note: adjusted confidence intervals are used;")
print("they can differ from p-values")
print("FWE is not controlled")
if (length(qval) != 2)
stop("Argument qval should have 2 values")
x <- as.matrix(x)
p <- ncol(x)
xy <- elimna(cbind(x, y))
x <- xy[, 1:p]
x <- as.matrix(x)
pp <- p + 1
y <- xy[, pp]
if (SEED)
set.seed(2)
print("Taking bootstrap samples. Please wait.")
data <- matrix(sample(length(y), size = length(y) * nboot,
replace = TRUE), nrow = nboot)
bvec1 <- apply(data, 1, qhomtsub2, x, y, qval[1])
bvec2 <- apply(data, 1, qhomtsub2, x, y, qval[2])
bvec1 <- as.matrix(bvec1)
bvec2 <- as.matrix(bvec2)
if (p == 1) {
bvec1 <- t(bvec1)
bvec2 <- t(bvec2)
}
se <- NA
for (j in 1:p) se[j] <- sqrt(var(bvec1[j, ] - bvec2[j, ]))
temp1 <- rqfit(x, y, qval[1])$coef[2:pp]
temp2 <- rqfit(x, y, qval[2])$coef[2:pp]
crit <- qnorm(1 - alpha/2)
crit.ad <- NA
dif <- temp2 - temp1
regci <- NA
regci1 <- dif - crit * se
regci2 <- dif + crit * se
sig.level <- 2 * (1 - pnorm(abs(dif)/se))
regci.ad <- NA
if (alpha == 0.05 && qval[1] == 0.2 && qval[2] == 0.8)
crit.ad <- qnorm(0 - 0.09/sqrt(length(y)) + 0.975)
output <- matrix(NA, ncol = 7, nrow = p)
dimnames(output) <- list(NULL, c("Est 1", "Est 2", "Dif",
"SE", "ci.lower", "ci.upper", "p.value"))
output[, 1] <- temp1
output[, 2] <- temp2
output[, 3] <- dif
output[, 4] <- se
output[, 5] <- regci1
output[, 6] <- regci2
output[, 7] <- sig.level
ci.ad <- c(dif - crit.ad * se, dif + crit.ad * se)
output
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.