is_unit_truncated() returns a logical vector indicating which
observations had their propensity scores modified by truncation. Use
is_ps_truncated() to test whether an object has been truncated at all.
The answer comes from the truncation record, which is written for a fixed
set of observations and can both be lost and outlive them. On a ps_trunc,
vctrs::vec_slice() and c() drop it, and subassignment that grows the
vector carries it across a length change; see ps_trunc() for the whole
contract. On a psw vector built from truncated propensity scores, a
subset drops it, while subassignment that grows the weights carries it
across the length change.
is_unit_truncated() therefore checks that the record covers the object it
is given, and raises an error of class propensity_missing_meta_error when
it does not, or when an object marked as truncated carries no record at
all, rather than name truncated units at stale positions. Query the
ps_trunc object the record was written for instead.
That check counts observations, which a reordering does not change, so a
ps_trunc or psw reordered through vctrs rather than through [, such
as by vctrs::vec_slice(x, 5:1) or dplyr::arrange(), drops the
positions instead, and is_unit_truncated() refuses the result. See
ps_trunc() and psw for the whole contract.
Arguments
- x
A
ps_truncobject created byps_trunc(), or a psw vector built from one.
Value
A logical vector the same length as x (or number of rows for
matrix input). TRUE marks observations whose values were winsorized.
