com: Prediction with 'lmer' objects

Usage Arguments Examples

View source: R/fun.R

Usage

1
com(fit, varpattern = "", form = terms(fit), data = getData(fit), ...)

Arguments

fit
varpattern
form
data
...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
##---- 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, varpattern = "", form = terms(fit), data = getData(fit), 
    ...) 
{
    getData <- function(x) UseMethod("getData")
    getData.lme <- function(x) x$data
    getData.lmer <- function(x) x@frame
    model.mat <- model.matrix(form, data, ...)
    fe <- fixef(fit)
    effect.names <- grep(varpattern, names(fe), value = T)
    ret <- c(model.mat[, effect.names] %*% fe[effect.names])
    names(ret) <- rownames(model.mat)
    retnames <- rownames(fit$resid)
    ret <- ret[retnames]
    attr(ret, "predictors") <- effect.names
    ret
  }

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