Skip to contents

is_unit_trimmed() returns a logical vector indicating which observations were removed by trimming. This is a per-unit query, as opposed to is_ps_trimmed(), which tests whether the object has been trimmed at all.

Usage

is_unit_trimmed(x)

Arguments

x

A ps_trim object created by ps_trim().

Value

A logical vector the same length as x, where TRUE marks a trimmed unit.

See also

ps_trim() for trimming propensity scores, is_ps_trimmed() to test whether an object has been trimmed, ps_trim_meta() to retrieve full trimming metadata.

Examples

ps <- c(0.05, 0.3, 0.6, 0.95)
trimmed <- ps_trim(ps, method = "ps", lower = 0.1, upper = 0.9)

is_unit_trimmed(trimmed)
#> [1]  TRUE FALSE FALSE  TRUE

# Use to subset data to retained observations
kept <- !is_unit_trimmed(trimmed)
ps[kept]
#> [1] 0.3 0.6