Skip to content

Bayesian dynamic factor model estimation and predictive statistics including nowcasting and forecasting

License

Notifications You must be signed in to change notification settings

srlanalytics/bdfm

Repository files navigation

bdfm

Bayesian dynamic factor model estimation in R.

Build Status codecov

bdfm estimates dynamic factor models by simulation using the Durbin and Koopman (2012) disturbance smoother and returns estimated factors, predicted values of observables, posterior distributions for predicted values (optional), and forecast updates by series (optional). Maximum likelihood estimation via Watson and Engle (1983) is also supported. Input data may be noisy, have missing values, or “ragged edges” due to different start or end dates.

Installation

To install the development version:

remotes::install_github("srlanalytics/bdfm")

Basic Use

Estimate a model with one factor and two lags in the transition equation:

library(bdfm)
dta <- cbind(fdeaths, mdeaths)
m <- dfm(dta, forecast = 2)

Input data should be an object of class "ts". If the tsbox package is installed, any ts-boxable time series objects can be supplied, such as "xts", "zoo", "timeSeries" or "data.frame".

Extract the resulting series, using predict().

plot(predict(m))

Or have a look at the estimated factors, using factors():

plot(factors(m))

Estimation Details

You can find details on estimation routines and derivations in the short book Practical Implementation of Factor Models.

Related Packages

  • MARSS, dynfactoR
    Offer maximum likelihood estimation only
  • greta
    Uses Hamiltonian Monte Carlo simulation find posterior distributions of model parameters for whatever model the user specifies. It looks superb, but being general purpose it is much more difficult to implement DFMs than with bdfm.

About

Bayesian dynamic factor model estimation and predictive statistics including nowcasting and forecasting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published