Page 1 of 1

storing coefficients and errors for panel data

Posted: Thu Jun 08, 2017 5:27 am
by Jorrit van der Windt
Hello,

I just went through the introduction to EViews programming and I am aware of the extensive examples about storing coefficients and statistics of multiple regressions. However I want to store coefficients of multiple runs of the same regressions with different companies over different timespans.

So I have data availible and am able to create a matrix to store the coefficients in, however I cannot figure out how to run equations with panal data.

I have a few questions.

The first is how can I run seperate regressions for different series in a panel. The panel is structured as follows for 600 companies over 5 years within the variable. So the price variable has all the prices for different companies on different time (which is the definition of a panel data set)
CopanyID_dd/mm/yyyy

I want to run the following regression and store the coefficients and standard error of the regression for every individual company per year.
What code can I use to distinguish between companies and different years?

My second question what the code is for storing standard errors
I know for coefficients it would be
colplace(coefs, eq.@coefs,)

what would be the @ code for the standard error of the regression. would it be @se?

Thanks in advance

Jorrit van der Windt

Re: storing coefficients and errors for panel data

Posted: Thu Jun 08, 2017 8:13 am
by EViews Gareth
If your data are in a panel workfile, you just need to set the sample by date and companies:

Code: Select all

smpl 1990 1995 if company="MSFT"
http://www.eviews.com/help/helpintro.ht ... ation.html
(scroll down to data members)

Re: storing coefficients and errors for panel data

Posted: Thu Jun 15, 2017 5:56 am
by Jorrit van der Windt
Hi Gareth

Thanks for your reply! I think my question was maybe a little unclear, I want to run a regression for 571 different companies for 8 individual year. So i would have to use this code per company

Code: Select all

smpl 2006 if company="msft"
However as there are 571 companies for 8 years that would result in 4568 companyyears, which would be too much to do manually. Is it possible to sample within a loop? For example each company in the panel is specifide by its name, can I loop them as follows?

Code: Select all

for !i=1 to 571 smpl company(!i)
Is it also possible to run the regression: ret c rm-rf smb hml using the following code.

Code: Select all

'create matrix to store coefficients. There are 571 companies for 8 years (so 4568 results) and I will store 5 coefficients matrix(4568,5) coefs 'create empty equation to be used inside the loop equation eq 'create a loop for each year for !i=2008 to 2016 smpl date(!i) 'run regressions for different companies and years for !i=1 to 571 smpl company(!i) eq.ls ret c rm_rf_gl smb hml 'store coefficients into matrix colplace coefs eq.@coefs eq.@se next
Would I then get the coefficients in the matrix in panel format (year and company)?

Eager to hear your answer

Kind regards

Jorrit van der Windt

Re: storing coefficients and errors for panel data

Posted: Thu Jun 15, 2017 6:05 am
by EViews Gareth

Code: Select all

for !c = 1 to 571 for !y=2000 to 2016 smpl if @year=!y and @crossid=!c 'do stuff here next next

Re: storing coefficients and errors for panel data

Posted: Thu Jun 15, 2017 8:30 am
by Jorrit van der Windt
Hi Gareth,

Thank you very much it works now. However there are som crossidsthat have an insufficient number of observations and therefore it stopt the program without regressing the other cross IDs. Do I have to delete these cross IDs or can I force the program to continue somehow?

Secondly the output is stored in a vector or matrix, is there any way to connect the rows in the matrix to the cross ID so that i can use it in a new annual panel with the same companies?

again thanks for your help

Jorrit

Re: storing coefficients and errors for panel data

Posted: Thu Jun 15, 2017 8:42 am
by EViews Gareth
Run the program with maximum errors set high (or use the setmaxerrs command).

Use mtos to change from a matrix/vector into a group/series.

Re: storing coefficients and errors for panel data

Posted: Mon Jun 26, 2017 5:31 am
by Jorrit van der Windt
Hi Gareth,

If there is a "insufficient number of observations in" error it returns the value of the coefficient that was previously run. So for example if there is an error in R8 of the vector it uses the value of r7 and so forth. Is there a way to return a NA of a blank value if there is an error?

Eager to hear from you!

Jorrit

Re: storing coefficients and errors for panel data

Posted: Mon Jun 26, 2017 7:30 am
by EViews Gareth
You'll have to program around it with something like @errorcount.