Dynamic Models with Regime-Switching

Intensive longitudinal data have become increasingly prevalent in various scientific disciplines. Many such data sets are noisy, multivariate, and multi-subject in nature. The change functions may also be continuous, or continuous but interspersed with periods of discontinuities (i.e., showing regime switches). The package 'dynr' (Dynamic Modeling in R) is an R package that implements a set of computationally efficient algorithms for handling a broad class of linear and nonlinear discrete- and continuous-time models with regime-switching properties under the constraint of linear Gaussian measurement functions. The discrete-time models can generally take on the form of a state- space or difference equation model. The continuous-time models are generally expressed as a set of ordinary or stochastic differential equations. All estimation and computations are performed in C, but users are provided with the option to specify the model of interest via a set of simple and easy-to-learn model specification functions in R. Model fitting can be performed using single- subject time series data or multiple-subject longitudinal data. Ou, Hunter, & Chow (2019) provided a detailed introduction to the interface and more information on the algorithms.

This README documents the steps necessary to get dynr cooking. That was the first of many food-based puns. It will not be the last.

Who is this repository for?

This repository is primarily for developers. If you're not currently on the development team but would like to be, please contact Sy-Miin Chow at Pennsylvania State University. You will need

  • Good computer programming skills (R and C preferably)
  • Decent mathematical ability
  • Knowledge of or interest in dynamical systems
  • Some exposure to statistical methods

If you're not a developer and just want to install dynr to run your models, please see the CRAN page including the vignette with installation guidelines.

How do I get set up?

Windows People

  • Summary of set up
  • Configuration
  • Dependencies
  • Database configuration
  • How to run tests
  • Deployment instructions

Mac People

  • Summary of set up
  • Configuration
  • Dependencies
  • Database configuration
  • How to run tests
  • Deployment instructions

Contribution guidelines

  • Writing tests
  • Code review
  • Other guidelines

We primarily use a centralized workflow in git. Occasionally, we employ a feature branch style for larger features that may break the master branch for extended periods of time.

Please follow these basic guidelines when writing commit messages.

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why, not how

We use win-builder to help test the repository prior to submitting a new release to CRAN.

A Note to developers: there is a bug in roxygen2 such that the latest version will not build our documentation. It is a known issue that will be resolved soon. In the meantime, use an older version of the package. Install it with devtools::install_version(package = 'roxygen2',version = '5.0.1', repos = c(CRAN = "https://cran.rstudio.com"))

Who do I talk to?

  • Michael D. Hunter is the Repo owner and admin
  • Sy-Miin Chow is the principle investigator on the grant that funds dynr
  • Other members of the development team include but are not limited to Lu Ou, Meng Chen, Linying Ji, and Hui-Ju Hung

Contact the Repo owner to obtain read and write permissions to this repository.


dynr 0.1.13-4


New features include:

  • You don't need to install R on Windows to C:/R anymore! The default (C:/Program Files/R) now works.
  • New demo for time-varying parameter (TVP) models
  • Several new vignettes covering a range of topics

Bug fixes and performance tweaks include:

  • The deviation form of regimes now displays properly in plotFormula
  • No longer require 'outfile' specification in dynr.model()
  • Fix a pointer addressing issue that could have caused crashes

dynr 0.1.12-5


New features include:

  • New 'verbose' argument to dynr.cook turns off printing of optimization history
  • New demo for Process Factor Analysis (PFA)
  • Regime-switching printing in plotFormula() with new 'printRS' argument

Bug fixes and performance tweaks include:

  • Greatly improved convergence rates for all models
  • Allow full initial covariance estimation
  • Fixed major bug in regime-switching matrix dynamics that formerly crashed R

dynr 0.1.11-8


New features include:

  • Noise printing by plotFormula() function

Bug fixes and performance tweaks include:

  • Fixed innovation vector computation for larger than 1-dimensional observations

dynr 0.1.11-2


New features include:

  • New demo for a linear oscillator with time-varying parameters

Bug fixes and performance tweaks include:

  • Fixed printex output for covariates and deviation form of the initial conditions
  • Fixed memory leak for intercepts in measurement models

dynr 0.1.10


New features include:

  • Use of individual-level covariates in the initial conditions. See ?prep.initial for details.
  • Deviation form of regime-switching models. Seee ?prep.regimes for details.
  • Access to the predicted, filtered, and smoothed latent variable estimates, and other by-products from the regime-switching extended Kalman filter in the 'cooked' model.
  • We now allow calculation of the negative log-likelihood value, the hessian matrix, and the predicted, filtered, and smoothed latent variable estimates at fixed parameter values without parameter optimization.
  • Beta version of a multiple imputation procedure. See ?dynr.mi for details.

Bug fixes and performance tweaks include:

  • Fixed a rounding bug that improves free parameter optimization, especially for models with many observed variables.
  • Improved documentation throughout
  • Added more examples in the help pages

dynr 0.1.9


New features include:

  • A new demo example is added to replicate the results from Yang & Chow (2010) paper.
  • Some standard S3 methods are added for the dynrCook class object.
  • autoplot() is added as an alias for dynr.ggplot().
  • dynr.data() now automatically handles ts class objects and equally spaced data with missingness.

Bug fixes and performance tweaks include:

  • Changes are made to accommodate the new release of ggplot2.

dynr 0.1.8


New features include:

  • None

Bug fixes and performance tweaks include:

  • In single-regime models, free parameters for intercepts and covariate effects in the measurement model can now be properly estimated.
  • Standard errors are more frequently returned
  • Flags indicate problematic standard errors.
  • Warning messages are more helpful regarding standard errors.
  • A weight flag allows easier convergence of multi-subject models.
  • Several new plotting features.

dynr 0.1.7


Initial release to CRAN!

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.16-2 by Michael D. Hunter, 7 months ago

https://dynrr.github.io/, https://github.com/mhunter1/dynr

Browse source code at https://github.com/cran/dynr

Authors: Lu Ou [aut] , Michael D. Hunter [aut, cre] , Sy-Miin Chow [aut] , Linying Ji [aut] , Meng Chen [aut] , Hui-Ju Hung [aut] , Jungmin Lee [aut] , Yanling Li [aut] , Jonathan Park [aut] , Massachusetts Institute of Technology [cph] , S. G. Johnson [cph] , Benoit Scherrer [cph] , Dieter Kraft [cph]

Documentation:   PDF Manual  

Task views: Time Series Analysis

GPL-3 license

Imports MASS, Matrix, numDeriv, xtable, latex2exp, grid, reshape2, plyr, mice, magrittr, Rdpack, methods, fda, car, stringi, tibble, deSolve

Depends on ggplot2

Suggests testthat, roxygen2, knitr, rmarkdown

System requirements: GNU make

See at CRAN