%function [thet]=Estimateit clear all; clc; Num=100; %generate 100 data sets for i=1:Num T=100; %generate the data set artificial(0,1,T); load data; %plot(1:T,data); %set initial conditions x0=[0,1]; H0=eye(2); crit=0.00001; nit=100; % find likelihood maximizer with csminwel [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(@makelike, x0, H0, [], crit, nit, data); % find likelihood maximizer with fminsearch (built into matlab) x=fminsearch(@makelike,x0,[],data); %store results resul(i,:)=xh; resu(i,:)=x; end %plot results figure(2) hist(resul(:,1)) figure(3) hist(resu(:,1)) %compute number of reasonable results for the first method ones(size(resul(:,1)))'*((abs(resul(:,1))<10).*ones(size(resul(:,1)))) %compute number of reasonable results for the second method ones(size(resu(:,1)))'*((abs(resu(:,1))<10).*ones(size(resu(:,1))))