% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_missing_model.R
\name{ild_missing_model}
\alias{ild_missing_model}
\title{Fit a model for missingness (diagnostic / sensitivity)}
\usage{
ild_missing_model(
  x,
  outcome,
  predictors,
  random = FALSE,
  family = stats::binomial(),
  ...
)
}
\arguments{
\item{x}{An ILD object (see [is_ild()]).}

\item{outcome}{Character. Name of the variable with missingness (e.g. \code{"mood"}).}

\item{predictors}{Character vector. Names of covariates to predict missingness.}

\item{random}{Logical. If \code{TRUE}, fit \code{glmer(is_missing ~ ... + (1|id))};
if \code{FALSE} (default), fit \code{glm(is_missing ~ ., family = binomial)}.}

\item{family}{Passed to \code{glm} / \code{glmer} (default \code{binomial()}).}

\item{...}{Passed to \code{glm()} or \code{lme4::glmer()}.}
}
\value{
A list with \code{fit} (the fitted model or \code{NULL} if no/all missing),
  \code{tidy} (tibble: term, estimate, std_error, p_value), \code{outcome},
  \code{predictors}, and \code{message}. If \code{fit} is not \code{NULL},
  \code{p_missing} is a numeric vector of predicted P(missing) per row (aligned to \code{x}).
}
\description{
Fits a logistic model predicting whether the outcome is missing from
covariates. Use as a diagnostic; then [ild_ipw_weights()] to compute
inverse-probability weights and [ild_ipw_refit()] for a sensitivity analysis.
This is not a full MNAR solution—treat as diagnostic and sensitivity tooling.
}
\details{
**Not** run automatically by [ild_diagnose()]; it is the usual prerequisite for
[ild_ipw_weights()] when you want IPW summaries in the bundle (see [ild_diagnostics_utilities]).
}
\section{Bundle integration}{

There is no separate \dQuote{missingness model} slot on the bundle. This function
supports the IPW workflow; after [ild_ipw_weights()], [ild_diagnose()] can summarize
weights in \code{causal} on \code{\link{ild_diagnostics_bundle}}.
}

\examples{
set.seed(1)
d <- ild_simulate(n_id = 15, n_obs_per = 8, seed = 1)
d$stress <- rnorm(nrow(d))
d$mood <- d$y
d$mood[sample(nrow(d), 20)] <- NA
x <- ild_prepare(d, id = "id", time = "time")
mm <- ild_missing_model(x, "mood", "stress")
mm$tidy
}
\seealso{
[ild_diagnose()], [ild_diagnostics_bundle()], [ild_ipw_weights()]

Other ild_diagnostics_utilities: 
\code{\link{ild_design_check}()},
\code{\link{ild_ipcw_weights}()},
\code{\link{ild_iptw_msm_weights}()},
\code{\link{ild_iptw_weights}()},
\code{\link{ild_ipw_weights}()},
\code{\link{ild_joint_msm_weights}()},
\code{\link{ild_missing_cohort}()},
\code{\link{ild_missing_compliance}()},
\code{\link{ild_missing_hazard_first}()},
\code{\link{ild_missing_pattern}()},
\code{\link{ild_missingness_report}()}
}
\concept{ild_diagnostics_utilities}
