Learn R Programming

AICcmodavg (version 1.35)

predictSE.gls: Computing Predicted Values and Standard Errors

Description

Function to compute predicted values based on linear predictor and associated standard errors from a generalized least squares model.

Usage

predictSE.gls(mod, newdata, se.fit = TRUE, print.matrix = FALSE)

Arguments

mod
an object of class 'gls' containing the output of a model.
newdata
a data frame with the same structure as that of the original data frame for which we want to make predictions.
se.fit
logical. If TRUE, compute standard errors on predictions.
print.matrix
logical. If TRUE, the output is returned as a matrix, with predicted values and standard errors in columns. If FALSE, the output is returned as a list.

Value

  • 'predictSE.gls' returns requested values either as a matrix ('print.matrix = TRUE') or list ('print.matrix = FALSE') with components:
  • fitthe predicted values.
  • se.fitthe standard errors of the predicted values (if 'se.fit = TRUE').

Details

'predictSE.gls' computes predicted values based on the linear predictor and associated standard errors, excluding the correlation or variance structure of the model. Standard errors are approximated using the delta method (Oehlert 1992).

References

Gelman, A., Hill, J. (2007) Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press: New York. Oehlert, G. W. (1992) A note on the delta method. American Statistician 46, 27--29.

See Also

gls, predict.gls

Examples

Run this code
##Orthodont data from Pinheiro and Bates (2000) revisited
require(nlme)
m1 <- gls(distance ~ age, correlation = corCompSymm(value = 0.5, form = ~ 1 | Subject),
          data = Orthodont, method= "ML")
##compare against lme fit
  identical(logLik(m1),
  logLik(lme(distance ~ age, random = ~1 | Subject, data = Orthodont,
          method= "ML")))
  ##both are identical

##compute predictions and SE's for different ages
predictSE.gls(m1, newdata = data.frame(age = c(8, 10, 12, 14)))

Run the code above in your browser using DataLab