public class VectorAutoregression extends Object implements Serializable, Cloneable
This class contains methods for modeling multivariate time series of the form
where each is a real-valued time series indexed by t. Define the K dimensional mean process and the cross-covariance matrix where for each (t,h), is a K * K real-valued matrix whose (i,j)t,h element is the covariance between :The vector autoregressive model, or VAR, has a number of equivalent forms. A general form is
where is a p-th degree matrix polynomial in the lag or backshift operator, L. Note that p is the specified autoregressive lag and ut is the error process. The error process is assumed to be a K dimensional white noise series, with and nonsingular covariance matrix, , which is constant over time. The coefficient matrices are K * K matrices containing the coefficients of the model. The matrix Xt represents a matrix of deterministic terms such as trend or seasonal variables, and D represents the associated coefficient matrix of Xt.Constructor and Description |
---|
VectorAutoregression(TimeSeries ts)
Constructor for the class.
|
Modifier and Type | Method and Description |
---|---|
double[] |
getARConstants()
Returns the current settings of the constants used in the autoregression
model.
|
int[] |
getARModel()
Returns the autoregressive model configuration.
|
double[][] |
getEstimates()
Returns the parameter estimates (coefficients) of the vector
autoregression model.
|
double[][] |
getForecasts()
Returns the h-step ahead forecast at times
t=nT, nT+1, ..., T, where
h=1,2, ...,
maxStepsAhead . |
boolean |
isA0Flag()
Returns the state of
A0Flag . |
void |
setA0Flag(boolean A0Flag)
Sets the flag to include the leading autoregressive coefficient matrix in
the model.
|
void |
setARConstants(double[] arConstants)
Sets the constants for the autoregressive model.
|
void |
setARLag(int arLag)
Sets the autoregressive lag parameter.
|
void |
setARModel(int[] arModel)
Sets the form of the autoregressive terms of the model.
|
void |
setCenter(boolean center)
Sets the flag to center the data.
|
void |
setMaxLag(int maxLag)
Sets the maximum lag.
|
void |
setScale(boolean scale)
Sets the flag to scale the data.
|
void |
setTrend(boolean trend)
Sets the flag to fit a trend parameter in the model.
|
public VectorAutoregression(TimeSeries ts)
ts
- a TimeSeries
object.public double[] getARConstants()
double
array containing the constants used in the
autoregression model. If the value is null
, the default
values are active.public int[] getARModel()
int
array specifying the autoregressive
configuration. If null
, then all parameters are active in
the current model.public double[][] getEstimates()
double
array containing the estimated parameters
(coefficients).public double[][] getForecasts()
maxStepsAhead
.
The h-step ahead forecast
uses the conditional expectation of given the historical information known at time t. The estimated VAR model approximates the conditional expectation and the forecasts are generated from the estimated VAR model via the following recursion: where is the vector time series anddouble
matrix T-nT by
maxStepsAhead
* K containing the forecasts.
Note that the forecast is stored in location [t-nT][(h-1)*K + k] of the returned forecast matrix.
public boolean isA0Flag()
A0Flag
.boolean
which specifies whether or not the leading
coefficient matrix is nontrivial.public void setA0Flag(boolean A0Flag)
When true
, a nontrivial, lower-triangular leading
autoregressive coefficient matrix, A0, will be
estimated in the model. When false
, A0
is the constant identity matrix, which is also the default case.
A0Flag
- boolean
indicating whether to fit the leading
coefficient matrix.
Default: A0Flag
=false
.
public void setARConstants(double[] arConstants)
setARModel(int[])
for details.arConstants
- a double
array specifying the
autoregressive model constants.
The input array arConstants
must be of length
(A0Flag
+arLag
)*K*K,
such that for indices 1=0,...,(A0Flag
+ arLag
),
i=0,...,K-1, and
j=0,...,K-1, arConstants[
l*K*K +i*K +
j]
specifies a constant value for parameter
.
arConstants[
i]
=0.public void setARLag(int arLag)
maxLag
.arLag
- an int
specifying the desired lag for the
autoregressive terms.
Default: arLag
=1.public void setARModel(int[] arModel)
Without loss of generality, assume that the series mean is 0 and that there are no deterministic terms. Then we can write the vector autoregression model of lag p as
Each of the matrices Aj represents K * K unknown coefficients. In practice, many of the (p+ 1) * K * K coefficients are restricted to be 0 or otherwise constant. The leading coefficient matrix A0 must be lower-triangular and is very often equal to the identity matrix (this is the default behavior). Fully expanded the model looks like K equations in K(p+1) unknowns. Consider each coefficient matrix as the vector for . is just the columns of appended to each other. To specify a configuration different from the default, append the vectorized coefficient matrices as or when including a nontrivial leading coefficient matrix. Set the value at index l*K*K + j*K + i to 1 or -1 to fit or in the model. Set the value to 0 to exclude as a parameter. Note that for the leading coefficient matrix,l= 0, the value at j*K + i is ignored unless i is at least j, i.e., only the lower triangle of A0 can be nontrivial.arModel
- an int
array specifying the autoregressive
model parameters.
For indices
l=0,...,(A0Flag
+arLag
),
i=0,...,K-1, and j=0,...,K-1,
arModel[
l*K*K +i*K + j]
= {-1,1}
indicates that the coefficient
is a parameter (to be estimated) in the model.
Default: A0 is the identity matrix and
arModel[
i]
=1 for all i.
public void setCenter(boolean center)
center
=true
, column means are subtracted from
the data.center
- a boolean
indicating whether or not column
means should be subtracted from the data.
Default: center
=false
.
public void setMaxLag(int maxLag)
maxLag
- an int
specifying the maximum lag to consider
in the first (pure VAR) stage regression.public void setScale(boolean scale)
If scale
=true
, the data values are
mean-centered and then divided by the standard deviation.
scale
- a boolean
Default: scale
=false
.
public void setTrend(boolean trend)
true
to include a deterministic trend in the model.trend
- a boolean
specifying whether or not to include
a deterministic trend.
Default: trend
=false
.
Copyright © 1970-2016 Rogue Wave Software
Built May 19 2016.