08、统计学这么好赚钱啊!我也要成为数据分析和建模大师,快给我个学校电话,我要报名!
答:(第三部分)下面我们就来看看这个项目实际上究竟多么有杀气吧。先从计量经济学说起。我们说说计量经济学2.这门课包括三个内容,bootstrap、非参数模型以及面板数据分析。也许听起来还可以,不过我们现在给大家看看常用的面板数据分析的上机实习(答案)是什么样的吧。
先看看最简单的估计量长什么样
然后再看看为了实现上机实习目标,给出的样例程序(我发现空格都没了)
% program AE2pGMMs2Stest.m (J.F.Kiviet@uva.nl)disp(Program AE2pGMMs2Stest); clear; clc;disp(Examines GMMsystem estimator and Sargan tests);disp( in finite samples of a stable panel AR(1) model);startseed=20120131; startrandom = RandStream(mcg16807, Seed, startseed);RandStream.setDefaultStream(startrandom);mingam=0.1; maxgam=0.9; numbgam=5;minT=4; maxT=10; numbT=7;R=1000; psi=1; phi=1; N=100;disp([ N = num2str(N) , psi = num2str(psi) , phi = num2str(phi)]);disp([ R = num2str(R) , seed = num2str(startseed)]);stepgam = (maxgam - mingam)/(numbgam - 1);vecgam = mingam + stepgam*(cumsum(ones(numbgam,1))-1);disp( gamma values: ); disp(vecgam);stepT=(maxT - minT)/(numbT - 1);vecT=minT + stepT*(cumsum(ones(numbT,1))-1);disp( T values: ); disp(vecT);ghat1 = zeros(numbgam, numbT);ghat1rep = ghat1; ghat2 = ghat1; ghat2rep = ghat1; ghat22 = ghat1;ghatAB1=ghat1; ghatAB1rep=ghat1; ghatAB2=ghat1; ghatAB2rep=ghat1;ghatAB22=ghat1;Srgsysrej=ghat1; Srgsysrejrep=ghat1;SrgABrej=ghat1; SrgABrejrep=ghat1;Srgincrej=ghat1; Srgincrejrep=ghat1;ALFA = randn(N,R);maxLAB = maxT*(maxT - 1)/2; % number of instruments for GMM-ABH = 2*eye(maxT - 1); % matrix H of weight matrixtt = 1;while tt < maxT-1tt = tt+1;H(tt,tt-1) = -1;H(tt-1, tt) = -1;end % iL */YY = zeros(maxT, N); YL = YY; DY = YY; ZABi = zeros(maxT-1,maxLAB);rep = 0;while rep < Rrep = rep + 1;6EPS = randn(maxT+1,N);igam = 0;while igam < numbgamigam = igam+1;gam = vecgam(igam);kappa1 = phi/(1-gam);gam2 = gam*gam;kappa2 = 1/sqrt(1-gam2);sigalfa = psi*sqrt((1-gam)/(1+gam));sigalfa2 = sigalfa*sigalfa;ZABtY = zeros(maxLAB, 1);ZABtX = ZABtY;ZStY = zeros(maxT-1,1); ZStX = ZStY;Winv11 = zeros(maxLAB, maxLAB);Winv12 = zeros(maxLAB,maxT-1); Winv22 = zeros(maxT-1,maxT-1);i = 0;while i < Ni = i+1;YL(1,i) = ALFA(i,rep)*kappa1*sigalfa+EPS(maxT+1,i)*kappa2;YY(1,i) = gam*YL(1,i) + sigalfa*ALFA(i,rep) + EPS(1,i);tt = 1;while tt < maxTtt = tt+1;YL(tt,i) = YY(tt-1,i);YY(tt,i) = gam*YY(tt-1,i) + sigalfa*ALFA(i,rep) + EPS(tt,i);endDY(:,i) = YY(:,i) - YL(:,i);tt = 0; iL = 0;while tt < maxT-1iL = iL + tt;tt = tt + 1;ZABi(tt,iL+1:iL+tt) = YL(1:tt,i); % i-th block AB instr.endZABitZSi = (ZABi)*diag(DY(1:maxT-1,i)); % ZSi eff.stat. instr.ZSitZSi = diag(DY(1:maxT-1,i).^2);Winv11 = Winv11 + ZABi*H*ZABi;Winv22 = Winv22 + ZSitZSi;ZABtY = ZABtY + ZABi*DY(2:maxT,i);ZABtX = ZABtX + ZABi*DY(1:maxT-1,i);ZStY = ZStY + DY(1:maxT-1,i).*YY(2:maxT,i);ZStX = ZStX + DY(1:maxT-1,i).*YL(2:maxT,i);endiT = 0;while iT < numbTiT = iT+1; T = vecT(iT); LAB = T*(T-1)/2; L = LAB+T-1;Winv = [Winv11(1:LAB,1:LAB),zeros(LAB,T-1);zeros(T-1,LAB),Winv22(1:T-1,1:T-1)];WABinv = Winv11(1:LAB,1:LAB);W = eye(L)/Winv;WAB = eye(LAB)/WABinv;NUM = [ZABtX(1:LAB); ZStX(1:T-1)]*W*[ZABtY(1:LAB);ZStY(1:T-1)];DEN = [ZABtX(1:LAB); ZStX(1:T-1)]*W*[ZABtX(1:LAB);ZStX(1:T-1)];7ghat1rep(igam,iT) = NUM/DEN;NUM = ZABtX(1:LAB)*WAB*ZABtY(1:LAB);ghatAB1rep(igam,iT) = NUM/(ZABtX(1:LAB)*WAB*ZABtX(1:LAB)); % GMMAB1i = 0; W2inv = zeros(L,L); Ztuhat = zeros(L,1);% now the 2-step GMMsWAB2inv = zeros(LAB,LAB); ZtuhatAB = zeros(LAB,1);while i < Ni = i+1;tt = 0; iL = 0; % again construct i-th block of AB instrumentswhile tt < T-1iL = iL+tt; tt = tt+1;ZABi(tt,iL+1:iL+tt) = YL(1:tt,i);enduhat1 = DY(2:T,i)-DY(1:T-1,i)*ghat1rep(igam,iT);uhat = [uhat1;(YY(2:T,i)-YY(1:T-1,i)*ghat1rep(igam,iT))];Ztuhati = [ZABi(1:T-1,1:LAB)*uhat(1:T-1);(DY(1:T-1,i).*uhat(T:2*T-2))];Ztuhat = Ztuhat + Ztuhati;W2inv = W2inv + Ztuhati*Ztuhati;uhatAB = DY(2:T,i) - DY(1:T-1,i)*ghatAB1rep(igam,iT);ZtuhatABi = ZABi(1:T-1,1:LAB)*uhatAB(1:T-1);ZtuhatAB = ZtuhatAB + ZtuhatABi;WAB2inv