Fits the partial cointegration model to a collection of time series
fit.pci(Y, X,
pci_opt_method = c("jp", "twostep"),
par_model = c("par", "ar1", "rw"),
lambda = 0,
robust = FALSE, nu = 5)
The time series that is to be modeled. A plain or zoo
vector of length n
.
Specifies the method that will be used for finding the best fitting model. One of the following:
"jp" The joint-penalty method (see below)
"twostep" The two-step method (see below)
Default: jp
The model used for the residual series. One of the following:
"par" The residuals are assumed to follow a partially autoregressive model.
"ar1" The residuals are assumed to be autoregressive of order one.
"rw" The residuals are assumed to follow a random walk.
Default: par
The penalty parameter to be used in the joint-penalty (jp
) estimation method.
Default: 0.
If TRUE
, then the residuals are assumed to follow a t-distribution with
nu
degrees of freedom. Default: FALSE
.
The degrees-of-freedom parameter to be used in robust estimation. Default: 5.
An object of class pci.fit
containing the fit that was found. The following components
may be of interest
The vector of weights
The standard errors of the components of beta
The estimated coefficient of mean reversion
The standard error of rho
The negative of the log likelihood
The proportion of variance attributable to mean reversion
The partial cointegration model is given by the equations:
$$ Y_t = \beta_1 * X_{t,1} + beta_2 * X_{t,2} + ... + beta_k * X_{t,k} + 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} \sim N(0,\sigma_M^2)$$ $$\epsilon_{R,t} \sim N(0,\sigma_R^2)$$
Given the input series
Y
and X
,
this function searches for the parameter values
beta
, rho
that give the best fit of this model when using a Kalman filter.
If pci_opt_method
is twostep
, then a two-step procedure is used.
In the first step, a linear regression is performed of X
on Y
to determine
the parameter beta
. From this regression, a series of residuals
is determined. In the second step, a model is fit to the residual series. If
par_model
is par
, then a partially autoregressive model is fit to
the residual series. If par_model
is ar1
, then an autoregressive model
is fit to the residual series. If par_model
is rw
then a random walk
model is fit to the residual series. Note that if pci_opt_method
is twostep
and par_model
is ar1
, then this reduces to the Engle-Granger two-step
procedure.
If pci_opt_method
is jp
, then the joint-penalty procedure is used.
In this method, the parameterbeta
are estimated jointly
with the parameter rho
using a gradient-search optimization function.
In addition, a penalty value of
\(\lambda * \sigma_R^2\)
is added to the Kalman filter likelihood score when searching for the
optimum solution. By choosing a positive value for lambda
, you can drive
the solution towards a value that places greater emphasis on the mean-reverting
component.
Because the joint-penalty method uses gradient search, the final parameter values found are dependent upon the starting point. There is no guarantee that a global optimum will be found. However, the joint-penalty method chooses several different starting points, so as to increase the chance of finding a global optimum. One of the chosen starting points consists of the parameters found through the two-step procedure. Because of this, the joint-penalty method is guaranteed to find parameter values which give a likelihood score at least as good as those found using the two-step procedure. Sometimes the improvement over the two-step procedure is substantial.
Clegg, Matthew, 2015. Modeling Time Series with Both Permanent and Transient Components using the Partially Autoregressive Model. Available at SSRN: http://ssrn.com/abstract=2556957
Clegg, Matthew and Krauss, Christopher, 2018. Pairs trading with partial cointegration. Quantitative Finance, 18(1), 121 - 138.
egcm
Engle-Granger cointegration model
partialAR
Partially autoregressive models
# NOT RUN {
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
YX <- rpci(n=1000, beta=c(2,3,4), sigma_C=c(1,1,1), rho=0.9,sigma_M=0.1, sigma_R=0.2)
fit.pci(YX[,1], YX[,2:ncol(YX)])
# }
Run the code above in your browser using DataLab