Fork of the msm R package for continuous-time multi-state modelling of panel data implementing a zero-inflated negative binomial model.
- Added a zero-inflated negative binomial observation model (hmmZINBinom)
- Parameters:
disp: dispersionprob: success probabilitybernpi: probability of an excess zero
This extends the set of available observation models in msm, allowing you to model overdispersed counts with extra zeros.
install.packages("devtools") # if devtools not already installed
devtools::install_github('da-wi/msm')# Define a ZINB observation model
model_zeroinflnegbinom <- list(
hmmMV(hmmZINBinom(disp = 10, prob = 0.4, bernpi = 0.1),
hmmZINBinom(disp = 3, prob = 0.3, bernpi = 0.16),
hmmZINBinom(disp = 5, prob = 0.6, bernpi = 0.7),
hmmZINBinom(disp = 2, prob = 0.3, bernpi = 0.5)),
hmmMV(hmmZINBinom(disp = 7, prob = 0.3, bernpi = 0.1),
hmmZINBinom(disp = 3, prob = 0.3, bernpi = 0.16),
hmmZINBinom(disp = 5, prob = 0.6, bernpi = 0.2),
hmmZINBinom(disp = 4, prob = 0.3, bernpi = 0.1))
)
# Fit the model to data
fit <- msm(state ~ time, subject = id, data = mydata, hmodel = model_zeroinflnegbinom)
summary(fit)
https://github.com/chjackson/msm
Multi-state modelling with msm: material from a web-based training course
If you used this package, please cite:
- Jackson, C. (2011). Multi-state models for panel data: the msm package for R. Journal of statistical software, 38, 1-28.
- Willinger, D., & Stieger, S. (2025). Bluetooth-sensed social presence is associated with immediate vigor and delayed fatigue: A multi-method time series analysis. iScience, 28(6).