1 | Lmu(fit, nam, verbose = 0)
|
fit |
|
nam |
|
verbose |
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 | ##---- 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 (fit, nam, verbose = 0)
{
if (class(fit) != "lmer")
stop("only implemented for lmer")
v <- fit@frame[[nam]]
if (!is.factor(v))
stop("nam needs to specify the name of a factor")
levs <- levels(v)
if (verbose > 0)
print(levs)
cmat <- contrasts(v)
if (verbose > 0)
print(cmat)
fe <- getFix(fit)$fixed
if (verbose > 0)
print(fe)
if (substring(nam, 1, 1) != "^")
nam <- paste("^", nam, sep = "")
L.indices <- grep(nam, names(fe))
if (verbose > 0)
print(L.indices)
L <- matrix(0, nrow = length(levs), ncol = length(fe))
colnames(L) <- names(fe)
if (verbose > 0)
print(L)
rownames(L) <- levs
L[, L.indices] <- cmat
if ("(Intercept)" %in% colnames(L))
L[, "(Intercept)"] <- 1
L
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.