| predict.merMod {lme4} | R Documentation |
predict method for
merMod objects
## S3 method for class 'merMod'
predict(object, newdata = NULL,
newparams=NULL, newX=NULL,
re.form = NULL, ReForm, REForm, REform,
terms = NULL,
type = c("link", "response"), allow.new.levels = FALSE,
na.action = na.pass, ...)
object |
a fitted model object |
newdata |
data frame for which to evaluate predictions |
newparams |
new parameters to use in evaluating predictions,
specified as in the |
newX |
new design matrix to use in evaluating predictions
(alternative to |
re.form |
formula for random effects to condition on. If |
ReForm |
allowed for backward compatibility: |
REForm |
allowed for backward compatibility: |
REform |
allowed for backward compatibility: |
terms |
a |
type |
character string - either |
allow.new.levels |
(logical) if FALSE (default),
then any new levels (or NA values) detected in
|
na.action |
function determining what should be done
with missing values for fixed effects in |
... |
optional additional parameters. None are used at present. |
a numeric vector of predicted values
There is no option for computing standard errors of
predictions because it is difficult to define an
efficient method that incorporates uncertainty in the
variance parameters; we recommend bootMer
for this task.
(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |herd), cbpp, binomial)) str(p0 <- predict(gm1)) # fitted values str(p1 <- predict(gm1,ReForm=NA)) # fitted values, unconditional (level-0) newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd))) str(p2 <- predict(gm1,newdata)) # new data, all RE str(p3 <- predict(gm1,newdata,ReForm=NA)) # new data, level-0 str(p4 <- predict(gm1,newdata,ReForm=~(1|herd))) # explicitly specify RE