Internal function for the Mixed-Effects Model Calibration Curve (MIXC)
MIXC.RdEstimates the calibration curve using a logistic generalized linear mixed model.
Arguments
- data
optional data frame containing the variables
p,y, andcluster. 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, whenCI_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:
modelThe fitted mixed-effects model object
cluster_dataData frame with calibration data for each cluster
plot_dataData frame with calibration data for the average cluster
observed_dataData frame with calibration data for individual observations
plotA
ggplot2object ifplot = TRUE, otherwiseNULL