Skip to contents

Functions to create and manipulate psw objects, which are specialized vectors for propensity score weights with optional estimand attributes. Most users should use wt_ate() and friends, but these functions can help extend the functionality of psw objects.

Usage

new_psw(
  x = double(),
  estimand = NULL,
  stabilized = FALSE,
  trimmed = FALSE,
  truncated = FALSE,
  ...
)

psw(
  x = double(),
  estimand = NULL,
  stabilized = FALSE,
  trimmed = FALSE,
  truncated = FALSE
)

is_psw(x)

is_stabilized(wt)

is_causal_wt(x)

as_psw(x, estimand = NULL)

estimand(wt)

estimand(wt) <- value

Arguments

x

A numeric vector (default: double()).

estimand

A character string representing the estimand (e.g., "ate", "att", "ato"). Default is NULL.

stabilized

A logical TRUE

trimmed

Logical, whether these weights came from a trimmed PS.

truncated

Logical, whether these weights came from a truncated PS.

...

Additional attributes to track in the weights.

wt

An object to check or convert.

value

The value to add to the attribute.

Value

  • new_psw(): A psw object.

  • psw(): A psw object.

  • is_psw(): TRUE if the object is a psw, otherwise FALSE.

  • as_psw(): A psw object.

  • estimand(): The estimand attribute of a psw object.

  • is_stabilized(): The stabilized attribute of a psw object.

Examples

psw_weights <- new_psw(c(0.1, 0.2, 0.3), estimand = "ate")
is_psw(psw_weights)
#> [1] TRUE
estimand(psw_weights)
#> [1] "ate"

psw_helper <- psw(c(0.5, 0.7), estimand = "att")
as_psw(c(0.1, 0.2), estimand = "ato")
#> <psw{estimand = ato}[2]>
#> [1] 0.1 0.2