Obtains predictions from a fitted generalized linear model with random effects.

# S3 method for class 'glmmPQL'
predict(object, newdata = NULL, type = c("link", "response"),
       level, na.action = na.pass, ...)

Arguments

object

a fitted object of class inheriting from "glmmPQL".

newdata

optionally, a data frame in which to look for variables with which to predict.

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.

level

an optional integer vector giving the level(s) of grouping to be used in obtaining the predictions. Level values increase from outermost to innermost grouping, with level zero corresponding to the population predictions. Defaults to the highest or innermost level of grouping.

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.

Value

If level is a single integer, a vector otherwise a data frame.

See also

Examples

fit <- glmmPQL(y ~ trt + I(week > 2), random = ~1 |  ID,
               family = binomial, data = bacteria)
#> iteration 1
#> iteration 2
#> iteration 3
#> iteration 4
#> iteration 5
#> iteration 6
predict(fit, bacteria, level = 0, type="response")
#>   [1] 0.96808 0.96808 0.85873 0.85873 0.93448 0.93448 0.74086 0.74086 0.89703
#>  [10] 0.89703 0.63585 0.63585 0.63585 0.96808 0.96808 0.85873 0.85873 0.85873
#>  [19] 0.96808 0.96808 0.85873 0.85873 0.85873 0.89703 0.89703 0.63585 0.63585
#>  [28] 0.93448 0.93448 0.74086 0.74086 0.74086 0.96808 0.96808 0.85873 0.85873
#>  [37] 0.85873 0.96808 0.96808 0.85873 0.85873 0.85873 0.93448 0.74086 0.96808
#>  [46] 0.96808 0.85873 0.85873 0.85873 0.89703 0.89703 0.63585 0.63585 0.63585
#>  [55] 0.96808 0.96808 0.85873 0.85873 0.85873 0.96808 0.96808 0.85873 0.89703
#>  [64] 0.89703 0.63585 0.63585 0.63585 0.93448 0.93448 0.74086 0.74086 0.74086
#>  [73] 0.96808 0.96808 0.85873 0.85873 0.85873 0.89703 0.89703 0.63585 0.63585
#>  [82] 0.63585 0.96808 0.96808 0.85873 0.85873 0.85873 0.93448 0.93448 0.74086
#>  [91] 0.74086 0.96808 0.96808 0.85873 0.85873 0.85873 0.96808 0.96808 0.85873
#> [100] 0.85873 0.85873 0.96808 0.96808 0.85873 0.85873 0.85873 0.93448 0.93448
#> [109] 0.74086 0.74086 0.74086 0.89703 0.89703 0.63585 0.63585 0.96808 0.96808
#> [118] 0.85873 0.96808 0.96808 0.85873 0.85873 0.89703 0.89703 0.63585 0.63585
#> [127] 0.63585 0.93448 0.74086 0.74086 0.74086 0.96808 0.85873 0.85873 0.85873
#> [136] 0.89703 0.89703 0.63585 0.63585 0.63585 0.96808 0.96808 0.85873 0.85873
#> [145] 0.85873 0.93448 0.74086 0.89703 0.89703 0.63585 0.63585 0.96808 0.96808
#> [154] 0.85873 0.89703 0.89703 0.63585 0.96808 0.96808 0.85873 0.85873 0.85873
#> [163] 0.93448 0.93448 0.74086 0.74086 0.74086 0.96808 0.96808 0.85873 0.85873
#> [172] 0.85873 0.93448 0.74086 0.89703 0.89703 0.63585 0.63585 0.63585 0.93448
#> [181] 0.93448 0.74086 0.74086 0.96808 0.96808 0.85873 0.85873 0.85873 0.89703
#> [190] 0.89703 0.63585 0.63585 0.63585 0.93448 0.93448 0.74086 0.74086 0.74086
#> [199] 0.89703 0.63585 0.63585 0.93448 0.93448 0.74086 0.74086 0.74086 0.89703
#> [208] 0.89703 0.63585 0.63585 0.93448 0.93448 0.74086 0.74086 0.74086 0.93448
#> [217] 0.93448 0.74086 0.74086 0.74086
#> attr(,"label")
#> [1] "Predicted values"
predict(fit, bacteria, level = 1, type="response")
#>     X01     X01     X01     X01     X02     X02     X02     X02     X03     X03 
#> 0.98284 0.98284 0.91989 0.91989 0.90508 0.90508 0.65649 0.65649 0.97240 0.97240 
#>     X03     X03     X03     X04     X04     X04     X04     X04     X05     X05 
#> 0.87597 0.87597 0.87597 0.98515 0.98515 0.93008 0.93008 0.93008 0.98515 0.98515 
#>     X05     X05     X05     X06     X06     X06     X06     X07     X07     X07 
#> 0.93008 0.93008 0.93008 0.96628 0.96628 0.85170 0.85170 0.72917 0.72917 0.35050 
#>     X07     X07     X08     X08     X08     X08     X08     X09     X09     X09 
#> 0.35050 0.35050 0.94268 0.94268 0.76725 0.76725 0.76725 0.98515 0.98515 0.93008 
#>     X09     X09     X10     X10     X11     X11     X11     X11     X11     X12 
#> 0.93008 0.93008 0.96403 0.84307 0.98515 0.98515 0.93008 0.93008 0.93008 0.83349 
#>     X12     X12     X12     X12     X13     X13     X13     X13     X13     X14 
#> 0.83349 0.50082 0.50082 0.50082 0.98515 0.98515 0.93008 0.93008 0.93008 0.89072 
#>     X14     X14     X15     X15     X15     X15     X15     X16     X16     X16 
#> 0.89072 0.62032 0.97240 0.97240 0.87597 0.87597 0.87597 0.92878 0.92878 0.72328 
#>     X16     X16     X17     X17     X17     X17     X17     X18     X18     X18 
#> 0.72328 0.72328 0.94268 0.94268 0.76725 0.76725 0.76725 0.70709 0.70709 0.32608 
#>     X18     X18     X19     X19     X19     X19     X19     X20     X20     X20 
#> 0.32608 0.32608 0.87030 0.87030 0.57355 0.57355 0.57355 0.97363 0.97363 0.88096 
#>     X20     X21     X21     X21     X21     X21     Y01     Y01     Y01     Y01 
#> 0.88096 0.98515 0.98515 0.93008 0.93008 0.93008 0.98515 0.98515 0.93008 0.93008 
#>     Y01     Y02     Y02     Y02     Y02     Y02     Y03     Y03     Y03     Y03 
#> 0.93008 0.76080 0.76080 0.38931 0.38931 0.38931 0.84872 0.84872 0.52930 0.52930 
#>     Y03     Y04     Y04     Y04     Y04     Y05     Y05     Y05     Y06     Y06 
#> 0.52930 0.57345 0.57345 0.21227 0.21227 0.71445 0.71445 0.33400 0.98284 0.98284 
#>     Y06     Y06     Y07     Y07     Y07     Y07     Y07     Y08     Y08     Y08 
#> 0.91989 0.91989 0.83349 0.83349 0.50082 0.50082 0.50082 0.92384 0.70857 0.70857 
#>     Y08     Y09     Y09     Y09     Y09     Y10     Y10     Y10     Y10     Y10 
#> 0.70857 0.98473 0.92819 0.92819 0.92819 0.91883 0.91883 0.69409 0.69409 0.69409 
#>     Y11     Y11     Y11     Y11     Y11     Y12     Y12     Y13     Y13     Y13 
#> 0.98515 0.98515 0.93008 0.93008 0.93008 0.96403 0.84307 0.57345 0.57345 0.21227 
#>     Y13     Y14     Y14     Y14     Z01     Z01     Z01     Z02     Z02     Z02 
#> 0.21227 0.97934 0.97934 0.90477 0.95563 0.95563 0.81193 0.98515 0.98515 0.93008 
#>     Z02     Z02     Z03     Z03     Z03     Z03     Z03     Z05     Z05     Z05 
#> 0.93008 0.93008 0.97797 0.97797 0.89896 0.89896 0.89896 0.87030 0.87030 0.57355 
#>     Z05     Z05     Z06     Z06     Z07     Z07     Z07     Z07     Z07     Z09 
#> 0.57355 0.57355 0.83065 0.49575 0.83349 0.83349 0.50082 0.50082 0.50082 0.97363 
#>     Z09     Z09     Z09     Z10     Z10     Z10     Z10     Z10     Z11     Z11 
#> 0.97363 0.88096 0.88096 0.98515 0.98515 0.93008 0.93008 0.93008 0.97240 0.97240 
#>     Z11     Z11     Z11     Z14     Z14     Z14     Z14     Z14     Z15     Z15 
#> 0.87597 0.87597 0.87597 0.92878 0.92878 0.72328 0.72328 0.72328 0.96439 0.84442 
#>     Z15     Z19     Z19     Z19     Z19     Z19     Z20     Z20     Z20     Z20 
#> 0.84442 0.97797 0.97797 0.89896 0.89896 0.89896 0.76205 0.76205 0.39095 0.39095 
#>     Z24     Z24     Z24     Z24     Z24     Z26     Z26     Z26     Z26     Z26 
#> 0.84872 0.84872 0.52930 0.52930 0.52930 0.92878 0.92878 0.72328 0.72328 0.72328 
#> attr(,"label")
#> [1] "Predicted values"