xanova.lmer: Modified Anova for lmer objects

Usage Arguments Examples

View source: R/fun.R

Usage

1
xanova.lmer(fit, Llist, df = NULL, clevel = 0.95)

Arguments

fit
Llist
df
clevel

Examples

 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
##---- 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, Llist, df = NULL, clevel = 0.95) 
{
    warning("xanova.lmer uses Chi-Square tests")
    ret <- list()
    for (ii in 1:length(Llist)) {
        L <- rbind(Llist[[ii]])
        QR <- qr(L)
        R <- qr.R(QR)
        dfH <- QR$rank
        eta <- R %*% fixef(fit)
        vv <- R %*% vcov(fit) %*% t(R)
        chisq <- t(eta) %*% qr.solve(vv, eta)
        test <- list(ChiSquare = chisq, DF = dfH, `p-value` = 1 - 
            pchisq(chisq, dfH))
        ret[[ii]]$anova <- test
        eta <- L %*% fixef(fit)
        vv <- diag(L %*% vcov(fit) %*% t(L))
        etasd <- sqrt(vv)
        zval <- c(eta/etasd)
        aod <- cbind(Estimate = c(eta), Std.Error = etasd, `z-value` = zval, 
            `p-value` = 2 * pnorm(-abs(zval)))
        if (!is.null(clevel)) {
            hw <- qnorm(1 - (1 - clevel)/2) * etasd
            aod <- cbind(aod, LL = eta - hw, UL = eta + hw)
            labs <- paste(c("Lower", "Upper", format(clevel)))
            colnames(aod)[ncol(aod) + c(-1, 0)] <- labs
        }
        aod <- as.data.frame(aod)
        class(aod) <- c("estimate.lme", "data.frame")
        ret[[ii]]$estimate <- aod
    }
  }

gmonette/spida documentation built on May 14, 2017, 1 p.m.