{"id":16036615,"url":"https://github.com/sebkrantz/dfms","last_synced_at":"2025-04-10T03:54:02.126Z","repository":{"id":50701190,"uuid":"399755644","full_name":"SebKrantz/dfms","owner":"SebKrantz","description":"Dynamic Factor Models for R","archived":false,"fork":false,"pushed_at":"2025-03-22T10:53:42.000Z","size":27377,"stargazers_count":33,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T03:53:51.286Z","etag":null,"topics":["dynamic-factor-models","rstats","time-series"],"latest_commit_sha":null,"homepage":"https://sebkrantz.github.io/dfms/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SebKrantz.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json"}},"created_at":"2021-08-25T09:04:15.000Z","updated_at":"2025-03-22T11:00:52.000Z","dependencies_parsed_at":"2024-06-09T13:39:30.223Z","dependency_job_id":"12e14935-2cfa-4e66-aed6-92cecf70e9d3","html_url":"https://github.com/SebKrantz/dfms","commit_stats":{"total_commits":245,"total_committers":1,"mean_commits":245.0,"dds":0.0,"last_synced_commit":"dd930a639e5216b30565339995b93270ece918ab"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebKrantz%2Fdfms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebKrantz%2Fdfms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebKrantz%2Fdfms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebKrantz%2Fdfms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SebKrantz","download_url":"https://codeload.github.com/SebKrantz/dfms/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154999,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-factor-models","rstats","time-series"],"created_at":"2024-10-08T22:06:27.065Z","updated_at":"2025-04-10T03:54:02.104Z","avatar_url":"https://github.com/SebKrantz.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **dfms**: Dynamic Factor Models for R\n\u003c!-- badges: start --\u003e\n[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/556_status.svg)](https://github.com/ropensci/software-review/issues/556)\n[![R-CMD-check](https://github.com/SebKrantz/dfms/workflows/R-CMD-check/badge.svg)](https://github.com/SebKrantz/dfms/actions)\n[![dfms status badge](https://sebkrantz.r-universe.dev/badges/dfms)](https://sebkrantz.r-universe.dev)\n[![CRAN status](https://www.r-pkg.org/badges/version/dfms)](https://cran.r-project.org/package=dfms) \n[![cran checks](https://badges.cranchecks.info/worst/dfms.svg)](https://cran.r-project.org/web/checks/check_results_dfms.html)\n![downloads per month](https://cranlogs.r-pkg.org/badges/dfms?color=blue)\n![downloads](https://cranlogs.r-pkg.org/badges/grand-total/dfms?color=blue)\n[![Codecov test coverage](https://codecov.io/gh/SebKrantz/dfms/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SebKrantz/dfms?branch=main)\n[![minimal R version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/)\n[![dependencies](https://tinyverse.netlify.app/badge/dfms)](https://CRAN.R-project.org/package=dfms)\n\u003c!-- [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) --\u003e\n\u003c!-- badges: end\n\n\u003c!-- **NOTE**: This package is under [rOpenSci Statistical Software Peer Review](https://stats-devguide.ropensci.org/). Peer review might result in changes to the API. --\u003e\n\u003c!--\nThe package is fully functional though, and you are very welcome to install it using `remotes::install_github(\"SebKrantz/dfms\")` and give feedback. --\u003e\n\n*dfms* provides efficient estimation of Dynamic Factor Models via the EM Algorithm. Estimation can be done in 3 different ways following:\n\n- Doz, C., Giannone, D., \u0026 Reichlin, L. (2011). A two-step estimator for large approximate dynamic factor models based on Kalman filtering. *Journal of Econometrics, 164*(1), 188-205. \u003cdoi:10.1016/j.jeconom.2011.02.012\u003e \n\n- Doz, C., Giannone, D., \u0026 Reichlin, L. (2012). A quasi-maximum likelihood approach for large, approximate dynamic factor models. *Review of Economics and Statistics, 94*(4), 1014-1024. \u003cdoi:10.1162/REST_a_00225\u003e\n\n- Banbura, M., \u0026 Modugno, M. (2014). Maximum likelihood estimation of factor models on datasets with arbitrary pattern of missing data. *Journal of Applied Econometrics, 29*(1), 133-160. \u003cdoi:10.1002/jae.2306\u003e\n\nThe default is `em.method = \"auto\"`, which chooses `\"BM\"` following Banbura \u0026 Modugno (2014) with missing data or mixed frequency, and `\"DGR\"` following Doz, Giannone \u0026 Reichlin (2012) otherwise. Using `em.method = \"none\"` generates Two-Step estimates following Doz, Giannone \u0026 Reichlin (2011). This is extremely efficient on bigger datasets. PCA and Two-Step estimates are also reported in EM-based methods. All methods support missing data, but `em.method = \"DGR\"` does not model them in EM iterations.\n\n### Comparison with Other R Packages\n\n*dfms* is intended to provide a simple, numerically robust, and computationally efficient baseline implementation of (linear Gaussian) Dynamic Factor Models for R, allowing straightforward application to various contexts such as time series dimensionality reduction and forecasting. The implementation is based on efficient C++ code, making *dfms* orders of magnitude faster than packages that can be used to fit dynamic factor models such as [*MARSS*](\u003chttps://CRAN.R-project.org/package=MARSS\u003e), or [*nowcasting*](\u003chttps://github.com/nmecsys/nowcasting\u003e) and [*nowcastDFM*](\u003chttps://github.com/dhopp1/nowcastDFM\u003e) geared to mixed-frequency nowcasting applications - supporting blocking of variables into different groups for which factors are to be estimated and evaluation of news content. For large-scale nowcasting models the [`DynamicFactorMQ`](https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.dynamic_factor_mq.DynamicFactorMQ.html) class in the `statsmodels` Python library is probably the most robust implementation - see the [example](http://www.chadfulton.com/topics/statespace_large_dynamic_factor_models.html) by Chad Fulton.   \u003c!-- , and EM adjustments for variables at different frequencies. *dfms* with `em.method = \"BM\"` does allow mixed-frequency data but performs no specific adjustments for the frequency of the data^[All series are weighted equally, and the prevalence of missing values in lower-frequency series downweights them. To remedy this lower frequency series could be included multiple times in the dataset e.g. include a quarterly series 3 times in a monthly dataset.]. *dfms* currently also does not allow residual autocorrelation in the estimation (i.e. it cannot estimate *approximate factor models*), but the addition of this feature is planned. --\u003e\nThe *dfms* package is not intended to fit more general forms of the state space model like [*MARSS*](\u003chttps://CRAN.R-project.org/package=MARSS\u003e).\n\n\u003c!-- or advanced specifications of Dynamic Factor Models tailored to mixed-frequency nowcasting applications such as [*nowcasting*](\u003chttps://github.com/nmecsys/nowcasting\u003e) and [*nowcastDFM*](\u003chttps://github.com/dhopp1/nowcastDFM\u003e). Such software could however benefit from the functions and methods provided in *dfms*, most notably *dfms* exports stationary Kalman Filters and Smoothers used in nowcasting applications, that are noticeably faster than the more general implementations provided by the [*FKF*](\u003chttps://CRAN.R-project.org/package=FKF\u003e) package. --\u003e\n\n\u003c!-- Estimation with *dfms* also requires stationary data of a single frequency, and assumes time-invariant system matrices and classical assumptions (i.e. the 'exact factor model', assuming away residual autocorrelation in the observation equation). --\u003e\n\n### Installation \n\n```r\n# CRAN\ninstall.packages(\"dfms\")\n\n# Development Version\ninstall.packages('dfms', repos = c('https://sebkrantz.r-universe.dev', 'https://cloud.r-project.org'))\n\n```\n### Usage Example \n```r\nlibrary(dfms)\n\n# Fit DFM with 6 factors and 3 lags in the transition equation\nmod = DFM(diff(BM14_M), r = 6, p = 3) \n\n# 'dfm' methods\nsummary(mod)\nplot(mod)\nas.data.frame(mod)\n\n# Forecasting 20 periods ahead\nfc = predict(mod, h = 20)\n\n# 'dfm_forecast' methods\nprint(fc)\nplot(fc)\nas.data.frame(fc)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebkrantz%2Fdfms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebkrantz%2Fdfms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebkrantz%2Fdfms/lists"}