Section2 - diag can generate a vector by taking the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Hendrik Wolff Some Matlab syntax discussed in section, January 26, 2006 (I) vector+scalar is possible (although dangerous, since it deviates from matrix rules). Instead of a “for loop”, i.e. for i=1:n e(i) = exp(Xb(i)+s2/2);end; %write e=exp(Xb+s2/2); % if you want to be more consistent with matrix rules, write: e=exp(Xb+ones(n,1)*s2/2); (II) The Two Meanings of the command diag Let V = s2*inv(X'*X); For calculating the standard error: Instead of writing se=zeros(4,1); for i=1:4 se(i)= sqrt(V(i,i));end;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: diag can generate a vector by taking the diagonal elements of a matrix. se = sqrt(diag(V)); diag can also generate a diagonal matrix DiagonalMatrix = diag(se); Hint: this command turns out to be useful for the construction of the robust covariance matrix term Σ [e 2 (i)x(i)x(i)']. (III) Parametric bootstrap: outboot=zeros(nboot,k); for iboot=1:nboot, u=floor(n*rand(n,1)+1); y_b=x*beta+eps(u,1); [beta_b]=ols(y_b,x); outboot(iboot,:)=beta_b'; end,...
View Full Document

This note was uploaded on 08/01/2008 for the course ARE 213 taught by Professor Imbens during the Spring '06 term at Berkeley.

Ask a homework question - tutors are online