New KALMAN Feture in 6.3
We've added some new options to KALMAN in Version 6.3.
The options are Y, X and V, and are used to feed in the dependent variable(s) (Y option), explanatory variables (X option, for a VAR or a single equation, since one vector applies to all) and measurement equation variances(s) (V option). Among other things, this can be used for "dummy observation" priors.
See an example in the Examples and Sample Code section. For instance,
compute xdummy=$
%eqnxvector(%modeleqn(sims9var,1),1949:3)*$
dumwght
kalman(x=xdummy)
xdummy is the vector of explanatory variables for the VAR model sims9var at date 1949:3 (in this case the last pre-sample data), scaled by dumwght. If y is omitted, it's assumed to be perfectly predicted. The KALMAN instruction with x and y options updates the coefficients and covariance matrices, but doesn't shift the entry pointer or compute residuals.
If V option can be used Y and X, but also can be used just in a standard Kalman filter as it walks through the data set. This makes it much easier to adjust the observation equation variances, which previously had to be done using the KFSET during the setup of the model. An example of this is the following, which does two separate KALMAN's (with low and high variances), resetting the coefficients and covariance matrix between the two.
*
* lambdav1 is the product of the ARCH factors. Use it to scale
* the original measurement and transition variances
*
ewise tvx(iv)=tv(iv)*lambdav1(iv)
kalman(noprint,startup=i,resid=onestep,v=lambdav1.*vce) nvar+1
*
* Compute the likelihood elements, and save the updated
* coefficients and variances
*
compute likely1 = lhood-lhood0
compute coeff1 = %modelgetcoeffs(sims9var)
ewise xxx1(iv) = xxx(iv)
*
* Compute the densities for each equation for this branch
*
ewise eqlhx21(j)= -likely1(2,j) - likely1(1,j)
ewise w1(iv) = exp(.5*eqlhx21(iv))*(1-theta)
*
* High variance branch
*
* Reset the likelihood array, the coefficients and the variance
* matrices. Scale up the tvx matrices
*
compute lhood=lhood0
compute %modelsetcoeffs(sims9var,coeff0)
ewise xxx(iv)=xxx0(iv)
ewise tvx(iv)=tvx(iv)*gamma**2
kalman(noprint,startup=i,resid=onestep,$
v=gamma**2*lambdav1.*vce) nvar+1
The options are Y, X and V, and are used to feed in the dependent variable(s) (Y option), explanatory variables (X option, for a VAR or a single equation, since one vector applies to all) and measurement equation variances(s) (V option). Among other things, this can be used for "dummy observation" priors.
See an example in the Examples and Sample Code section. For instance,
compute xdummy=$
%eqnxvector(%modeleqn(sims9var,1),1949:3)*$
dumwght
kalman(x=xdummy)
xdummy is the vector of explanatory variables for the VAR model sims9var at date 1949:3 (in this case the last pre-sample data), scaled by dumwght. If y is omitted, it's assumed to be perfectly predicted. The KALMAN instruction with x and y options updates the coefficients and covariance matrices, but doesn't shift the entry pointer or compute residuals.
If V option can be used Y and X, but also can be used just in a standard Kalman filter as it walks through the data set. This makes it much easier to adjust the observation equation variances, which previously had to be done using the KFSET during the setup of the model. An example of this is the following, which does two separate KALMAN's (with low and high variances), resetting the coefficients and covariance matrix between the two.
*
* lambdav1 is the product of the ARCH factors. Use it to scale
* the original measurement and transition variances
*
ewise tvx(iv)=tv(iv)*lambdav1(iv)
kalman(noprint,startup=i,resid=onestep,v=lambdav1.*vce) nvar+1
*
* Compute the likelihood elements, and save the updated
* coefficients and variances
*
compute likely1 = lhood-lhood0
compute coeff1 = %modelgetcoeffs(sims9var)
ewise xxx1(iv) = xxx(iv)
*
* Compute the densities for each equation for this branch
*
ewise eqlhx21(j)= -likely1(2,j) - likely1(1,j)
ewise w1(iv) = exp(.5*eqlhx21(iv))*(1-theta)
*
* High variance branch
*
* Reset the likelihood array, the coefficients and the variance
* matrices. Scale up the tvx matrices
*
compute lhood=lhood0
compute %modelsetcoeffs(sims9var,coeff0)
ewise xxx(iv)=xxx0(iv)
ewise tvx(iv)=tvx(iv)*gamma**2
kalman(noprint,startup=i,resid=onestep,$
v=gamma**2*lambdav1.*vce) nvar+1