Learn R Programming

DHARMa (version 0.2.0)

refit.glmmTMB: Refit a Model with a Different Response

Description

Refit a Model with a Different Response

Usage

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

Arguments

object

a fitted model

newresp

a new response

...

further arguments, no effect implemented for this S3 class

Examples

Run this code
# NOT RUN {
testData = createData(sampleSize = 200, family = poisson())

# examples of refit with different model classes
library(lme4)
library(mgcv)
library(glmmTMB)

fittedModel <- lm(observedResponse ~ Environment1 , data = testData)
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])

fittedModel <- glm(observedResponse ~ Environment1 , data = testData, family = "poisson")
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])

fittedModel <- mgcv::gam(observedResponse ~ s(Environment1) , data = testData, family = "poisson")
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])

fittedModel <- lme4::lmer(observedResponse ~ Environment1 + (1|group) , data = testData)
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])

fittedModel <- lme4::glmer(observedResponse ~ Environment1 + (1|group) , data = testData, 
                           family = "poisson")
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])

fittedModel <- glmmTMB::glmmTMB(observedResponse ~ Environment1 + (1|group) , data = testData)
newResponse = simulate(fittedModel)
refit(fittedModel, newResponse[,1])
# }

Run the code above in your browser using DataLab