Open EdoardoCostantini opened 1 year ago
Added data for replicating the issue in #1b55040
Implemented solution 2:
- After computing
CNR2
, check if it is less than 0. If so, set it to 0.
in #289e3b3
Still needs testing.
devtools::check()
and testthat
do not see the data for replication of error. Need to fix that before you can test the change.
In
cp_thrs_PR2()
, it can happen that:CNR2 <- 1 - exp(-2 / nrow(ivs) * (univ_mods$lls - univ_mods$ll0))
returns a negative value. This could happen if the likelihood of the more complex model is almost identical to the likelihood of the null model. In using this package, it could be that one of the possible predictors is so bad that this happens.
This was fixed in #ce6cc01 by taking the absolute value of the resulting CNR2 before taking the square root. This is not the most elegant solution. You could instead use some numerical trick. For example:
univ_mods$lls - univ_mods$ll0
is smaller than floating point precision. If so, just setCNR2
to zero.CNR2
, check if it is less than 0. If so, set it to 0.