far.cv {far} | R Documentation |
Cross Validation for FARX(1) model
Description
Cross Validation for FAR(1) and FARX(1) models
Usage
far.cv(data, y, x, kn, ncv, cvcrit, center=TRUE, na.rm=TRUE, joined=FALSE)
Arguments
data |
A |
y |
A vector giving the name(s) of the endogenous variable(s) of the model. |
x |
A vector giving the name(s) of the exogenous variable(s) of the model. |
kn |
A vector giving the maximum values of the various
|
ncv |
Number of observations used to the cross validation |
cvcrit |
A vector of characters. Name of the variable used to
measure the errors ( |
center |
Logical. Does the observation need to be centered. |
na.rm |
Logical. Does the |
joined |
Logical. If |
Details
In order to perform good forecasting with a FAR or FARX model, you need
to determine the dimensions kn
of the subspace in which the linear
operator is estimated (see far
for more details).
This function helps the user to do this choice by performing a cross
validation on a test sample. The usage is close of the
far
function, so we will discuss about the options which
differ.
First, the kn
option is used to restrict the values searched:
this is a vector containing the maxima values. As in
far
, the dimension of this vector is function of the
number of variables involved in the model and the type of estimation
done (joined or not).
ncv
is the number of observation used to test the models. If it
is not provided, the function use the last fifth of the observations in
data
. In such a case, the four first fifth are used to
estimates the models. This is in general a good compromise.
Finally, cvcrit
list the variables used to test the models. If
more than one variable is provided, the test is calculated as a mean
of the errors over all the variables.
The criteria used to test the (functional) errors are the norms L1, L2, L infinite, L1 on the maxima, L2 on the maxima, and L infinite on the maxima.
Value
It is a LIST with the following elements
cv |
Matrix giving the various errors (L1, L2, L infinite, L1 on the
maxima, L2 on the maxima, L infinite on the maxima) for the tested
values of |
minL1 |
A vector corresponding to the row of |
minL2 |
A vector corresponding to the row of |
minLinf |
A vector corresponding to the row of |
minL1max |
A vector corresponding to the row of |
minL2max |
A vector corresponding to the row of |
minLinfmax |
A vector corresponding to the row of |
Author(s)
J. Damon
See Also
Examples
# Simulation of a FARX process
data1 <- simul.farx(m=10,n=400,base=base.simul.far(20,5),
base.exo=base.simul.far(20,5),
d.a=matrix(c(0.5,0),nrow=1,ncol=2),
alpha.conj=matrix(c(0.2,0),nrow=1,ncol=2),
d.rho=diag(c(0.45,0.90,0.34,0.45)),
alpha=diag(c(0.5,0.23,0.018)),
d.rho.exo=diag(c(0.45,0.90,0.34,0.45)),
cst1=0.0)
# Cross validation (joined and separate)
model1.cv <- far.cv(data=data1, y="X", x="Z", kn=8, ncv=10, cvcrit="X",
center=FALSE, na.rm=FALSE, joined=TRUE)
model2.cv <- far.cv(data=data1, y="X", x="Z", kn=c(4,4), ncv=10, cvcrit="X",
center=FALSE, na.rm=FALSE, joined=FALSE)
print(model1.cv)
print(model2.cv)
k1 <- model1.cv$minL2[1]
k2 <- model2.cv$minL2[1:2]
# Modelization of the FARX process (joined and separate)
model1 <- far(data=data1, y="X", x="Z", kn=k1,
center=FALSE, na.rm=FALSE, joined=TRUE)
model2 <- far(data=data1, y="X", x="Z", kn=k2,
center=FALSE, na.rm=FALSE, joined=FALSE)
print(model1)
print(model2)