| correct_sign | R Documentation |
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.
correct_sign(x, shift = TRUE)
corrected_value(x)
is_corrected(x)
x |
A numeric vector, typically representing health. |
shift |
If |
correct_sign() returns a list with 2 components:
corrected: corrected version of x
modified: logical, TRUE when any of the elements of x have been changed
corrected_value(): returns the corrected value if passed the result of 'correct_sign().
is_corrected(): returns TRUE if a modifications was made and FALSE otherwise. Takes as argument the result of correct_sign(),
corrected_value(): Return the corrected value
is_corrected(): Check if the sign was corrected
Peter Konings
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')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.