---
title: "Importance sampling with censored univariate data"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Importance sampling with censored univariate data}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

`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.

```{r}
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)
```

For 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.
