continuous2ordinal: Transform a continuous vector to ordinal vector through...

View source: R/helper_data.R

continuous2ordinalR Documentation

Transform a continuous vector to ordinal vector through cutoff function.

Description

Discretize continuous x to ordinal z with k levels. If the generated values are guaranteed to have k unique levels, otherwise, error will be raised.

Usage

continuous2ordinal(x, k = 2, by = "dist", qmin = 0.1, qmax = 0.9, max_try = 20)

Arguments

x

continuous vector

k

number of ordinal levels. Generated ordinal vector takes value from 1,...,k

by

Select cut points by absolute values if 'dist' and by quantiles if 'quantile'

qmin

Cutoff points are slected in the range of 'qmin' and 'qmax' quantiles of the data 'x'

qmax

See 'qmin'.

max_try

The maximum number of attempts to select random cutoffs, since some may yield to ordinal variable with fewer than k levels

Value

an ordinal vector.


udellgroup/mixedgcImp documentation built on Jan. 25, 2023, 7:55 p.m.