https://github.com/cran/ltsa
Revision 0a03bbb7cf19e479dc77592ed09621eeb8afb470 authored by A.I. McLeod on 21 December 2015, 08:55:04 UTC, committed by cran-robot on 21 December 2015, 08:55:04 UTC
1 parent 83deceb
Tip revision: 0a03bbb7cf19e479dc77592ed09621eeb8afb470 authored by A.I. McLeod on 21 December 2015, 08:55:04 UTC
version 1.4.6
version 1.4.6
Tip revision: 0a03bbb
exactLoglikelihood.R
`exactLoglikelihood` <-
function(r, z, innovationVarianceQ=TRUE)
{
EPS<-.Machine$double.eps
r0 <- r[1] #need to input autocorrelation function to "trenchQFR"
r <- r/r[1]
if (r[1] < EPS)
stop("error: r[1] the variance is <= 0")
if (length(r) != length(z))
stop("error: r and z have unequal lengths")
out<-.C("trenchQFR", as.double(r), as.integer(length(r)),
as.double(z), as.integer(length(z)), EPS,
tr = array(0, dim=c(1,2 )), fault = as.integer(1),
PACKAGE="ltsa" )
fault<-out$fault
if (fault == 1)
stop("error: matrix is not p.d.")
n <- length(z)
S <-(out$tr)[1]
lg<-(out$tr)[2]
if (innovationVarianceQ) {
LL <- -0.5*n*(1+log(2*pi))-0.5*(n*log(S/n)+lg)
sigmaSq <- S/(n*r0)
}
else {
LL <- sigmaSq <- NA
}
list(LL=LL, sigmaSq=sigmaSq)
}
Computing file changes ...