function [ like ] = FCVARlike(x, k, r, db, EstnOptions)
% 
% function like = FCVARlike(x, k, r, db, options)
% Lee Morin & Morten Nielsen
% August 22, 2011
%
% FCVARlike(x, k, r, db, EstnOptions) is the likelihood function for the fractional AR model.
% 
% input = vector or matrix of data x.
%       scalar k denotes the number of lags.
%       scalar r denotes the cointegrating rank.
%       vector or scalar db of fractional differencing parameters.
%           The size of db indicates whether or not restriction d = b is imposed
%           based on the number of free parameters.
%       cell array of options EstnOptions, see DefaultEstnOptions(db0, k, r, p), 
%			RestrictEstnOptions(db0, k, r, p, defaultFCVARoptions), 
%			and AdjustEstnOptions(db0, k, r, p, initialFCVARoptions).
% 
% output = scalar like is the value of the log likelihood function evaluated at db, 
%       with all other parameters concentrated out. 
%
% Calls the function GetParams to get the OmegaHat matrix.
%______________________________________________________


% Determine desired set of options.
N = EstnOptions{1};

% Obtain concentrated parameter estimates.
[ estimates ] = GetParams(x, k, r, db, EstnOptions);
% estimates = { dbHat, alphaHat, betaHat, rhoHat, PiHat, OmegaHat, GammaHat } 
OmegaHat = cell2mat(estimates(6));

% Calculate value of likelihood function.
T = size(x,1) - N;
p = size(x,2);
like = - T*p/2*( log(2*pi) + 1)  - T/2*log(det(OmegaHat));



% end


