Giter VIP home page Giter VIP logo

partialar's Introduction

partialAR

R package for fitting the partially autoregressive model

The partially autoregressive model is a time series model that is given by the following specification:

   X[t] = M[t] + R[t]
   M[t] = rho * M[t-1] + epsilon_M[t]
   R[t] = R[t-1] + epsilon_R[t]
   epsilon_M[t] ~ NID(0, sigma_M^2)
   epsilon_R[t] ~ NID(0, sigma_R^2)

Thus, the series X[t] is a sum of a random walk R[t], representing the permanent component, and a mean-reverting series M[t], representing the transient component.

This model was previously studied in Summers [1] and also in Poterba and Summers [2] in their often cited work on mean reversion in the S&P 500.

One example application of the partially autoregressive model is as follows. In the calendar year 2014, the behavior of Coca-Cola (KO) and Pepsi (PEP) were quite similar, as evidenced by charts of their stock prices. Despite this, cointegration tests find that they were not cointegrated. Thus, the question arises, "How far were they from being cointegrated?" The partially autoregressive model gives a possible answer to this question. When a partially autoregressive model is fit, it is found that 90% of the variance of the daily fluctuations of the residual series is due to a transient mean-reverting component, while 10% of the variance is due to a permanent random walk component.

The partialAR package provides routines for estimating the parameters of a partially autoregressive model and for testing goodness of fit.

A companion paper [3] can be found on SSRN.

[1] Summers, Lawrence H. Does the stock market rationally reflect fundamental values?. The Journal of Finance 41.3 (1986): 591-601.

[2] Poterba, James M., and Lawrence H. Summers. Mean reversion in stock prices: Evidence and implications. Journal of Financial Economics} 22.1 (1988): 27-59.

[3] Clegg, Matthew. Modeling Time Series with Both Permanent and Transient Components Using the Partially Autoregressive Model (January 28, 2015). Available at SSRN: http://ssrn.com/abstract=2556957

partialar's People

Contributors

matthewclegg avatar

Stargazers

Ricardo Henriquez avatar  avatar  avatar Mislav Sagovac avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar Jerzy Pawlowski avatar

Forkers

mislavsag

partialar's Issues

Compilation error

Hi,

I get this error when installing the package via install_github on windows. Any idea what's wrong?

Gavin.

`* installing source package 'partialAR' ...
** using staged installation
** libs
g++ -std=gnu++11 -I"C:/PROGRA1/R/R-421.0/include" -DNDEBUG -I'C:/Users/xen_m/AppData/Local/R/win-library/4.2/Rcpp/include' -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"C:/PROGRA1/R/R-421.0/include" -DNDEBUG -I'C:/Users/xen_m/AppData/Local/R/win-library/4.2/Rcpp/include' -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cfit.cc -o cfit.o
cfit.cc: In function 'double loglik_par_c(Rcpp::NumericVector, double, double, double, double, double)':
cfit.cc:171:41: error: 'PI' was not declared in this scope
171 | double nll = (n/2.0)log(tvar * 2.0PI) + esumsq/(2.0*tvar);
| ^~
cfit.cc: In function 'double loglik_par_t_c(Rcpp::NumericVector, double, double, double, double, double, double)':
cfit.cc:202:66: error: 'PI' was not declared in this scope
202 | double const_term = n * (lgamma((nu+1.0)0.5) - 0.5log(nu * PI) -
| ^~
make: *** [C:/PROGRA1/R/R-421.0/etc/x64/Makeconf:257: cfit.o] Error 1
ERROR: compilation failed for package 'partialAR'

  • removing 'C:/Users/xen_m/AppData/Local/R/win-library/4.2/partialAR'`

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.