## Average Cross-sectional Regression in Panel Data Structure

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

### Average Cross-sectional Regression in Panel Data Structure

Hi,
I have a panel data with N=40, T=50.
I want to estimate the following models:
1. For each country
2. For each year
3. Take average across T for each N. So, i will have 40 observations. Then i want to run a cross-section regression
4. Take average (for entire period) across N for each T. So, I will have 50 observations - one for each year. I want to estimate a time series model.
5. Same as #4, but the averaging is for sub-samples like 1950-1970, 1971-1995.

Thank you.

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

### Re: Average Cross-sectional Regression in Panel Data Structure

Hi,
I would be grateful if someone can help me out.

Thank you.

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Average Cross-sectional Regression in Panel Data Structure

Do you have a lot of series in your equation?

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

### Re: Average Cross-sectional Regression in Panel Data Structure

Dear Glenn,
No, i have a panel data set. I want to estimate those my models to see how the coefficient changes with respect to specifications.

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Average Cross-sectional Regression in Panel Data Structure

I meant, are there a lot of variables in the regression specification. There are different ways of doing this and the best will depend on your specification.

If you want to post your workfile and a description of the equation, that might be a useful approach.

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

### Re: Average Cross-sectional Regression in Panel Data Structure

I have only "two" variables.

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Average Cross-sectional Regression in Panel Data Structure

With only two variables it's easiest to do it in the same workfile page. Note that in these two cases, you are replacing every observation with the relevant means and then subsampling when running the regression so that the output labeling may not be what you want. If this is the case, an alternative way to do it is to create new workfile pages and then save the means to those pages. That's only a couple more steps...

1. Cross-section regressions

smpl @all
series ycxmean = @meansby(y, @crossid)
series x1cxmean = @meansby(x1, @crossid)
series x2cxmean = @meansby(x2, @crossid)
smpl if @cellid = 1
equation cxeq.ls ycxmean c x1cxmean x2cxmean

2. Period regressions

smpl @all
series ypermean = @meansby(y, @year)
series x1permean = @meansby(x1, @year)
series x2permean = @meansby(x2, @year)
smpl if @year = @min(@year)
equation pereq.ls ypermean c x1permean x2permean

3. Sub-group

Use Proc/Series classify... on the YEAR series to create an classification variable for your groups. Then do the same as (1) and (2) using your classification variable.

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

### Re: Average Cross-sectional Regression in Panel Data Structure

Thank you Glenn. with your codes, i managed to estimate year-wise regressions, cross-section regressions, cross-section average regression. All these results match with Stata output.
However, for estimating time series average regression (that is taking average across each ID for each year; kindly see #4 question), when i use the code:
smpl if @year = @min(@year)

EViews is telling me that "Near Singular Matrix"

Similarly, for sub-group estimations, i could not generate variables as you suggested.
Use Proc/Series classify... on the YEAR series to create an classification variable for your groups.

I have attached the EViews data sheet. Kindly have a look at it.
My apologies for bothering you too much.

Thank you.
Attachments
help_santosh.wf1
Kindle see the text file

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Average Cross-sectional Regression in Panel Data Structure

Sorry my fault. You want to find the period averages (taking averages across all cross-sections for each period), and then do the regression for a given cross-section. My sample statement was backward...

Code: Select all

`smpl @allseries ypermean = @meansby(cf, @year)series x1permean = @meansby(ds, @year)smpl if @crossid=1equation pereq.ls ypermean c x1permean`

Santosh
Posts: 26
Joined: Mon Sep 26, 2016 11:00 am

Thank you Glenn.