Panel data regression (fixed effects)

29 次查看(过去 30 天)
I would like to run a panel data regression which is formatted in the following way:
-dependent variable:
*618x14038 (number of periods x observations per period) matrix of dependent variable
-independent variables:
*618x14038 matrix of independent variable (for starters I only have one independent variable, but other variables that might be of interest are formatted in the same way at this moment)
I would also like to include a constant term (which perhaps should be formatted as a 618x14038 matrix of ones).
My problems however are that
a) Regressions don't seem to work with matrix formatting. E.g.
[B,BINT,R,RINT,STATS] = regress(y, [ones(618,14038) x1])
returns the following error: "Y must be a vector and must have the same number of rows as X." (I am aware that this is not the correct regression to use for panel data, since it does not incorporate a time dimension, so it is purely to demonstrate my point about the formatting.)
b) I can't find a working function for a panel data regressions. For instance this toolbox gives the same error using the matrix formatting. It uses the following command:
x = panel( y, X, T, method, options )
Where y and x are the dependent and independent variable respectively, t is the number of sample periods, method is the method (e.g. fixed or random effects) and options, which can be used to request the calculation of Newey-West robust standard errors. I have tried to work around the matrix formatting problem by creating a column vector by using linear indexing, so:
y_vector=[]; x_vector=[];
for i=1:(618*14038)
y_vector(i,1)=x1(i);
x_vector(i,1)=x1(i);
end
And afterwards running
x = panel(y_vector, [ones((618*14038),1) x_vector], 618, 'fe', 'robust')
Which gave the following error: "Maximum variable size allowed by the program is exceeded." Which I found to be a bit odd, since (in my belief) I only used a constant term and one other variable.
Does anyone have any idea/recommendations on how to deal with these issues? If needed I can supply you with additional information. Thanks in advance.
Martin

回答(1 个)

Star Strider
Star Strider 2014-9-15
I’m guessing ‘x1’ is your (618x14038) matrix. Your call to regress should be:
[B,BINT,R,RINT,STATS] = regress(y, [ones(size(x1,1),1) x1]);
See if that improves things. I haven’t investigated the ‘paneldatatoolbox’.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by