function LogLikelihood = no_kalman(hx,gx,SigX,Y,ny,T); %LogLikelihood = no_kalman(hx,gx,SigX,Y,ny,T); %Computes the log-likelihood function of a linearized model of the form: %x_{t+1} = hx * x_t + eta *epsilon_{t+1} %y_t = gx * x_t %where epsilon_t distributes N(0,I) %Inputs: %hx and gx (as described above) %SigX the unconditional variance/covariance matrix %of x_t (i.e., SigX satisfies SigX = hx*SigX*hx' + eta*eta'. %Y is a vector of stacked observations. There are ny time series each of length T, so Y is of length ny*T. %Specifically, if DATA is an ny-by-T matrix containing the data, then Y=DATA(:). %ny is the number of observables %T length of each time series %For details see the background paper ``Evaluating the Sample Likelihood of Linearized DSGE Models Without the Use of the Kalman Filter,'' by Stephanie Schmitt-Grohe and Martin Uribe, manuscript, Duke University, September 2007. %(This paper also explains how the program can easily accomodate measurement errors without modificaitons.) %(c) Stephanie Schmitt-Grohe and Martin Uribe, September 2007. HX = SigX*gx'; A=gx*HX/2; for i=1:T L((i-1)*ny+1:i*ny,1:size(A,2))= A; HX = hx*HX; A = [gx*HX A]; end OM_inverse = inv(L+L'); LogLikelihood = - ny*T/2 * log(2*pi) + 1/2 * log(det(OM_inverse)) - 1/2 * Y' * OM_inverse * Y