predict.BTglmmPQL: Predict Method for BTglmmPQL Objects

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/predict.BTglmmPQL.R

Description

Obtain predictions and optionally standard errors of those predictions from a "BTglmmPQL" object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'BTglmmPQL'
predict(
  object,
  newdata = NULL,
  newrandom = NULL,
  level = ifelse(object$sigma == 0, 0, 1),
  type = c("link", "response", "terms"),
  se.fit = FALSE,
  terms = NULL,
  na.action = na.pass,
  ...
)

Arguments

object

a fitted object of class "BTglmmPQL"

newdata

(optional) a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used.

newrandom

if newdata is provided, a corresponding design matrix for the random effects, will columns corresponding to the random effects estimated in the original model.

level

an integer vector giving the level(s) at which predictions are required. Level zero corresponds to population-level predictions (fixed effects only), whilst level one corresponds to the individual-level predictions (full model) which are NA for contests involving individuals not in the original data. By default level = 0 if the model converged to a fixed effects model, 1 otherwise.

type

the type of prediction required. The default is on the scale of the linear predictors; the alternative "response" is on the scale of the response variable. Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scale) and type = "response" gives the predicted probabilities. The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale (fixed effects only).

se.fit

logical switch indicating if standard errors are required.

terms

with type ="terms" by default all terms are returned. A character vector specifies which terms are to be returned.

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

...

further arguments passed to or from other methods.

Details

If newdata is omitted the predictions are based on the data used for the fit. In that case how cases with missing values in the original fit are treated is determined by the na.action argument of that fit. If na.action = na.omit omitted cases will not appear in the residuals, whereas if na.action = na.exclude they will appear (in predictions and standard errors), with residual value NA. See also napredict.

Standard errors for the predictions are approximated assuming the variance of the random effects is known, see Booth and Hobert (1998).

Value

If se.fit = FALSE, a vector or matrix of predictions. If se = TRUE, a list with components

fit

Predictions

se.fit

Estimated standard errors

Author(s)

Heather Turner

References

Booth, J. G. and Hobert, J. P. (1998). Standard errors of prediction in Generalized Linear Mixed Models. Journal of the American Statistical Association 93(441), 262 – 272.

See Also

predict.glm(), predict.BTm()

Examples

1
2
3
4
5
6
7
8
9
seedsModel <- glmmPQL(cbind(r, n - r) ~ seed + extract,
                      random = diag(nrow(seeds)),
                      family = binomial,
                      data = seeds)

pred <- predict(seedsModel, level = 0)
predTerms <- predict(seedsModel, type = "terms")

all.equal(pred, rowSums(predTerms) + attr(predTerms, "constant"))

BradleyTerry2 documentation built on Feb. 3, 2020, 5:08 p.m.