Storing all coefficients

For questions regarding programming in the EViews programming language.

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

Amorimneto
Posts: 11
Joined: Thu Jan 15, 2015 11:55 am

Storing all coefficients

Postby Amorimneto » Thu Feb 19, 2015 10:27 am

Hello good morning,
im having trouble to get a matrix winth all the coefficients of the regression.
my code is:

Code: Select all

group xs group xf 'create series for %i pib pib1 pib2 pib3 pib4 pib5 desemprego desemprego1 desemprego2 desemprego3 desemprego4 desemprego5 ipca ipca1 ipca2 ipca3 ipca4 ipca5 selic selic1 selic2 selic3 selic4 Selic5 compr compr1 compr2 compr3 compr4 compr5 endiv endiv1 endiv2 endiv3 endiv4 endiv5 cdi cdi1 cdi2 cdi3 cdi4 cdi5 xs.add {%i} next for %f overi xf.add {%f} next 'create vector to store r-squares vector(42) r2s 'create empty equation to be used inside the loop equation eq ''counter of how many equations we have run !rowcounter=1 'create table matrix(2,10) coeffients 'run pairwise regressions between each series for !i=1 to xf.@count %iname = xf.@seriesname(!i) for !j=1 to xs.@count %jname = xs.@seriesname(!j) equation eq_{%iname}_{%jname}.ls {%iname} c {%jname} coeffients(!i) = eq_{%iname}_{%jname}.@coef(1) coeffients(!i) = eq_{%iname}_{%jname}.@coef(2) next next 'run pairwise regressions between each series for !i=1 to xf.@count %iname = xf.@seriesname(!i) for !j=1 to xs.@count %jname = xs.@seriesname(!j) eq.ls {%iname} c {%jname} r2s(!rowcounter) = eq.@r2 !rowcounter = !rowcounter+1 next next

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

Re: Storing all coefficients

Postby EViews Gareth » Thu Feb 19, 2015 10:29 am

You created a matrix with 2 rows and 10 columns. You're then inputting values into the matrix with a line like:

Code: Select all

coeffients(!i) = eq_{%iname}_{%jname}.@coef(1)
You can't do that, since coeffients is a matrix, not a vector. You need to assign it to an (i,j) element, not a (i) element.

Amorimneto
Posts: 11
Joined: Thu Jan 15, 2015 11:55 am

Re: Storing all coefficients

Postby Amorimneto » Thu Feb 19, 2015 11:00 am

Thz
so im a little lost, i put this.

Code: Select all

coeffients(!j,!i) = eq_{%iname}_{%jname}.@coef(!i)
but its only filling 1 line in the matrix

Amorimneto
Posts: 11
Joined: Thu Jan 15, 2015 11:55 am

Re: Storing all coefficients

Postby Amorimneto » Thu Feb 19, 2015 11:17 am

You created a matrix with 2 rows and 10 columns. You're then inputting values into the matrix with a line like:

Code: Select all

coeffients(!i) = eq_{%iname}_{%jname}.@coef(1)
You can't do that, since coeffients is a matrix, not a vector. You need to assign it to an (i,j) element, not a (i) element.

i get it

Code: Select all

coeffients(!j,1) = eq_{%iname}_{%jname}.@coef(1) coeffients(!j,2) = eq_{%iname}_{%jname}.@coef(2)
thz


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest