| getFitted | R Documentation |
Wrapper to get the fitted/predicted response of the model at the response scale.
getFitted(object, ...)
## Default S3 method:
getFitted(object, ...)
## S3 method for class 'gam'
getFitted(object, ...)
## S3 method for class 'HLfit'
getFitted(object, ...)
## S3 method for class 'MixMod'
getFitted(object, ...)
## S3 method for class 'phylolm'
getFitted(object, ...)
## S3 method for class 'phyloglm'
getFitted(object, ...)
## S3 method for class 'brmsfit'
getFitted(object, ...)
object |
a fitted model. |
... |
additional parameters to be passed on, usually to the simulate function of the respective model class. |
The purpose of this wrapper is to extract the fitted values, which is implemented via predict(model, type = "response") for most model classes.
If you implement this function for a new model class, you should include an option to modify which random effects (REs) are included in the predictions. If this option is not available, it is essential that predictions are provided marginally/unconditionally, i.e. without the RE estimates (because of https://github.com/florianhartig/DHARMa/issues/43), which corresponds to re-form = ~0 in lme4.
Florian Hartig
getObservedResponse, getSimulations, getRefit, getFixedEffects
testData = createData(sampleSize = 400, family = gaussian())
fittedModel <- lm(observedResponse ~ Environment1 , data = testData)
# response that was used to fit the model
getObservedResponse(fittedModel)
# predictions of the model for these points
getFitted(fittedModel)
# predictions on the scale of the observed response
# (differs from getFitted only for k/n binomial models)
getFittedResponse(fittedModel)
# extract simulations from the model as matrix
getSimulations(fittedModel, nsim = 2)
# extract simulations from the model for refit (often requires different structure)
x = getSimulations(fittedModel, nsim = 2, type = "refit")
getRefit(fittedModel, x[[1]])
getRefit(fittedModel, getObservedResponse(fittedModel))
# get data frame that was used to fit the model
getData(fittedModel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.