## -----------------------------------------------------------------------------
library(summary2joint)
set.seed(31)
variables <- list(age = list(type = "continuous"),
                  response = list(type = "binary"),
                  severity = list(type = "ordinal", levels = 3L))
studies <- lapply(seq_len(80), function(i) {
  z <- matrix(rnorm(300), 100, 3)
  z[, 2] <- 0.4 * z[, 1] + sqrt(0.84) * z[, 2]
  age <- 55 + 8 * z[, 1]
  response <- as.integer(z[, 2] > 0)
  severity <- findInterval(z[, 3], c(-Inf, -0.5, 0.5, Inf))
  list(n = 100L, summaries = list(
    age = list(mean = mean(age), sd = sd(age)),
    response = list(events = sum(response)),
    severity = list(counts = tabulate(severity, 3))))
})
fit <- fit_summary_copula(studies, variables)
fit
fit$diagnostics[c("converged", "boundary", "inference_ok")]

## -----------------------------------------------------------------------------
joint_probability(fit, lower = c(age = 60, response = 1, severity = 2))
head(simulate_summary_copula(fit, n = 100, seed = 42))
confint(fit)

