Page 1 of 1

Storing all coefficients

Posted: Thu Feb 19, 2015 10:27 am
by Amorimneto
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

Re: Storing all coefficients

Posted: Thu Feb 19, 2015 10:29 am
by EViews Gareth
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.

Re: Storing all coefficients

Posted: Thu Feb 19, 2015 11:00 am
by Amorimneto
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

Re: Storing all coefficients

Posted: Thu Feb 19, 2015 11:17 am
by Amorimneto
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