Code Monkey home page Code Monkey logo

dpca's Introduction

Dynamic Principal Component Analysis and Generalized Dynamic Factor Model Estimation

R-CMD-check Codecov test coverage License

This package provides a fast and reliable implementation of Brillinger's dynamic principal component analysis. The main use case is estimation of Generalized Dynamic Factor Models (Forni & Lippi, 2001, Forni, Hallin, Lippi and Reichlin, 2000).

At its core, this package features multivariate spectral density estimation based on the lag-window estimator. Based on an estimated spectrum, dynamic principal components are computed using an efficient numerical procedure for eigenvalue/eigenvector decomposition (Implicitly Restarted Arnoldi Method).

Moreover, dpca implements the method to select the number of dynamic principal components of Hallin & Liska (2007). Also the information criteria by Bai & Ng, 2003 are implemented, with the additional feature that the constant multplier in the penalty term is chosen in a data-driven way analogously to Hallin & Liska (2007).

Things implemented so far:

  • Estimation of multivariate spectral density using lag-window technique.
  • Fast computation of dynamic eigenvalues/eigenvectors of spectrum using ARPACK.
  • Discrete fourier transformation to obtain filters/transfer functions.
  • The selection criterion of Hallin & Liska (2007) to determine the number of dynamic factors.
  • Ship ARPACK.
  • Interface to common time series data formats (zoo, ts).
  • One-Sided representation of the the dynamic common component using the approach of Forni, Hallin, Lippi, Zaffaroni (2015).
  • Forecasting methods.
  • Model assessment.

We are aware of the R package freqdom, developed by Siegfried Hörmann and Lukas Kidzinsiki which is a pure R implementation. dpca is written mainly in C. Although providing a similiar interface to that of freqdom, dpca has some unique features apart from being much faster.

For instance, the convoluted filter which computes the dynamic common component from the output in freqdom is obtained by filtering the output twice: first to get the inputs (what in freqdom is called "scores" in analogy to their FDA context) and, second these inputs are filtered again to get the dynamic common component ("KLexpansion"). dpca computes the convolution in the frequency domain. The advantage of this approach is that this filter is invariant with respect to multiplications of dynamic eigenvectors by a unit-length complex number.

Installation

dpca depends on ARPACK to compute dynamic eigenvalues/eigenvectors using the Implicitly Restarted Arnoldi Method which is much faster than R's base::eigen() whenever a truncated instead of the full spectral decomposition is required. ARPACK is shipped with dpca.

To install dpca using devtools:

devtools::install_github("https://github.com/christophrust/dpca.git")

Example

set.seed(123456)

## simulate some data
nrx <- 100L
ncx <- 1000L
q <- 4L

epsilon <- matrix(rnorm((ncx + 10) * q), nrow = q)

filter_coefs <- vapply(1:10, function(l) {
  matrix(rnorm(q * nrx, sd = 1/l), nrx, q)
}, matrix(0, nrx, q))

chi1 <- multivariate_filter(epsilon, filter_coefs, 1:10)

x <- chi + rnorm(nrx * ncx, sd = 0.1 * sd(chi))
bw <- floor(ncol(x)^(1/3))

dpc <- dpca(x, q = q, bandwidth = bw)
str(dpc)

dpca's People

Contributors

christophrust avatar

Watchers

James Cloos avatar  avatar

Forkers

allisterh

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.