Skip to contents

Estimates the calibration curve using a logistic generalized linear mixed model.

Usage

MIXC(
  data = NULL,
  p,
  y,
  cluster,
  grid,
  method = c("slope", "intercept"),
  plot = TRUE,
  cluster_curves = FALSE,
  nsims_pi = 10000,
  CI = TRUE,
  CI_method = c("naive", "delta"),
  cl.level = 0.95
)

Arguments

data

optional data frame containing the variables p, y, and cluster. If supplied, variable names should be given without quotation marks.

p

predicted probabilities (numeric vector) or name of the column in data.

y

binary outcome variable or the name of the column in data.

cluster

Cluster identifier (factor, character, or integer) or name of the column in data.

grid

the grid for the calibration curve evaluation

method

character, type of mixed-effects model: "intercept" (random intercept) or "slope" (random slope). Default is "slope".

plot

logical, indicating whether to generate a calibration plot. Default is TRUE.

cluster_curves

logical, whether to include cluster-specific curves in the plot. Default is FALSE.

nsims_pi

integer, number of simulations for prediction intervals. Default is 10000.

CI

logical, whether to calculate confidence intervals. Default is TRUE.

CI_method

character, method for computing the confidence intervals of the observed proportions. If "delta", the delta method is applied. Conversely, when CI_method == "naive", no correction is applied. Default is "naive".

cl.level

the confidence level for the calculation of the confidence interval. Default is 0.95.

Value

A list containing:

model

The fitted mixed-effects model object

cluster_data

Data frame with calibration data for each cluster

plot_data

Data frame with calibration data for the average cluster

observed_data

Data frame with calibration data for individual observations

plot

A ggplot2 object if plot = TRUE, otherwise NULL

Details

This function estimates the calibration curves using a logistic generalized linear mixed model.