function [out] = lambdafoc(theta,y,x,W); % This is the first order condition of the concetrated log-likelihood where %lambda is the variable of concentration. %-------------------------------------------------------------- % OUTPUT: out = value of the lambda FOC function given % INPUT: theta(1,1) = lambda - first entry of the vector % y = (nx1) synthetic data % x = (nx1) synthetic data % W = (nxn) weight matrix constructed from z's %Strangly, we've found that variables of interest need to be included as "r %subscript 1" which in MatLab is "r(1)". We had to do this even when we %only have one variable. Here we have two variables. n = size(y,1); S = eye(n,n)-theta(1).*W; M = eye(n,n) -x*inv(x'*x)*x'; sig2hat = (1/n)*y'*S'*M*S*y; out = (1/sig2hat)*y'*W'*M*S*y-trace(W*inv(S));