PSPred: Estimate propensity scores

View source: R/PSPred.R

PSPredR Documentation

Estimate propensity scores

Description

Fits a logistic model using baseline observations from fit_dat and returns each row's estimated probability of receiving treatment 1 in pred_dat. The model is fitted again each time the function is called.

Usage

PSPred(ps_fo, fit_dat, pred_dat, mapping, ...)

Arguments

ps_fo

propensity score model formula

fit_dat

A data frame containing the baseline observations used to fit the model.

pred_dat

A data frame containing the observations for which propensity scores are requested.

mapping

A pd_mapping object that identifies the treatment and time columns and the baseline time.

...

Additional arguments passed to stats::glm().

Value

A numeric vector of propensity scores, one for each row of pred_dat, rounded to three decimal places.

Examples

data("BiSample", package = "PDRobust")
map <- Mapping(
  id = "id", time = "time", treatment = "A",
  survival = "S", outcome = "Y",
  baseline_time = 0, cutoff_time = 2,
  covariates = c("X1", "X2", "X4"),
  interest_vars = c("X1", "X2"), y_type = "B"
)
pd_dat <- DataStandard(BiSample, map)
ps <- PSPred(A ~ X1 + X2 + X4, pd_dat, pd_dat, map)
head(ps)

PDRobust documentation built on Oct. 2, 2026, 5:09 p.m.