kalman_likeprofile.m

Revision 1 - 5/31/07 at 3:41 pm by e2holmes

Back to revision history for kalman_likeprofile.m
This file is part of the project Teaching code for State-space models
function [profpoints, likeprofile]=kalman_likeprofile(a, y, V1, param)
%This function does a likelihood profile of param, maximizing over the other parameters
%a is a vector of the initial values for the parameters
%param is the parameter that is being fixed
%This uses fmincon (minimization with constraints) to hold param constant while the others are maximized

%Don't display anything during the searching
myopt=optimset('Display','off');
warning('off');

%Set up the constraint matrix to hold param constant
%cf. matlab help page for fmincon function
Aeq = zeros(1, length(a));
Aeq(param) = 1;

scal = .05;
step = .005; %fraction of scal
%profile over range of scale:(scale+1)
if(param == 1) profpoints = (a(1)-scal):step:(a(1)+scal); 
else profpoints = -8:.25:0;
end

%profpoints = a(param);

likeprofile = zeros(1,length(profpoints));
for( Beq = profpoints ) 
   %fmincon(FUN,XO,A,B,Aeq,Beq,LB,UB,NONLCON, OPTIONS, P1, P2...)
   a(param)=Beq;
	aprof=fmincon('kalman_loglik',a, [], [], Aeq, Beq, [], [], [], myopt,y, V1, 0 );

likeprofile(find(Beq==profpoints)) = kalman_loglik( aprof,y,V1, 0);
end
Sculpin 0.2 | xhtml | problems or comments? | report bugs