View source: R/mclogit-dispersion.R
| dispersion | R Documentation |
The function dispersion() extracts the dispersion parameter
from a multinomial logit model or computes a dispersion parameter
estimate based on a given method. This dispersion parameter can
be attached to a model using update(). It can also given as an
argument to summary().
dispersion(object,method, ...) ## S3 method for class 'mclogit' dispersion(object,method=NULL, ...)
object |
an object that inherits class |
method |
a character string, either |
... |
other arguments, ignored or passed to other methods. |
Afroz, Farzana, Matt Parry, and David Fletcher. (2020). "Estimating Overdispersion in Sparse Multinomial Data." Biometrics 76(3): 834-842. doi: 10.1111/biom.13194.
library(MASS) # For 'housing' data
# Note that with a factor response and frequency weighted data,
# Overdispersion will be overestimated:
house.mblogit <- mblogit(Sat ~ Infl + Type + Cont, weights = Freq,
data = housing)
dispersion(house.mblogit,method="Afroz")
dispersion(house.mblogit,method="Deviance")
summary(house.mblogit)
phi.Afroz <- dispersion(house.mblogit,method="Afroz")
summary(house.mblogit, dispersion=phi.Afroz)
summary(update(house.mblogit, dispersion="Afroz"))
# In order to be able to estimate overdispersion accurately,
# data like the above (which usually comes from applying
# 'as.data.frame' to a contingency table) the model has to be
# fitted with the optional argument 'from.table=TRUE':
house.mblogit.corrected <- mblogit(Sat ~ Infl + Type + Cont, weights = Freq,
data = housing, from.table=TRUE,
dispersion="Afroz")
# Now the estimated dispersion parameter is no longer larger than 20,
# but just bit over 1.0.
summary(house.mblogit.corrected)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.