mod2obspred: Extract observed and predicted, or predictor, values from a model object.
Description
This function takes a model object and returns the observed and (optionally) the predicted (fitted) values from that model; or the values of the predictors in the model.
A data frame with one column containing the observed and (if obs.only=FALSE, the default) another column containing the predicted values from 'model'; or a data frame with the 'x', 'data' or predictor values from 'model' (if x.only=TRUE).
Arguments
model
a model object of class "glm", "gam", "gbm", "GBMFit", "randomForest" or "bart" from which the response variable and fitted (predicted) values can be extracted. Note that, for "randomForest" models, only the out-of-bag prediction is available from the model object (see ?randomForest::predict.randomForest), so here you'll get different results if you provide 'model' or the modelled 'obs' (and corresponding 'pred') values.
obs.only
logical value (default FALSE) indicating whether only 'obs' should be obtained. Saves computing time when 'pred' not needed. Used e.g. by prevalence).
x.only
logical value (default FALSE) indicating whether only 'x' or 'data' (the predictor values) should be obtained. Used e.g. by varImp if imp.type = "permutation".