You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an error thrown by stat_density_2d not very informative. It computes an illegal bandwidth for me behind the scene, which causes an internal error that is not explained in the messages. Specifying the bandwidth explicitly can fix the problem. However, I expect stat_density_2d can either handle these edge cases or point out that the default value given the data is illegal and manual input is required.
Error in stat_density_2d():
! Problem while computing stat.
ℹ Error occurred in the 1st layer.
Caused by error in seq_len():
! argument must be coercible to non-negative integer
The error messages is quite confusing. By digging into the warnings, I found the root cause of the problem:
1: Computation failed in stat_density2d()
Caused by error in MASS::kde2d():
! bandwidths must be strictly positive
In stat_density_2d, h is automatically computed before calling kde2d, if not given
So if one of data$x and data$y has more than 75% of identical values, defualt bandwidth will become 0 without warning, and it will immediately be considered as illegal by kde2d.
The text was updated successfully, but these errors were encountered:
Thanks for the report! I can reproduce the issue on my end. I agree that the message should be more informative and perhaps suggest that the user provide the h argument manually.
I found an error thrown by stat_density_2d not very informative. It computes an illegal bandwidth for me behind the scene, which causes an internal error that is not explained in the messages. Specifying the bandwidth explicitly can fix the problem. However, I expect stat_density_2d can either handle these edge cases or point out that the default value given the data is illegal and manual input is required.
The following example works fine:
but the next one will throw an error:
The error messages is quite confusing. By digging into the warnings, I found the root cause of the problem:
In stat_density_2d, h is automatically computed before calling kde2d, if not given
and bandwidth.nrd uses the following formula by default
So if one of data$x and data$y has more than 75% of identical values, defualt bandwidth will become 0 without warning, and it will immediately be considered as illegal by kde2d.
The text was updated successfully, but these errors were encountered: