Problem Saving Estimated VAR Coefficients

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Problem Saving Estimated VAR Coefficients

Postby mike_d » Fri Mar 16, 2012 8:53 am

Hi,

I am looping through many files, running a VAR or VEC based on whether there is a cointegrating relation. I am currently trying to properly store all estimated coefficients and standard errors. I have referred to the help files and figure what I am attempting is the most efficient way. I have included a small snippet of the step that estimates and saves coefficients for VAR/VEC with 2 lags. The problem I am having is that the estimated VAR coefficients are not saving properly. For some reason the estimate for the first lag of the second endogenous variable (s9, s11 or s13 in this case) is not saving in the correct position in my results table. I have contemplated freezing the estimating as a table and then taking the value from the frozen table but would like to know where I am going wrong. I can upload the entire program if needed however it is quite long. Thanks in advance. See code below, I commented on the specific lines that are not working the way I thought they would:



if cdsv = 2 then

for !w = 9 to 14 step 2
!older = @errorcount
if c!w = 0 then
var var_est!w.ls 1 2 s3 s!w @ s15 s16 s17 s18 s19
endif

if c!w > 0 then
var vec_est!w.ec 1 2 s3 s!w @ s15 s16 s17 s18 s19
endif
!newer = @errorcount


if !newer = !older then
clearerrs

var!w_coeff1(!i*3,1) = var_est!w.c(1,1)
var!w_coeff1(!i*3,2) = var_est!w.c(1,2)
var!w_coeff1(!i*3,5) = var_est!w.c(1,3) '''not working - saving the same coeff as line above for some reason instead of coeff 3 (1st lag of second endog.)
var!w_coeff1(!i*3,6) = var_est!w.c(1,4)
''exogs
var!w_coeff1(!i*3,9) = var_est!w.c(1,5) '''these 5 lines save coeff 3-7 from eq1 but I want coeff 5-9 saved in these spots
var!w_coeff1(!i*3,10) = var_est!w.c(1,6)
var!w_coeff1(!i*3,11) = var_est!w.c(1,7)
var!w_coeff1(!i*3,12) = var_est!w.c(1,8)
var!w_coeff1(!i*3,13) = var_est!w.c(1,9)

var!w_coeff1(!i*3,14) = var_est!w.c(2,1)
var!w_coeff1(!i*3,15) = var_est!w.c(2,2)
var!w_coeff1(!i*3,18) = var_est!w.c(2,3)
var!w_coeff1(!i*3,19) = var_est!w.c(2,4)
''exogs
var!w_coeff1(!i*3,22) = var_est!w.c(2,5)
var!w_coeff1(!i*3,23) = var_est!w.c(2,6)
var!w_coeff1(!i*3,24) = var_est!w.c(2,7)
var!w_coeff1(!i*3,25) = var_est!w.c(2,8)
var!w_coeff1(!i*3,26) = var_est!w.c(2,9)

var!w_coeff1((!i*3)+1,1) = var_est!w.@coefse(1,1)
var!w_coeff1((!i*3)+1,2) = var_est!w.@coefse(2,1)
var!w_coeff1((!i*3)+1,5) = var_est!w.@coefse(3,1)
var!w_coeff1((!i*3)+1,6) = var_est!w.@coefse(4,1)

''exogs
var!w_coeff1((!i*3)+1,9) = var_est!w.@coefse(5,1)
var!w_coeff1((!i*3)+1,10) = var_est!w.@coefse(6,1)
var!w_coeff1((!i*3)+1,11) = var_est!w.@coefse(7,1)
var!w_coeff1((!i*3)+1,12) = var_est!w.@coefse(8,1)
var!w_coeff1((!i*3)+1,13) = var_est!w.@coefse(9,1)

var!w_coeff1((!i*3)+1,14) = var_est!w.@coefse(1,2)
var!w_coeff1((!i*3)+1,15) = var_est!w.@coefse(2,2)
var!w_coeff1((!i*3)+1,18) = var_est!w.@coefse(3,2)
var!w_coeff1((!i*3)+1,19) = var_est!w.@coefse(4,2)

''exogs
var!w_coeff1((!i*3)+1,22) = var_est!w.@coefse(5,2)
var!w_coeff1((!i*3)+1,23) = var_est!w.@coefse(6,2)
var!w_coeff1((!i*3)+1,24) = var_est!w.@coefse(7,2)
var!w_coeff1((!i*3)+1,25) = var_est!w.@coefse(8,2)
var!w_coeff1((!i*3)+1,26) = var_est!w.@coefse(9,2)

vec!w_coeff1(!i*3,2) = vec_est!w.c(1,1)
vec!w_coeff1(!i*3,3) = vec_est!w.c(1,2)

vec!w_coeff1(!i*3,6) = vec_est!w.c(1,3)
vec!w_coeff1(!i*3,7) = vec_est!w.c(1,4)

