% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_iptw_weights.R
\name{ild_iptw_weights}
\alias{ild_iptw_weights}
\title{Inverse probability of treatment weights (IPTW)}
\usage{
ild_iptw_weights(
  x,
  treatment,
  predictors,
  stabilize = TRUE,
  trim = c(0.01, 0.99),
  ...
)
}
\arguments{
\item{x}{An ILD object (see [is_ild()]).}

\item{treatment}{Character. Name of a **binary** treatment column (numeric
\code{0}/\code{1} or two-level factor).}

\item{predictors}{Character vector of covariate names in \code{x} (main terms only).}

\item{stabilize}{Logical. If \code{TRUE} (default), stabilized weights
\eqn{P(A)/P(A|X)} for the observed \eqn{A}; otherwise \eqn{1/P(A|X)}.}

\item{trim}{Numeric of length 2. Quantiles for trimming (default \code{c(0.01, 0.99)}).}

\item{...}{Passed to \code{stats::glm()}.}
}
\value{
\code{x} with added column \code{.ipw_treat}. Attributes include
  \code{ild_iptw_fit} (the fitted \code{glm} object).
}
\description{
Fits a **single pooled** treatment propensity model (logistic regression)
over all person-occasions and computes stabilized or unstabilized IPTW weights
(one factor per row). Use this for a **time-invariant** treatment or descriptive
pooling. For **time-varying** \eqn{A_t} with a sequential MSM estimand, use
[ild_iptw_msm_weights()] instead. Outcome missingness IPW is
[ild_missing_model()] + [ild_ipw_weights()].
}
\details{
**Assumptions:** Positivity (\eqn{0 < P(A|X) < 1}), correct specification of
the treatment model. This is sensitivity / MSM-style tooling, not a substitute
for careful causal design.
}
\section{Bundle integration}{

Adds \code{.ipw_treat}. Use [ild_joint_msm_weights()] to combine with
\code{.ipw_censor} into \code{.ipw} for [ild_ipw_refit()] and [ild_diagnose()].
}

\examples{
set.seed(2)
d <- ild_simulate(n_id = 20, n_obs_per = 6, seed = 2)
d$stress <- rnorm(nrow(d))
d$trt <- as.integer(d$stress > 0)
x <- ild_prepare(d, id = "id", time = "time")
x <- ild_iptw_weights(x, treatment = "trt", predictors = "stress")
summary(x$.ipw_treat)
}
\seealso{
[ild_iptw_msm_weights()], [ild_ipcw_weights()], [ild_joint_msm_weights()],
  [ild_ipw_refit()]

Other ild_diagnostics_utilities: 
\code{\link{ild_design_check}()},
\code{\link{ild_ipcw_weights}()},
\code{\link{ild_iptw_msm_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_model}()},
\code{\link{ild_missing_pattern}()},
\code{\link{ild_missingness_report}()}
}
\concept{ild_diagnostics_utilities}
