rwe_cut: Create strata

View source: R/psrwe_ps_est.R

rwe_cutR Documentation

Create strata

Description

Cut a sequence of numbers into bins.

The cut points are chosen such that there will with equal numbers in each bin for x. By default, values of y that are outside the range of x will be excluded from the bins, unless they are in the keep_inx.

Usage

rwe_cut(x, y = x, breaks = 5, keep_inx = NULL)

Arguments

x

Vector of values based on which cut points will be determined

y

Vector of values to be cut, default to be the same as x

breaks

Number of cut points

keep_inx

Indices of y that will be categorized as 1 or the largest bin even if their values are out of range of x, i.e. the y's that will not be trimmed

Value

A vector of stratum assignment for y. The y's that are outside the range of x and not in keep_inx are assigned NA in the result.

Examples


x <- rnorm(100,  mean = 0, sd = 1)
y <- rnorm(1000, mean = 1, sd = 2)
rwe_cut(x, y, breaks = 5)


psrwe documentation built on March 18, 2022, 5:33 p.m.