function [L] = neolike(xh,tmax, tmin, y2); %transform back xh=transform(xh,tmax,tmin,2); %recover parameters beta=xh(1); g=xh(2); ro=xh(3); alpha=xh(4); fi=xh(5); lambda=xh(6); delta=xh(7); sigmay=xh(8); sigmak=xh(9); sigmac=xh(10); sigmal=xh(11); vol=xh(12); %rename data y0=y2(:,1); k0=y2(:,2); c0=y2(:,3); l0=y2(:,4); %solve the model %new parameters - definitions teta=((((1+g)^(1-fi*(1-ro)))/beta)-(1-delta))/alpha;%%=cap/gdp nu=1-(delta+g)/teta; %=cons/gdp labor=1-1/(1+fi*(1-alpha)/(nu*(1-fi))); %steady state values cap=labor/(teta^(1/(1-alpha))); gdp=teta*cap; cons=nu*gdp; %more parameter definitions phi=alpha*beta*gdp/((1+g)*cap); omega=fi*(1-ro)-1; a1=labor/(1-labor); pi=(1-fi)*(1-ro)*a1; %matrices D=[ 0,-phi,-omega,pi,0,phi,omega,-pi; -gdp,(1+g)*cap,cons,0,0,0,0,0; 1,0,0,-(1-alpha),-1,0,0,0; 1,0,-1,-(1+a1),0,0,0,0; 0,0,0,0,1,0,0,0; 1,0,0,0,0,0,0,0; 0,1,0,0,0,0,0,0; 0,0,1,0,0,0,0,0;]; E=[ 0,0,0,0,0,0,0,0; 0,(1-delta)*cap,0,0,0,0,0,0; 0,alpha,0,0,0,0,0,0; 0,0,0,0,0,0,0,0; 0,0,0,0,lambda,0,0,0; 0,0,0,0,0,1,0,0; 0,0,0,0,0,0,1,0; 0,0,0,0,0,0,0,1;]; %use gensys [G,C,impact,fmat,fwt,ywt,gev,eu]=gensys(D,E,zeros(8,1),[0;0;0;0;1;0;0;0],[0,0,0; 0,0,0; 0,0,0; 0,0,0; 0,0,0; 1,0,0; 0,1,0; 0,0,1]); if eu(1)==1 && eu(2)==1 F = G([1,2,3,4,5],[1,2,3,4,5]); %H = [1 0 0 0 0; 0 0 1 0 0; 0 0 0 1 0]; H=[eye(4),zeros(4,1)];%G([1,2,3,4],[2,5]); Q = vol*impact([1,2,3,4,5])*impact([1,2,3,4,5])'; %R = diag([sigmay,sigmac,sigmal]); R = diag([sigmay,sigmak,sigmac,sigmal]); %initx = [y0(1);0;c0(1);l0(1);0]; initx = [y0(1);k0(1);c0(1);l0(1);0]; initV = 0.1*eye(5); y1=y2'; %filter the data and find the conditional likelihood [xfilt, Vfilt, VVfilt, loglik] = kalman_filter(y1, F, H, Q, R, initx, initV); L=-loglik; else L=100000000000000000000000000; %if the solution is not unique or does not exist, we place a very low %probability on it end