*
* %CXLogDensityCV(cvsigma,cvsigmahat,nobs)
* Generalization of %LogDensityCV to complex matrices. cvsigma should be
* an Hermitian p.d. matrix which is the theoretical value. cvsigmahat is
* also Hermitian p.d. and represents the sample value. nobs is the
* number of (effective) observations on which the sample is based.
*
* This computes the concentrated log likelihood. Use %CXLogDensity for
* the frequency-by-frequency log likelihood.
*
function %CXLogDensityCV cvsigma cvsigmahat nobs
type real %CXLogDensityCV
type cmatrix cvsigma cvsigmahat
type real    nobs
*
local vect[cmatrix] cxsvd
local integer n
local real    logdet trace
local cmatrix usigmau
*
compute n=%rows(cvsigma)
*
compute cxsvd=%cxsvd(cvsigma)
compute usigmau=%cxadj(cxsvd(1))*cvsigmahat*cxsvd(1)
sstats 1 n log(%real(cxsvd(2)(t,1)))>>logdet %real(usigmau(t,t)/cxsvd(2)(t,1))>>trace
compute %CXLogDensityCV=-.5*nobs*(logdet+trace)-.5*n*nobs*log(2*%pi)
end

