UniIS combines an observed-data likelihood layer with
importance sampling on the parameter space. This separation is central:
probability functions describe the outcome distribution, while a
proposal describes how parameters are drawn.
library(UniIS)
set.seed(1)
x <- rexp(50, 1.2)
fit <- is_fit(
x,
pdf = function(x, theta) dexp(x, exp(theta[1])),
cdf = function(x, theta) pexp(x, exp(theta[1])),
survival = function(x, theta) pexp(x, exp(theta[1]), lower.tail = FALSE),
theta0 = 0,
proposal = is_proposal_normal(0, 0.75),
control = is_control(n_draws = 500, seed = 1)
)
summary(fit)
#> Importance-sampling inference summary
#>
#> MLE IS mean IS SD 2.5% 50% 97.5%
#> theta1 0.1984084 0.1938046 0.1582861 -0.1170681 0.205078 0.4836634
#>
#> log likelihood: -40.07957
#> ESS: 105.7For right censoring, give x and a status vector with
1 for an event and 0 for a right-censored
observation. The same model functions are used; only the likelihood
representation changes.