correct_sign {rineq}R Documentation

Corrects negative values in the health variable

Description

The Relative Concentration Index is not bonded between [-1,1] if the health variable contains both negative and positive values. This function corrects for this either by imputing a value of 0 for all negative values or by subtracting the minimum value.

Usage

correct_sign(x, shift = TRUE)

corrected_value(x)

is_corrected(x)

Arguments

x

A numeric vector, typically representing health.

shift

If FALSE (the default), 0 is imputed for all negative values in x. If TRUE the minimum value of x is subtracted from it.

Value

correct_sign() returns a list with 2 components:

These components can be extracted with the functions corrected_value and is_corrected.

Functions

Author(s)

Peter Konings

Examples

data("housing")

# standardize & normalize bmi, will introduce negative values
housing$bmi.std <- (housing$bmi - mean(housing$bmi))/ sd(housing$bmi)

housing$bmi.std.shifted <- corrected_value(correct_sign(housing$bmi.std, shift = TRUE))
housing$bmi.std.imputed <- corrected_value(correct_sign(housing$bmi.std, shift = FALSE))

## compare the effect of both methods
plot(density(housing$bmi.std, na.rm = TRUE))
points(density(housing$bmi.std.shifted, na.rm = TRUE), col = 'blue')
points(density(housing$bmi.std.imputed, na.rm = TRUE), col = 'green')


[Package rineq version 0.2.3 Index]