R/cTMed-mc-ci-dot.R

Defines functions .MCCI

.MCCI <- function(object,
                  alpha = c(0.05, 0.01, 0.001)) {
  return(
    lapply(
      X = object$output,
      FUN = function(x) {
        idx <- seq_len(length(x$est) - 1)
        thetahat <- x$est[idx]
        thetahatstar <- x$thetahatstar[, idx, drop = FALSE]
        probs <- .PCProbs(alpha = alpha)
        ci <- vector(
          mode = "list",
          length = length(idx)
        )
        for (i in idx) {
          ci[[i]] <- .PCCI(
            thetahatstar = thetahatstar[, i],
            thetahat = thetahat[i],
            probs = probs
          )
        }
        ci <- do.call(
          what = "rbind",
          args = ci
        )
        ci <- cbind(
          interval = x$delta_t,
          ci
        )
        rownames(ci) <- colnames(thetahatstar)
        return(ci)
      }
    )
  )
}

Try the cTMed package in your browser

Any scripts or data that you put into this service are public.

cTMed documentation built on Oct. 21, 2024, 5:08 p.m.