Section2

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

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

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;
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern