Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getRefit

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

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))

DHARMa

Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models

v0.4.1
GPL (>= 3)
Authors
Florian Hartig [aut, cre] (<https://orcid.org/0000-0002-6255-9059>), Lukas Lohse [ctb]
Initial release
2021-04-8

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.