R/b0.R

Defines functions llik.Sigma vS.mat B.mat G.l b0

Documented in b0

#' Empirical estimation of B0 (p. 344)
#'
b0 <- function(Sigma, B) {
    gMean.Sigma <- apply(Sigma, c(1, 2), mean)
    gMean.B <- apply(B, c(1, 2), sum)
    return(1 - gMean.Sigma - gMean.B)
}

G.l <- function(Sigma, t, l) apply(Sigma[, , t - (0:(l - 1))], c(1, 2), mean)

B.mat <- function(Theta) {
    B <- array(dim = c(length(Theta$b2), length(Theta$b2), 4))
    B[, , 2] <- matrix(1, nc = length(Theta$b2), nr = length(Theta$b2))
    B[, , 3] <- as.matrix(Theta$b2) %*% as.vector(Theta$b2)
    B[, , 4] <- as.matrix(Theta$b3) %*% as.vector(Theta$b3)
    B[, , 1] <- b0(Sigma, B[, , 2:4])
    return(B)
}

vS.mat <- function(Theta, t) {
    B <- B.mat(Theta)
    vS <- B[, , 1]
    for (j in 1:3) vS <- vS + B[, , j + 1] * G.l(Sigma, t, Theta$l[j])
    return(vS)
}

llik.Sigma <- function(Sigma, v) mixAK::dWISHART(Sigma[, , 40], Theta$v, 1/Theta$v * 
    vS.mat(Theta, 40))
voigtstefan/RrealCov documentation built on Sept. 23, 2017, 12:17 a.m.