Function to compute predicted values based on linear predictor and associated standard errors from various fitted models.
1.1
predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE,...)## S3 method for class 'gls'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE,...)## S3 method for class 'lme'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, level =0,...)## S3 method for class 'mer'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, level =0, type ="response",...)## S3 method for class 'merMod'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, level =0, type ="response",...)## S3 method for class 'lmerModLmerTest'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, level =0,...)## S3 method for class 'unmarkedFitPCount'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, type ="response", c.hat =1, parm.type ="lambda",...)## S3 method for class 'unmarkedFitPCO'predictSE(mod, newdata, se.fit =TRUE, print.matrix =FALSE, type ="response", c.hat =1, parm.type ="lambda",...)
Arguments
mod: an object of class gls, lme, mer, merMod, lmerModLmerTest, unmarkedFitPCount, or unmarkedFitPCO 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.
level: the level for which predicted values and standard errors are to be computed. The current version of the function only supports predictions for the populations excluding random effects (i.e., level = 0).
type: specifies the type of prediction requested. This argument can take the value response or link, for predictions on the scale of the response variable or on the scale of the linear predictor, respectively.
c.hat: value of overdispersion parameter (i.e., variance inflation factor) such as that obtained from Nmix.gof.test. If c.hat > 1, predictSE will multiply the variance-covariance matrix of the predictions by this value (i.e., SE's are multiplied by sqrt(c.hat)). High values of c.hat (e.g., c.hat > 4) may indicate that model structure is inappropriate.
parm.type: the parameter for which predictions are made based on the N-mixture model of class unmarkedFitPCount or unmarkedFitPCO classes.
...: additional arguments passed to the function.
Details
predictSE computes predicted values and associated standard errors. Standard errors are approximated using the delta method (Oehlert 1992). Predictions and standard errors for objects of gls class and mixed models of lme, mer, merMod, lmerModLmerTest classes exclude the correlation or variance structure of the model.
predictSE computes predicted values on abundance and standard errors based on the estimates from an unmarkedFitPCount or unmarkedFitPCO object. Currently, only predictions on abundance (i.e., parm.type = "lambda") with the zero-inflated Poisson distribution is supported. For other parameters or distributions for models of unmarkedFit classes, use predict from the unmarked package.
Returns
predictSE returns requested values either as a matrix (print.matrix = TRUE) or list (print.matrix = FALSE) with components:
fit: the predicted values.
se.fit: the standard errors of the predicted values (if se.fit = TRUE).
Note
For standard errors with better properties, especially for small samples, one can opt for simulations (see Gelman and Hill 2007), or nonparametric bootstrap (Efron and Tibshirani 1998).
References
Efron, B., Tibshirani, R. J. (1998) An Introduction to the Bootstrap. Chapman & Hall/CRC: New York.
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.