correctSign | 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)
x |
a numeric vector, typically representing health. |
shift |
logical. If |
Returns a list with 2 components:
corrected |
corrected version of |
modified |
logical, |
These components can be extracted with the functions correctedValue
and isCorrected
.
Peter Konings
data(nigeria)
nigeria$zscore.shifted <- corrected_value(correct_sign(nigeria$zscore, shift = TRUE))
nigeria$zscore.imputed <- corrected_value(correct_sign(nigeria$zscore, shift = FALSE))
## compare the effect of both methods
plot(density(nigeria$zscore, na.rm = TRUE))
points(density(nigeria$zscore.shifted, na.rm = TRUE), col = 'blue')
points(density(nigeria$zscore.imputed, na.rm = TRUE), col = 'green')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.