Page **1** of **1**

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

Posted: **Fri Jul 07, 2017 12:48 pm**

by **Santosh**

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.

Highly appreciate your help.

Thank you.

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

Posted: **Mon Jul 10, 2017 8:44 pm**

by **Santosh**

Hi,

I would be grateful if someone can help me out.

Thank you.

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

Posted: **Tue Jul 11, 2017 9:56 am**

by **EViews Glenn**

Do you have a lot of series in your equation?

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

Posted: **Tue Jul 11, 2017 10:17 am**

by **Santosh**

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.

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

Posted: **Tue Jul 11, 2017 10:28 am**

by **EViews Glenn**

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.

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

Posted: **Tue Jul 11, 2017 11:41 am**

by **Santosh**

I have only "two" variables.

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

Posted: **Wed Jul 12, 2017 4:39 pm**

by **EViews Glenn**

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.

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

Posted: **Sat Jul 15, 2017 3:34 am**

by **Santosh**

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.

Highly appreciate your help.

Thank you.

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

Posted: **Mon Jul 24, 2017 1:05 pm**

by **EViews Glenn**

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...

For your data, you'll want

Code: Select all

`smpl @all`

series ypermean = @meansby(cf, @year)

series x1permean = @meansby(ds, @year)

smpl if @crossid=1

equation pereq.ls ypermean c x1permean

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

Posted: **Tue Jul 25, 2017 12:44 pm**

by **Santosh**

Thank you Glenn.