% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_ipw_weights.R
\name{ild_ipw_weights}
\alias{ild_ipw_weights}
\title{Compute inverse-probability-of-observation weights from a missingness model}
\usage{
ild_ipw_weights(x, miss_fit, stabilize = TRUE, trim = c(0.01, 0.99))
}
\arguments{
\item{x}{An ILD object (see [is_ild()]); rows must align to the data used to fit \code{miss_fit}.}

\item{miss_fit}{The return value of [ild_missing_model()] (list with \code{fit}, \code{p_missing}, etc.).}

\item{stabilize}{Logical. If \code{TRUE} (default), use stabilized weights
\code{mean(p_obs) / p_obs}; otherwise \code{1 / p_obs}.}

\item{trim}{Numeric of length 2. Quantiles to trim weights (default \code{c(0.01, 0.99)}).
Weights below/above these quantiles are set to the quantile values.}
}
\value{
\code{x} with an added column \code{.ipw} (numeric). ILD attributes are preserved.
}
\description{
Uses the fitted missingness model from [ild_missing_model()] to compute
weights: unstabilized \code{w = 1 / p_obs} or stabilized
\code{w = mean(p_obs) / p_obs}. Weights are trimmed to avoid extremes.
Use with [ild_ipw_refit()] for sensitivity analysis. This is diagnostic
and sensitivity tooling, not a full MNAR solution.
}
\details{
Also a **section provider** for [ild_diagnose()] when \code{.ipw} is present on the
analysis data (see [ild_diagnostics_utilities]).
}
\section{Bundle integration}{

Adds \code{.ipw} to \code{x}. When that column is on the ILD data attached to the fit,
[ild_diagnose()] fills \code{causal} (weight summaries) 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")
xw <- ild_ipw_weights(x, mm, stabilize = TRUE)
summary(xw$.ipw)
}
\seealso{
[ild_diagnose()], [ild_diagnostics_bundle()], [ild_missing_model()],
  [ild_iptw_weights()], [ild_ipcw_weights()], [ild_joint_msm_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_joint_msm_weights}()},
\code{\link{ild_missing_cohort}()},
\code{\link{ild_missing_compliance}()},
\code{\link{ild_missing_hazard_first}()},
\code{\link{ild_missing_model}()},
\code{\link{ild_missing_pattern}()},
\code{\link{ild_missingness_report}()}
}
\concept{ild_diagnostics_utilities}
