function negloglike=gmrf_negloglike_skeleton(theta,y,A,C,G,G2,B) % GMRF_NEGLOGLIKE_SKELETON Calculate the GMRF data likelihood, x integrated out % % negloglike=gmrf_negloglike_skeleton(theta,y,A,C,G,G2,B) % % theta = [log([tau2; kappa; sigma2_epsilon]); beta] % y = the data vector, as a column with n elements % A = the observation matrix, sparse n-by-N % C,G,G2 = matrices used to build a Matérn-like precision, % see matern_prec_matrices, sparse N-by-N % B = the expectation basis matrix, N-by-length(beta) % % This is only a skeleton for Home Assignment 2. % $Id: gmrf_negloglike_skeleton.m 4454 2011-10-02 18:29:12Z johanl $ n = size(y,1); tau2 = exp(theta(1)); kappa = exp(theta(2)); sigma2eps = exp(theta(3)); beta = theta(4:end); % Remove this line from your copy: warning('This is only a skeleton function! Copy it and fill in the blanks!') mu = []; Q_x = []; Q_xy = []; %Compute choleskey factor [R_x,p_x] = chol(Q_x); [R_xy,p_xy] = chol(Q_xy); if p_x~=0 || p_xy~=0 %choleskey factor fail -> (almost) semidefinite matrix -> %-> det(Q) ~ 0 -> log(det(Q)) ~ -inf -> negloglike ~ inf %Set negloglike to a REALLY big value negloglike = realmax; return; end mu_xy = []; negloglike = 0;