您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 企业财务 > 第matlab计量经济学多重共线性的诊断与处理
第五节多重共线性的诊断与处理5.1多重共线性的诊断数据来源:《计量经济学》于俊年编著对外经济贸易大学出版社2000.6p208-p209某国1998-1998的经济数据年份进口额(y)国内产值(x1t)存货额(x2t)国内消费(x3t)198815.9149.34.2108.1198916.4161.24.1114.8199019171.53.1123.2199119.1175.53.1126.9199218.8180.81.1132.1199320.4190.72.2137.7199422.7202.12.1146199526.5212.15.6154.1199628.1226.15162.3199727.6231.95.1164.3199826.32390.7167.65.1.1条件数与病态指数诊断重共线性。,则认为存在严重的多共线性;若或较强的多重,则认为存在中等程度很小;则认为多重共线性程度重共线性。,则认为存在严重的多的多重共线性;若或较强,则认为存在中等程度度很小;若,则认为多重共线性程阵(不包括常数项)为自变量的相关系数矩303010,1010001000100100)()()()(minmax1CICICIRRCIRRRRR设x1,x2,…,xp是自变量X1,X2,…XP,经过中心化和标准化得到的向量,即:RxxXXXXxTiii2)(记(x1,x2,…,xp)为x,设为xTx一个特征值,为对应的特征向量,其长度为1,若0,则:0221122110000cXcXcXcxxxxxxxxppppTTTT根据上表,计算如下:x=[149.3,4.2,108.1;161.2,4.1,114.8;171.5,3.1,123.2;175.5,3.1,126.9;180.8,1.1,132.1;190.7,2.2,137.7;202.1,2.1,146;212.1,5.6,154.1;226.1,5,162.3;231.9,5.1,164.3;239,0.7,167.6]求x的相关矩阵RR=corrcoef(x)R=1.000000000000000.024470490835730.997152185820790.024470490835731.000000000000000.035673222920070.997152185820790.035673222920071.00000000000000求R的条件数:cond(R)ans=7.178039564809832e+002也可先求R的特征值e=eig(R)e=0.002784831061250.998252415043421.99896275389533注:3自变量的个数=ee(3)/e(1)ans=7.178039564809491e+002条件数为717.804,大于100,存在较严重的多重共线性。为了进一步了解哪些变量之间存在线性关系,计算相关矩阵的特征值和相应的特征向量:[v,d]=eig(R)v=0.706964538965750.035698735796330.706347464713710.00795062868633-0.999063342195630.04253499482058-0.707204304390490.024454826587770.70658618250581d=0.002784831061250000.998252415043420001.99896275389533注意:Rv=vdv为标准正交矩阵最小的特征值为0.00278483106125,对应的向量为:(0.70696453896575,0.00795062868633,-0.70720430439049)T考虑到第二个数0.00795062868633约等于0,从而即:07072.0707.031xx所以存在310,,ccc使得:03211cxcxc5.1.2方差膨胀因子诊断每一个自变量对应的方差膨胀因子为R-1相应的对角元素rjj。若记xj关于其他p-1个自变量的复相关系数为Rj则有:}{max112jjjjjjrVIFRr如果VIF5,则认为自变量间不存在多重共线性。如果性。程度或较强的多重共线就认为自变量间存中等,105VIF如果VIF10,则认为自变量间存在严重的多重共线性。在本例中:diag(inv(R))ans=1.0e+002*1.797227470436430.010234788725901.79843993838056VIF=max(diag(inv(R)))VIF=1.798439938380555e+002VIF远大于10,存在严重的多重共线性。注意:书上结果错了,我用SPSS算了,也是这个结果。方差膨胀因子也可按此计算:x1=x(:,1);x2=x(:,2);x3=x(:,3);[bbint,r,rint,stats]=regress(x1,[ones(11,1)x2x3]);一定要常数项1/(1-stats(1))ans=1.797227470435788e+0025.1.3容许度(Tolerance)诊断若记xj关于其他p-1个自变量的复相关系数为Rj则有:Tolj=1-R2j它是方差膨胀化因子的倒数。越小自变量共线性越强。小于0.1高度共线在本例中:Tol=1./diag(inv(R))Tol=0.005564125946490.977059738878030.00556037473734最小的值远小0.1,高度多重共线性。5.1.4方差比例诊断(看AppliedEconometricusingMatlab的第84页)注意:AppliedEconometricusingMatlab的第84页,4.4式是错的,4.3,4.5,4.6式是对的。某国1998-1998的经济数据年份进口额(y)国内产值(x1t)存货额(x2t)国内消费(x3t)198815.9149.34.2108.1198916.4161.24.1114.8199019171.53.1123.2199119.1175.53.1126.9199218.8180.81.1132.1199320.4190.72.2137.7199422.7202.12.1146199526.5212.15.6154.1199628.1226.15162.3199727.6231.95.1164.3199826.32390.7167.6x1=[149.3,4.2,108.1;161.2,4.1,114.8;171.5,3.1,123.2;175.5,3.1,126.9;180.8,1.1,132.1;190.7,2.2,137.7;202.1,2.1,146;212.1,5.6,154.1;226.1,5,162.3;231.9,5.1,164.3;239,0.7,167.6];x=[ones(size(x1,1),1),x1];vnames=strvcat('constant','x1','x2','x3');fmt='%12.6f';bkw(x,vnames,fmt);Belsley,Kuh,WelschVariance-decompositionK(x)constantx1x2x310.0000000.0000510.0000000.0000121400.0000060.1402840.5981360.1169481880.0000110.6802080.3756800.64626319780.9999830.1794570.0261840.236777K(x)=188时,有两个方差比例大于0.5,x1与x3可以存在共线性。K(X)30或者方差比例0.5,则存在多重共线性。上表的算法:[nobsnvar]=size(x);[udv]=svd(x,0);lamda=diag(d(1:nvar,1:nvar));lamda2=lamda.*lamda;v=v.*v;phi=zeros(nvar,nvar);fori=1:nvar;phi(i,:)=v(i,:)./lamda2';end;pi=zeros(nvar,nvar);fori=1:nvar;phik=sum(phi(i,:));pi(i,:)=phi(i,:)/phik;end;pi'ans=0.000000000004280.000051213866180.000000007535680.000012482052740.000006063715880.140283737583560.598136161578560.116947537521540.000010667849280.680208481806630.375680295735650.646262520841230.999983268430560.179456566743630.026183535150110.23677745958449K(x)的算法:[udv]=svd(x,0);d1=diag(d);d1=1.0e+002*8.028370999629810.057460066311730.042602312882930.00405906633001kx=[d1(1)/d1(1);d1(1)/d1(2);d1(1)/d1(3);d1(1)/d1(4)]kx=1.0e+003*0.001000000000000.139720879472630.188449181660431.977886131170545.2多重共线性的处理可参见《经济计量学》李景华编著中国商业出版社第四章5.2.1岭回归(脊回归)年份进口额(y)国内产值(x1t)存货额(x2t)国内消费(x3t)198815.9149.34.2108.1198916.4161.24.1114.8199019171.53.1123.2199119.1175.53.1126.9199218.8180.81.1132.1199320.4190.72.2137.7199422.7202.12.1146199526.5212.15.6154.1199628.1226.15162.3199727.6231.95.1164.3199826.32390.7167.6x=[149.3,4.2,108.1;161.2,4.1,114.8;171.5,3.1,123.2;175.5,3.1,126.9;180.8,1.1,132.1;190.7,2.2,137.7;202.1,2.1,146;212.1,5.6,154.1;226.1,5,162.3;231.9,5.1,164.3;239,0.7,167.6];y=[15.9;16.4;19;19.1;18.8;20.4;22.7;26.5;28.1;27.6;26.3];bb=zeros(4,101);kvec=0:0.01:1;count=0;fork=0:0.01:1b(:,count)=ridge(y,[ones(11,1)x],k);endplot(kvec',b'),xlabel('k'),ylabel('b','FontName','Symbol')00.20.40.60.81-50510152025k点击最上面一要线,删除得:00.20.40.60.81-20246k如果不想在图中包括常数项,则可:bb=zeros(3,101);kvec=0:0.01:1;count=0;fork=0:0.01:1count=count+1;bb(:,count)=ridge(y,x,k);endplot(kvec',bb'),xlabel('k'),ylabel('b','FontName','Symbol')00.20.40.60.81-20246k为了看清k在0到0.1之间回归系数的变化情况,则:bb=zeros(3,11)
本文标题:第matlab计量经济学多重共线性的诊断与处理
链接地址:https://www.777doc.com/doc-7099365 .html