R/CGaM.R

Defines functions CGaM

CGaM <-
  function(times, tao, K, covar, theta) {
    m <- rep(0, K)
    for(i in 1:length(times)) {
      for(k in 1:K) {
        if (tao[k + 1] < times[i]) {
          m[k] <- m[k] + (tao[k + 1] - tao[k]) * exp(theta %*% covar[i, ])
        }
        if (tao[k] < times[i] && times[i] <= tao[k + 1]) {
          m[k] <- m[k] + (times[i] - tao[k]) * exp(theta %*% covar[i, ])
        }
      }
    }
    return(m)
  }

Try the BGPhazard package in your browser

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

BGPhazard documentation built on Sept. 3, 2023, 5:09 p.m.