MATLAB Answers

Panel Data Regression

111 views (last 30 days)
I have to run a regression with a panel data. I have a sample of 94 elements and a time horizon of 5 years,a dependent variable (94x5) and 6 independent variables (94x5). How can I run an ols regression?

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 24 Jun 2014
Various panel regression models are covered in the above webinar. While fixed effects can be estimated using ols (fitlm function) random effects can be estimated using mle using the fitlme function
  1 Comment
Hamed Davari
Hamed Davari on 26 Feb 2019
This does not directly help, my friend. When someone asks something specific, she wants to get the specific answer, not a whole bunch of dispersed stuff in a video.

Sign in to comment.

More Answers (3)

the cyclist
the cyclist on 27 Jul 2011
You can use the following approach:
  • Purchase MATLAB
  • Download MATLAB
  • Purchase Econometrics Toolbox
  • Download Econometrics Toolbox
  • Use ordinary least squares functionality from Econometrics Toolbox. [I think the function may be called ols(), but I'm not sure.]
Of course, there are other approaches, but this one is pretty good.
  1 Comment
Pedram Davoudi
Pedram Davoudi on 25 Aug 2013
it's totally wrong

Sign in to comment.

Alessandra on 27 Jul 2011
I already have matlab and the econometrix toolbox but with ols regression I can not run a regression with a panel data, can I? with the ols regression I can run the regression year by year not considering all the years all together
  1 Comment
the cyclist
the cyclist on 28 Jul 2011
Sorry, since you mentioned ols(), I assumed that would work. I don't have the econ toolbox, so I can't explore easily. Try typing "lookfor panel -all" to search the help files (which will also search the toolbox functions).

Sign in to comment.

Muhammad Anees
Muhammad Anees on 12 Jun 2012
Hello: Late but a new member of Mathworks:
The following codes will work for you.
%%Classical estimation of the fixed effects panel data model
% Y and X stacked by cross-section; T is the time dimension
% Estimator for panel data with fixed effects (balanced panel)
% coeff contains the estimator of the slope (slope) and the fixed effects (fe)
% COVb contains the estimated covariance matrix of the slope estimator
[NT,m] = size(Y);
%within estimator
%build the matrix D
for i=1:N,
%compute the covariance matrix for the estimated coefficients
Tinashe Bvirindi
Tinashe Bvirindi on 23 May 2014
a panel is a collection of observations across entities and across time. it has both cross sectional and time series dimensions. the reason why the backslash operator is used is that it improves the efficiency of the code and reduces the degree of error where you require a repetitive estimation of the inverse... I hope this helps

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!