function y = lnnormfoc(theta,x); % This is the FOC w.r.t. theta of the log likelihood function for X ~ N(mu,sig2) %-------------------------------------------------------------- % OUTPUT: y1 = partial of likelihood function w.r.t to mu % y2 = partial of likelihood function w.r.t to sig2 % INPUT: theta = is a vector of the parameters of the distribution % theta(1,1) = mu - first entry of the vector is mu % theta(1,2) = sigma2 - second entry is variance % x = our vector of draws %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. m = size(x,1); xbar = mean(x); y(1) = m*(xbar - theta(1))/theta(2); y(2) = -m/(2*theta(2)) + sum((x - theta(1)).^2)/(2*(theta(2))^2);