Panel Data Regression

조회 수: 16 (최근 30일)
Alessandra
Alessandra 2011년 7월 27일
답변: Shashank Prasanna 2014년 6월 24일
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?

채택된 답변

Shashank Prasanna
Shashank Prasanna 2014년 6월 24일
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개)

Muhammad Anees
Muhammad Anees 2012년 6월 12일
Hello: Late but a new member of Mathworks:
The following codes will work for you.
%%Classical estimation of the fixed effects panel data model
function[coeff,COVb]=panFE(Y,X,T)
% 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);
[S,K]=size(X);
N=NT/T;
%within estimator
%build the matrix D
D=zeros(NT,N);
c=1;
for i=1:N,
D(c:T*i,i)=ones(T,1);
c=T*i+1;
end;
M=eye(NT)-D*inv(D'*D)*D';
b=inv(X'*M*X)*X'*M*Y;
a=inv(D'*D)*D'*(Y-X*b);
coeff.slope=b;
coeff.fe=a;
%compute the covariance matrix for the estimated coefficients
Xm=M*X;
Ym=M*Y;
res=Ym-Xm*b;
varres=(1/(NT-N-K))*res'*res;
COVb=varres*inv(X'*M*X);
  댓글 수: 2
Greg Heath
Greg Heath 2012년 6월 12일
1. What is the definition of "panel" data?
2. Why are you using INV instead of SLASH and BACKSLASH?
Hope this helps.
Greg
Tinashe Bvirindi
Tinashe Bvirindi 2014년 5월 23일
편집: Tinashe Bvirindi 2014년 5월 23일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by