function [out] = lambdacon(theta,y,x,W) % This is the NEGATIVE of the concetrated log-likelihood where %lambda is the variable of concentration. %-------------------------------------------------------------- % OUTPUT: out = NEGATIVE one times the value of the lambda concentrated % log-likelihood % 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. 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 = -(-(n/2)*log(sqrt(2*pi)+1)-(n/2)*log(sig2hat) +log(det(S)));