f2Local {MDMA}R Documentation

Local f^2

Description

Calculate local f^2 for (generalized) linear (mixed) models

[Experimental]

Usage

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", ...)

Arguments

object

a model object (currently supported: lm, glm, vglm).

method

method for calculation of R^2, which is needed for the calculation of f^2. See Details.

...

currently not used

type

indicate whether the marginal (fixed effects only) or the conditional (fixed + random effects) R^2 should be used. Default value is marginal, using conditional might be considered ambiguous.

Details

The following methods can be specified:

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.

Value

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.

Methods (by class)

Author(s)

Mathijs Deen

Examples

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


[Package MDMA version 2.0.0 Index]