Regression for unbalanced panel data

For questions regarding programming in the EViews programming language.

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

poken
Posts: 2
Joined: Thu Nov 17, 2011 2:37 am

Regression for unbalanced panel data

Postby poken » Wed Dec 07, 2011 2:30 am

Hi everyone:

I'm a new beginner to Eviews, here I plan to run a unbalanced panel data regression, the sample period is from 1963 to 2010,
using the daily stock data from CRSP to run a cross-sectional monthly regression; I have write part of eviews code but ran into some problems therefore can not generate results; I not sure where is the problem, here I posted part of my code, hoping that someone can help me to figure out the problem! Thanks!

Code: Select all

create idio u 1 1419783 read d:/yzu/thesis/data/crsp7173.txt date prc cusip $ permco vol ret year month smb hml mktrf rf umd output d:/yzu/thesis/result/idio6370.txt series exret = ret - rf 'calculate stock excess return group idio date year month permco exret mktrf smb hml umd !counter = 1 for !year = 1971 to 1973 'in order to test whether my code can work or not, I only run the data from 71 to 73. for !month = 1 to 12 for !cusip = 01650910 to 75471310 'list all cusip # here. smpl @all cusip=!cusip month=!month year=!year ' I think this line contain some syntax error, but I'm not sure. equation eq1 '4-factor regression model eq1.ls exret c mktrf smb hml umd 'run 4-factor regression to generate residual series residuals = resid !counter = !counter+1 next next next

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

Re: Regression for unbalanced panel data

Postby EViews Gareth » Wed Dec 07, 2011 8:47 am

I'm not sure what the line:

Code: Select all

smpl @all cusip=!cusip month=!month year=!year
is meant to be, but perhaps:

Code: Select all

smpl @all if cusip=!cusip and month=!month and year=!year

poken
Posts: 2
Joined: Thu Nov 17, 2011 2:37 am

Re: Regression for unbalanced panel data

Postby poken » Wed Dec 07, 2011 10:31 am

Dear Gareth:

Thanks for you rapidly reply, really appreciate!! :D
I have tried to run the adjusted code which you suggested, however still appear ERROR message: "Numeric operator applied to string data."
Perhaps I need to go back to check with my data set.

The reason why I include three for loops here is to run regressions by each firm (different cusip number) in each month in a given year.
I think the programming logic is on the right way however it contains some syntax error.
Is it possible that I put the "smpl @ all" in the wrong place therefore cause Eviews can't get my thought?

Thanks for your help again! :D

Code: Select all

smpl @ all if year=!year and month=!month and cusip = !cusip

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

Re: Regression for unbalanced panel data

Postby EViews Gareth » Wed Dec 07, 2011 10:38 am

It is a bit hard to tell without looking at the workfile. However, if I were to guess, I would say that your CUSIP series is stored in your workfile as an alpha series, rather than a series, so you can't do

Code: Select all

if cusip = !cusip
Since the left hand side of that equality is a sting, and the right hand side is a number.

Perhaps:

Code: Select all

@val(cusip) = !cusip


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests