R: Predict Method for BTglmmPQL Objects

predict.BTglmmPQL {BradleyTerry2} | R Documentation

## Predict Method for BTglmmPQL Objects

### Description

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

### Usage

    ## S3 method for class 'BTglmmPQL'
    predict(object, newdata = NULL, newrandom = NULL,
        level = 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.
`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

    attach(seeds)

    seedsModel <- glmmPQL(cbind(r, n - r) ~ seed + extract,
                          random = diag(length(r)),
                          family = binomial)

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

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

[Package BradleyTerry2 version 1.0-6 Index]