Code Monkey home page Code Monkey logo

nowcastdfm's Introduction

nowcastDFM

Run dynamic factor models (DFM) in R. Adapted from Bok et al. 2017, MATLAB code. The package provides the ability to estimate a DFM model using the expectation–maximization method, obtain predictions from estimated models, and obtain the impact of new data releases on model predictions. On CRAN.

Installation

install.packages("nowcastDFM")`

If this does not work, you can install directly from Github with:

install.packages("devtools")
devtools::install_github("dhopp1/nowcastDFM")

Functionality

  • dfm: estimate a dynamic factor model using the EM method. ?dfm for more info.
  • predict_dfm: obtain predictions from a previously estimated model. ?predict_dfm for more info.
  • gen_news: obtain impacts of new data releases and revisions on the forecast of a target variable. ?gen_news for more info.

Example

Given data is a dataframe (not a tibble) with a date column and 4 columns for various seasonally adjusted growth rates of economic series with missing values of NA:

library(nowcastDFM)

# estimate a DFM with one block for all variables
output_dfm <- dfm(data) 

# estimate a DFM with two different blocks
blocks <- data.frame(block_1 = c(1,1,1,0), block_2 = c(0,0,1,1)) # defining two blocks
output_dfm <- dfm(data, blocks = blocks)

# get predictions from estimated DFM for the following 3 months
# new data is dataframe with same columns as data the model was trained on, but newer data
predictions <- predict_dfm(new_data, output_dfm, months_ahead = 3)

# get impact of new data on predictions for a particular variable and time period
# old_data and new_data are dataframes with same columns as the data the model was trained on, but with older and newer data
news <- gen_news(old_data, new_data, output_dfm, target_variable = "target_name", target_period = "2020-01-01")

nowcastdfm's People

Contributors

dhopp1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nowcastdfm's Issues

Error in zeros(nM, 5 * nQ) : dimensions must be a positive quantity

Good day!

library(nowcastDFM)

estimate a DFM with one block for all variables

output_dfm <- dfm(data, blocks = NA, p = 1, max_iter = 5000, threshold = 1e-05)
Error in zeros(nM, 5 * nQ) : dimensions must be a positive quantity

Tell me, please, what could be the problem?
I tried version R 3.6.1 and R 4.1.3, different versions of matlab package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.