R/cTMed-delta-central-dot.R

Defines functions .DeltaCentral

.DeltaCentral <- function(delta_t,
                          phi,
                          vcov_phi_vec,
                          total) {
  if (total) {
    Fun <- .TotalCentralVec
  } else {
    Fun <- .IndirectCentralVec
  }
  constructor <- function(delta_t,
                          varnames) {
    return(
      function(x) {
        output <- Fun(
          phi_vec = x,
          delta_t = delta_t
        )
        names(output) <- varnames
        return(output)
      }
    )
  }
  func <- constructor(
    delta_t = delta_t,
    varnames = colnames(phi)
  )
  dim(phi) <- NULL
  jacobian <- numDeriv::jacobian(
    func = func,
    x = phi
  )
  return(
    list(
      delta_t = delta_t,
      jacobian = jacobian,
      est = func(x = phi),
      vcov = jacobian %*% vcov_phi_vec %*% t(jacobian)
    )
  )
}

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.