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
Raw File
Tip revision: 0a03bbb7cf19e479dc77592ed09621eeb8afb470 authored by A.I. McLeod on 21 December 2015, 08:55:04 UTC
version 1.4.6
Tip revision: 0a03bbb
TrenchLoglikelihood.R
`TrenchLoglikelihood` <-
function( r, z )  
{
    EPS<-.Machine$double.eps
    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]
    -(n/2)*log(S/n)-(1/2)*lg
}

back to top