Skip to content

da-wi/msm

 
 

Repository files navigation

msm

R-CMD-check

Fork of the msm R package for continuous-time multi-state modelling of panel data implementing a zero-inflated negative binomial model.

📌 Key addition

  • Added a zero-inflated negative binomial observation model (hmmZINBinom)
  • Parameters:
    • disp: dispersion
    • prob: success probability
    • bernpi: probability of an excess zero

This extends the set of available observation models in msm, allowing you to model overdispersed counts with extra zeros.

Installation (development version)

install.packages("devtools") # if devtools not already installed
devtools::install_github('da-wi/msm')

Basic usage

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

Original package

https://github.com/chjackson/msm

Tutorial material on msm

Multi-state modelling with msm: material from a web-based training course

Citation

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

About

Zero-inflated negative binomial model extension of msm R package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 83.0%
  • C 14.1%
  • TeX 1.9%
  • PostScript 1.0%