perform a regression for each crossid individually in a panel workfile

For econometric discussions not necessarily related to EViews.

Moderators: EViews Gareth, EViews Moderator

jo_m555
Posts: 2
Joined: Thu Feb 22, 2018 12:46 pm

perform a regression for each crossid individually in a panel workfile

Postby jo_m555 » Thu Feb 22, 2018 1:12 pm

Dear users,

I have a panel workfile with a sample of 31 cross-sections and 500 time periods. I would like to run a single regression for each crossid individually.
my cross section variable is "ID" which has values between 1 and 31. I uploaded the data correctly, having variables stacked over each ID from t=1 to T.
I would like to get a equation estimate for each cross id separately (which contain the t oberservations) Y = C + X1 + X2 + X3. and i would store the regressions as linreg1, linreg2,..., linreg31

I tried:

for !i=1 to 31
if @crossid=!i
equation linreg{!i}.LS Y X1 X2 X3
endif
next

But I get the error term:
Syntax error in control statement in "IF @CROSSID=1".

Can any one help me? many thanks in advande!
Best

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: perform a regression for each crossid individually in a panel workfile

Postby startz » Thu Feb 22, 2018 1:35 pm

Try

Code: Select all

for !i=1 to 31
smpl if @crossid=!i
equation linreg{!i}.LS Y X1 X2 X3
next

jo_m555
Posts: 2
Joined: Thu Feb 22, 2018 12:46 pm

Re: perform a regression for each crossid individually in a panel workfile

Postby jo_m555 » Thu Feb 22, 2018 2:26 pm

Great thank you so much! Best

fatihtekke
Posts: 3
Joined: Sat Jan 05, 2019 10:50 pm

Re: perform a regression for each crossid individually in a panel workfile

Postby fatihtekke » Sun Jan 06, 2019 10:28 am

Dear Gareth,
I would like to ask a follow up question for this post. I used the code and it is working. Thanks for that.
However, I have like 1200 crossid and need to collect the estimation betas and create a matrix(new variable) by 1200x1
I wonder if you are able to help me by adding lines to the code above.


Return to “Econometric Discussions”

Who is online

Users browsing this forum: No registered users and 14 guests