''exogs
vec!w_coeff1(!i*3,10) = vec_est!w.c(1,5)
vec!w_coeff1(!i*3,11) = vec_est!w.c(1,6)
vec!w_coeff1(!i*3,12) = vec_est!w.c(1,7)
vec!w_coeff1(!i*3,13) = vec_est!w.c(1,8)
vec!w_coeff1(!i*3,14) = vec_est!w.c(1,9)

vec!w_coeff1(!i*3,16) = vec_est!w.c(2,1)
vec!w_coeff1(!i*3,17) = vec_est!w.c(2,2)

vec!w_coeff1(!i*3,20) = vec_est!w.c(2,3)
vec!w_coeff1(!i*3,21) = vec_est!w.c(2,4)

''exogs
vec!w_coeff1(!i*3,24) = vec_est!w.c(2,5)
vec!w_coeff1(!i*3,25) = vec_est!w.c(2,6)
vec!w_coeff1(!i*3,26) = vec_est!w.c(2,7)
vec!w_coeff1(!i*3,27) = vec_est!w.c(2,8)
vec!w_coeff1(!i*3,28) = vec_est!w.c(2,9)

vec!w_coeff1(!i*3,1) = vec_est!w.a(1,1)
vec!w_coeff1(!i*3,15) = vec_est!w.a(2,1)

vec!w_coeff1((!i*3)+1,2) = vec_est!w.@coefse(2,1)
vec!w_coeff1((!i*3)+1,3) = vec_est!w.@coefse(3,1)

vec!w_coeff1((!i*3)+1,6) = vec_est!w.@coefse(4,1)
vec!w_coeff1((!i*3)+1,7) = vec_est!w.@coefse(5,1)
''exogs
vec!w_coeff1((!i*3)+1,10) = vec_est!w.@coefse(6,1)
vec!w_coeff1((!i*3)+1,11) = vec_est!w.@coefse(7,1)
vec!w_coeff1((!i*3)+1,12) = vec_est!w.@coefse(8,1)
vec!w_coeff1((!i*3)+1,13) = vec_est!w.@coefse(9,1)
vec!w_coeff1((!i*3)+1,14) = vec_est!w.@coefse(10,1)

vec!w_coeff1((!i*3)+1,16) = vec_est!w.@coefse(2,2)
vec!w_coeff1((!i*3)+1,17) = vec_est!w.@coefse(3,2)
vec!w_coeff1((!i*3)+1,20) = vec_est!w.@coefse(4,2)
vec!w_coeff1((!i*3)+1,21) = vec_est!w.@coefse(5,2)
''exogs
vec!w_coeff1((!i*3)+1,24) = vec_est!w.@coefse(6,2)
vec!w_coeff1((!i*3)+1,25) = vec_est!w.@coefse(7,2)
vec!w_coeff1((!i*3)+1,26) = vec_est!w.@coefse(8,2)
vec!w_coeff1((!i*3)+1,27) = vec_est!w.@coefse(9,2)
vec!w_coeff1((!i*3)+1,28) = vec_est!w.@coefse(10,2)

vec!w_coeff1((!i*3)+1,1) = vec_est!w.@coefse(1,1)
vec!w_coeff1((!i*3)+1,15) = vec_est!w.@coefse(1,2)
endif

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Problem Saving Estimated VAR Coefficients

Postby EViews Gareth » Fri Mar 16, 2012 9:05 am

Doesn't appear to be anything wrong with the code you posted. I just ran a test version of it and it worked fine. I'd say there is something else, elsewhere, going wrong.

Code: Select all

create u 100 series s3=nrnd series s9=nrnd series s15=nrnd series s16=nrnd series s17=nrnd series s18=nrnd series s19=nrnd !w = 9 var var_est!w.ls 1 2 s3 s!w @ s15 s16 s17 s18 s19 !i=2 matrix(6,13) var9_coeff1 var!w_coeff1(!i*3,1) = var_est!w.c(1,1) var!w_coeff1(!i*3,2) = var_est!w.c(1,2) var!w_coeff1(!i*3,5) = var_est!w.c(1,3) '''not working - saving the same coeff as line above for some reason instead of coeff 3 (1st lag of second endog.) var!w_coeff1(!i*3,6) = var_est!w.c(1,4) ''exogs var!w_coeff1(!i*3,9) = var_est!w.c(1,5) '''these 5 lines save coeff 3-7 from eq1 but I want coeff 5-9 saved in these spots var!w_coeff1(!i*3,10) = var_est!w.c(1,6) var!w_coeff1(!i*3,11) = var_est!w.c(1,7) var!w_coeff1(!i*3,12) = var_est!w.c(1,8) var!w_coeff1(!i*3,13) = var_est!w.c(1,9)

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Re: Problem Saving Estimated VAR Coefficients

Postby mike_d » Fri Mar 16, 2012 9:10 am

Would you be willing to look at the entire program? Could I send it to you as a text file? If not, no problem I will continue looking for the problem and I appreciate you checking that small snippet of code.

Mike

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Problem Saving Estimated VAR Coefficients

Postby EViews Gareth » Fri Mar 16, 2012 9:30 am

Probably faster for you to run through it yourself first.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests