Learn R Programming

DHARMa (version 0.4.1)

getRefit: Get model refit

Description

Wrapper to refit a fitted model

checks if the fitted model excluded NA values

Usage

getRefit(object, newresp, ...)

# S3 method for default getRefit(object, newresp, ...)

# S3 method for lm getRefit(object, newresp, ...)

# S3 method for glmmTMB getRefit(object, newresp, ...)

# S3 method for HLfit getRefit(object, newresp, ...)

# S3 method for 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

See Also

getObservedResponse, getSimulations, getFixedEffects

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab