The following code gives an example whereby I am using interaction() to turn a pair of factors into a single factor. I presume this is allowed and justified. However, if this new factor does not fully intersect with "y", the resample() function fails. By this I mean, that some level of the protected variable does not have both 1 & 0 levels of the "y" variable.
library(fairmodels)
data("compas")
str(compas)
r <- as.numeric(compas$Two_yr_Recidivism)-1
s <- interaction(compas$Sex, compas$Ethnicity)
table(s)
p_indexes <- fairmodels::resample(protected = s, y = r)
Error in if (expected > actual) { : missing value where TRUE/FALSE needed
If nothing else, a more specific error message is needed, explaining the problem. Preferably, it should continue to generate the best possible resampling.
The following code gives an example whereby I am using
interaction()
to turn a pair of factors into a single factor. I presume this is allowed and justified. However, if this new factor does not fully intersect with "y", theresample()
function fails. By this I mean, that some level of the protected variable does not have both 1 & 0 levels of the "y" variable.If nothing else, a more specific error message is needed, explaining the problem. Preferably, it should continue to generate the best possible resampling.