L-dgao 发表于 2013-5-2 12:56
你再检查一下你前后变量的维度是不是一致的,首先逻辑上不能存在错误吧,关于这两行,这只是一个演示文件 ...
你好,很开心你能帮我的忙,
这个是原始工具箱里的部分
% dimensions of the problem
T=6; % number of time periods
N=46; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[4,5,6]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);
[nobs K]=size(x);
% ----------------------------------------------------------------------------------------
输出的结果是
Warning: WK1READ will be removed in a future release.
Warning: WK1READ will be removed in a future release.
Ordinary Least-squares Estimates
Dependent Variable = logcit
R-squared = 0.3861
Rbar-squared = 0.3794
sigma^2 = 0.0320
Durbin-Watson = 1.8047
Nobs, Nvars = 276, 4
***************************************************************
Variable Coefficient t-statistic t-probability
intercept 1.605485 5.435955 0.000000
logp -1.041989 -8.610354 0.000000
logpn 0.146363 1.176771 0.240316
logy 0.703143 10.651591 0.000000
loglikols =
85.5537
LM test no spatial lag, probability = 2.8677, 0.090
robust LM test no spatial lag, probability = 1.5139, 0.219
LM test no spatial error, probability = 6.3199, 0.012
robust LM test no spatial error, probability = 4.9661, 0.026
Wrong # of variable names in prt_reg -- check vnames argument
will use generic variable names
Ordinary Least-squares Estimates
R-squared = 0.4634
Rbar-squared = 0.4595
sigma^2 = 0.0015
Durbin-Watson = 1.8004
Nobs, Nvars = 276, 3
***************************************************************
Variable Coefficient t-statistic t-probability
variable 1 -0.597372 -12.071931 0.000000
variable 2 0.162570 2.598087 0.009883
variable 3 0.335686 9.102462 0.000000
FE_rsqr2 =
0.9716
loglikfe =
509.8241
LM test no spatial lag, probability = 12.7208, 0.000
robust LM test no spatial lag, probability = 4.7332, 0.030
LM test no spatial error, probability = 23.6084, 0.000
robust LM test no spatial error, probability = 15.6207, 0.000
Wrong # of variable names in prt_reg -- check vnames argument
will use generic variable names
Ordinary Least-squares Estimates
R-squared = 0.4272
Rbar-squared = 0.4230
sigma^2 = 0.0013
Durbin-Watson = 2.0461
Nobs, Nvars = 276, 3
***************************************************************
Variable Coefficient t-statistic t-probability
variable 1 -0.648719 -13.267854 0.000000
variable 2 0.067473 1.072247 0.284556
variable 3 0.317823 4.891167 0.000002
LM test no spatial lag, probability = 0.9402, 0.332
robust LM test no spatial lag, probability = 3.8306, 0.050
LM test no spatial error, probability = 4.0933, 0.043
robust LM test no spatial error, probability = 6.9837, 0.008
以下是我对上述原始工具箱改的部分
% dimensions of the problem
T=13; % number of time periods
N=30; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[1]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[2,3,4]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);
[nobs K]=size(x);
% ----------------------------------------------------------------------------------------
输出的结果是
Warning: WK1READ will be removed in a future release.
Warning: WK1READ will be removed in a future release.
Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> demoLMsarsem_panel at 30
results=ols(y,[xconstant x]);
我很奇怪 我的数据明明是13年的30个省份的面板数据,为什么我改后会错了呢?难道是我对x和y变量的位置改错了?不是y=A(:,[1]); x=A(:,[2,3,4]); 而是y=A(:,[3]); x=A(:,[4,5,6]);?