| f2Local | R Documentation |
f^2Calculate local f^2 for (generalized) linear (mixed) models
f2Local(object, method, ...)
## S3 method for class 'lm'
f2Local(object, method = "r.squared", ...)
## S3 method for class 'glm'
f2Local(object, method = "r2", ...)
## S3 method for class 'vglm'
f2Local(object, method = "mcfadden", ...)
## S3 method for class 'glmmTMB'
f2Local(object, method = "nakagawa", type = "marginal", ...)
object |
a model object (currently supported: |
method |
method for calculation of |
... |
currently not used |
type |
indicate whether the marginal (fixed effects only) or the conditional (fixed + random effects)
|
The following methods can be specified:
lm objects: r.squared and adj.r.squared as extracted from the lm object.
glm objects: mcfadden, nagelkerke, coxsnell, tjur and efron, as implemented
in the performance package.
vglm objects: mcfadden, nagelkerke, coxsnell, tjur and efron, as implemented
in the R2.vglm function.
glmmTMB objects: nakagawa, as implemented in the performance package. It can also be
specified whether the marginal or the conditional R^2 should be used, however only the
marginal R^2 would make sense.
Note that for multinomial models, using method="efron" gives questionable with glm objects and
is not possible for vglm objects. For glm objects, method=coxsnell cannot be used when the
response is not binary.
f2Local returns a list containing f^2 values for every parameter in a model. For the glmmTMB
class, a list of all reduced models is returned as well. In a future version, this will be available for other classes as well.
f2Local(lm): Method for lm object
f2Local(glm): Method for glm object
f2Local(vglm): Method for vglm object
f2Local(glmmTMB): Method for glmmTMB object
Mathijs Deen
# linear model
model1 <- lm(mpg ~ cyl + wt*drat, data = mtcars)
f2Local(model1)
# generalized linear model (glm)
model2 <- glm(vs ~ cyl*wt + mpg, data = mtcars, family = "binomial")
f2Local(model2, method = "coxsnell")
# generalized linear model (vglm)
if(require(VGAM)){
pneumo <- transform(pneumo, let = log(exposure.time))
model3 <- vglm(cbind(normal, mild, severe) ~ let, multinomial, pneumo)
f2Local(model3)
}
# generalized linear mixed model
if(require(ClusterBootstrap) & require(glmmTMB)){
model4 <- glmmTMB(pos ~ treat*time + (1 + time | id), data = medication)
f2Local(model4)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.