getRefit {DHARMa} | R Documentation |
Get model refit
Description
Wrapper to refit a fitted model
checks if the fitted model excluded NA values
Usage
getRefit(object, newresp, ...)
## Default S3 method:
getRefit(object, newresp, ...)
## S3 method for class 'lm'
getRefit(object, newresp, ...)
## S3 method for class 'glmmTMB'
getRefit(object, newresp, ...)
## S3 method for class 'HLfit'
getRefit(object, newresp, ...)
## S3 method for class 'MixMod'
getRefit(object, newresp, ...)
Arguments
object |
a fitted model |
newresp |
the new response that should be used to refit the model |
... |
additional parameters to be passed on to the refit or update class that is used to refit the model |
Details
The purpose of this wrapper is to standardize the refit of a model. The behavior of this function depends on the supplied model. When available, it uses the refit method, otherwise it will use update. For glmmTMB: since version 1.0, glmmTMB has a refit function, but this didn't work, so I switched back to this implementation, which is a hack based on the update function.
Checks if the fitted model excluded NA values
Author(s)
Florian Hartig
See Also
getObservedResponse
, getSimulations
, getFixedEffects
Examples
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)
# 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))
[Package DHARMa version 0.4.6 Index]