f2Local {MDMA} | R Documentation |
Local f^2
Description
Calculate local f^2
for (generalized) linear (mixed) models
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: |
method |
method for calculation of |
... |
currently not used |
type |
indicate whether the marginal (fixed effects only) or the conditional (fixed + random effects)
|
Details
The following methods can be specified:
-
lm
objects:r.squared
andadj.r.squared
as extracted from thelm
object. -
glm
objects:mcfadden
,nagelkerke
,coxsnell
,tjur
andefron
, as implemented in theperformance
package. -
vglm
objects:mcfadden
,nagelkerke
,coxsnell
,tjur
andefron
, as implemented in theR2.vglm
function. -
glmmTMB
objects:nakagawa
, as implemented in theperformance
package. It can also be specified whether the marginal or the conditionalR^2
should be used, however only the marginalR^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.
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)
-
f2Local(lm)
: Method forlm
object -
f2Local(glm)
: Method forglm
object -
f2Local(vglm)
: Method forvglm
object -
f2Local(glmmTMB)
: Method forglmmTMB
object
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)
}