diff --git a/R/primary_censored_dist.R b/R/primary_censored_dist.R index 60ef7eb..299499b 100644 --- a/R/primary_censored_dist.R +++ b/R/primary_censored_dist.R @@ -285,6 +285,9 @@ primary_censored_cdf.pcens_pweibull_dunif <- function( # Use the lower incomplete gamma function scaled_t <- (t * inv_scale)^shape vapply(scaled_t, function(x) { + if (x <= 0) { + return(0) + } pracma::gammainc(x, 1 + inv_shape)["lowinc"] }, numeric(1)) } diff --git a/inst/stan/functions/primary_censored_dist_analytical_cdf.stan b/inst/stan/functions/primary_censored_dist_analytical_cdf.stan index 6030fa2..ff4d715 100644 --- a/inst/stan/functions/primary_censored_dist_analytical_cdf.stan +++ b/inst/stan/functions/primary_censored_dist_analytical_cdf.stan @@ -126,7 +126,7 @@ real primary_censored_lognormal_uniform_lcdf(data real d, real q, array[] real p } /** - * Compute the log of the integral of the Weibull PDF from 0 to t + * Compute the log of the lower incomplete gamma function * * This function is used in the analytical solution for the primary censored * Weibull distribution with uniform primary censoring. It corresponds to the