R/tweibull.R

Defines functions tweibull

Documented in tweibull

#' Generate a function that simulates time-to-event outcome from a Weibull Cox PH model
#'
#' @param lambda scale parameter
#' @param nu shape parameter
#'
#' @return function
#' @export
#'
#' @examples
#' tweibull(0.5, 1)
tweibull <- function(lambda, nu){
  if(lambda <= 0) stop("scale parameter lambda must be strictly greater than 0")
  if(nu <= 0) stop("shape parameter nu must be strictly greater than 0")
  function(U, Xbeta) {
    (-(log(U)) / (lambda * exp(Xbeta)))^(1/nu)
  }
}
a-chernofsky/project2 documentation built on Oct. 21, 2021, 10:23 p.m.