R: Provides predicted values for sample or new data. New...
modelPredictions
R Documentation
Provides predicted values for sample or new data. New predictions include SEs
Description
If no data are provided, modelPredictions returns a numeric vector predicted values for the sample, functioning as a simple wrapper for fitted.values(). If a dataframe with new values for Xs are provided, modelPredictions adds prediced values and SEs for these new data to the dataframe using predict() from car package.
Usage
modelPredictions(Model, Data=NULL, Label = NULL, Type = 'response')
Arguments
Model
a linear model, produced by lm.
Data
a dataframe containg cases for predictions. Must include all regressors from model. Default is NULL with predictions returned for the current sample.
Label
A string label to append to variable names for predicted values, CIs and SE. Default is NULL with no append
Type
'response' or 'link'. Used only for glm objects. see predict()
Value
If Data=NULL, returns a numeric vector of predicted values for sample. If Data are provided, adds four new columns at the front of the dataframe These variables are named Predicted (prediced value), CILo (lower bound of - 1 SE from Predicted), CIHi (upper bound of + 1 SE), and SE (Standard error of predicted value). NOTE: For GLM, +-1 SE are calculated on the link scale and then converted to the response scale (which will be asymetric) if Type = response.
If Label is not NULL, than Label is appended to end of these four variable names.