| ps_refit | R Documentation |
Re-estimates a propensity score model using only the observations retained
after trimming. This is the recommended intermediate step between
ps_trim() and weight calculation (e.g. wt_ate()):
ps_trim() -> ps_refit() -> wt_*()
Trimming changes the target population by removing observations with extreme propensity scores. Refitting the model on the retained subset produces propensity scores that better reflect this population, improving both model fit and downstream weight estimation. Weight functions warn if a trimmed propensity score has not been refit.
ps_refit(trimmed_ps, model, .data = NULL, ...)
trimmed_ps |
A |
model |
The original fitted model used to estimate the propensity scores (e.g. a glm or multinom object). The model is refit via update() on the retained subset. |
.data |
A data frame. If |
... |
Additional arguments passed to update(). |
A ps_trim object with re-estimated propensity scores for retained
observations and NA for trimmed observations. Use is_refit() to
confirm refitting was applied.
ps_trim() for the trimming step, is_refit() to check refit
status, wt_ate() and other weight functions for the next step in the
pipeline.
set.seed(2)
n <- 200
x <- rnorm(n)
z <- rbinom(n, 1, plogis(0.4 * x))
# fit a propensity score model
ps_model <- glm(z ~ x, family = binomial)
ps <- predict(ps_model, type = "response")
# trim -> refit -> weight pipeline
trimmed <- ps_trim(ps, lower = 0.1, upper = 0.9)
refit <- ps_refit(trimmed, ps_model)
wts <- wt_ate(refit, .exposure = z)
is_refit(refit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.