Description Details Disclaimer Author(s) References See Also Examples
Fits time series models which consist of a sum of a permanent and a transient component. The permanent component is modeled as a random walk, while the transient component is modeled as an autoregressive series of order one.
Package: | partialAR |
Type: | Package |
Version: | 1.0 |
Date: | 2015-01-12 |
License: | GPL-2 | GPL-3 |
This package fits time series models which consist of a sum of a permanent and a transient component. In other words, the model fitted is:
X[t] = M[t] + R[t]
M[t] = rho * M[t-1] + epsilon_M[t]
R[t] = R[t-1] + epsilon_R[t]
-1 < rho < 1
epsilon_M[t] ~ N(0, sigma_M^2)
epsilon_R[t] ~ N(0, sigma_R^2)
This model may be useful when modeling a time series that is thought to be primarily mean-reverting but which may also contain some random drift.
DISCLAIMER: The software in this package is for general information purposes only. It is hoped that it will be useful, but it is provided WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is not intended to form the basis of any investment decision. USE AT YOUR OWN RISK!
Matthew Clegg
Maintainer: Matthew Clegg <matthewcleggphd@gmail.com>
Summers, Lawrence H. Does the stock market rationally reflect fundamental values? Journal of Finance, 41(3), 591-601.
Poterba, James M. and Lawrence H. Summers. Mean reversion in stock market prices: Evidence and implications. Journal of Financial Economics, 22(1), 27-59.
Clegg, Matthew. Modeling Time Series with Both Permanent and Transient Components using the Partially Autoregressive Model. Available at SSRN: http://ssrn.com/abstract=2556957
arima
ARIMA modeling of time series
egcm
Engle-Granger cointegration model
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | set.seed(1)
x <- rpar(1000, 0.8, 1, 0.5) # Generate a random PAR sequence
fit.par(x) # Estimate its parameters
plot(fit.par(x)) # Plot the estimate
test.par(x) # Test the goodness of fit
# An example involving European stock market data
data(EuStockMarkets) # European Stock Markets 1991-1998
# Check for cointegration between German DAX and Swiss SMI
library(egcm)
egcm(log(EuStockMarkets[,c("DAX", "SMI")]))
# The series are not found to be cointegrated.
# Perhaps they are partially cointegrated? Check the residuals
# of the cointegration fit for partial autoregression:
fit.par(egcm(EuStockMarkets[,c("DAX", "SMI")])$residuals)
# A plot of the model looks promising:
## Not run: plot(fit.par(egcm(EuStockMarkets[,c("DAX", "SMI")])$residuals))
# 74% of the variance is attributed to a mean-reverting
# AR(1) process. However, it is important to check whether this is
# a better explanation than a simple random walk:
test.par(egcm(EuStockMarkets[,c("DAX", "SMI")])$residuals)
# The p-value is found to be 0.36, so the random walk hypothesis
# cannot be rejected.
# Another example involving a potential pairs trade between
# Coca-Cola and Pepsi.
# Fetch the price series for Coca-Cola (KO) and Pepsi (PEP) in 2014
library(TTR)
KO <- getYahooData("KO", 20140101, 20141231)$Close
PEP <- getYahooData("PEP", 20140101, 20141231)$Close
# Check whether they were cointegrated
egcm(KO,PEP)
# It turns out that they are not cointegrated. Perhaps a better
# fit can be obtained with the partially autoregressive model:
fit.par(egcm(KO,PEP)$residuals)
# The mean-reverting component of the above fit explains 90% of
# the variance of the daily returns. Thus, it appears that the
# two series are close to being cointegrated. A plot further
# confirms this:
plot(fit.par(egcm(KO,PEP)$residuals))
# Still, it is important to check whether or not the residual
# series is simply a random walk:
test.par(egcm(KO,PEP)$residuals)
# In this case, the p-value associated with the hypothesis that
# the series is partially autoregressive is 0.12. Thus, the
# evidence of partial autoregression is marginal. The random walk
# may be a better explanation.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.