Description Usage Arguments Value Author(s) References Examples
Robust rank-based test of interaction between treatment and center.
1 | interaction.test.mrfit(x, y, block)
|
x |
n by p design matrix |
y |
n by 1 response vector |
block |
n by 1 vector denoting block membership |
Fstat |
F test statistic |
Fpval |
p-value associated with F statistic |
Tstat |
Chi-sq test statistic |
Tpval |
p-value associated with Chi-sq statistic |
John Kloke kloke@biostat.wisc.edu
Rashid, M.M., McKean, J.W., Kloke, J.D. (2011). R Estimates and Associated Inferences for Mixed Models with Covariates in a Multi-Center Clinical Trial. Statistics in Biopharmaceutical Research.
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 | ##---- 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, block)
{
ub <- unique(block)
m <- length(ub)
p <- ncol(x)
bigbetahat <- vector(mode = "numeric", length = m * p)
tauhat <- vector(mode = "numeric", length = m)
one <- rep(1, m - 1)
Ip <- diag(rep(1, p))
H1 <- one %x% Ip
H2 <- -diag(1 * one) %x% Ip
H <- cbind(H1, H2)
V <- matrix(0, nrow = m * p, ncol = m * p)
min.n <- sum(block == ub[1])
for (i in 1:m) {
yi <- y[block == ub[i]]
xi <- x[block == ub[i], ]
xi <- xi - outer(rep(1, nrow(xi)), apply(xi, 2, mean))
if (length(yi) < min.n) {
min.n <- length(yi)
}
fit <- rfit(xi, yi)
bigbetahat[((i - 1) * p + 1):(i * p)] <- fit$coef
V[((i - 1) * p + 1):(i * p), ((i - 1) * p + 1):(i * p)] <- solve(crossprod(xi))
}
tauhat <- mrfit(x, y, block)$tauhat
q <- nrow(H)
HB <- H %*% bigbetahat
F <- t(HB) %*% solve(H %*% V %*% t(H)) %*% HB/(q * tauhat^2)
T <- q * F
list(Fstat = F, Fpval = 1 - pf(F, q, min.n - p), Tstat = T,
Tpval = 1 - pchisq(T, q))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.