Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with threshold on engine_glm and method using "modEvA" #123

Closed
cwaldock1 opened this issue May 2, 2024 · 3 comments
Closed

Error with threshold on engine_glm and method using "modEvA" #123

cwaldock1 opened this issue May 2, 2024 · 3 comments
Assignees

Comments

@cwaldock1
Copy link

Hello!

I get an error when using the threshold function for some species (but others run fine) with no discernable reason for this difference between species. This only applies when the threshold method is any of the options from modEva.

Below is my code, and a traceback call to identify the location of the error.

mod2_glm <- distribution(background) |>
  add_predictors(env = predictors_suit, 
                 transform = 'none', 
                 derivates = 'quad', 
                 harmonize_na = T) |> 
  add_biodiversity_poipa(pa_data, 
                         name = 'PA model',
                         field_occurrence = 'PA', 
                         docheck = F) |>
  engine_glm() |>
  train(runname = 'PA model')

mod2_glm <- ibis.iSDM::threshold(mod2_glm, method = 'TSS')
9: h(simpleError(msg, call))
8: .handleSimpleError(function (cond) 
   .Internal(C_tryCatchHelper(addr, 1L, cond)), "comparison (<) is possible only for atomic and list types", 
       base::quote(raster_thresh < tr[1]))
7: `[<-`(`*tmp*`, raster_thresh < tr[1], value = 0)
6: .local(obj, method, value, point, field_occurrence, format, return_threshold, 
       ...)
5: threshold(obj, method = method, value = value, point = point, 
       field_occurrence = field_occurrence, format = format, return_threshold = return_threshold, 
       ...)
4: threshold(obj, method = method, value = value, point = point, 
       field_occurrence = field_occurrence, format = format, return_threshold = return_threshold, 
       ...)
3: .stackthreshold(obj = ras, method = method, value = value, point = point, 
       field_occurrence = field_occurrence, format = format, return_threshold = return_threshold)
2: ibis.iSDM::threshold(mod2_glm, method = "TSS")
1: ibis.iSDM::threshold(mod2_glm, method = "TSS")

I can send the data to create a reprex via email if that is helpful?

Thanks as ever for your support in updating and developing the package.

Cheers,
Conor

@Martin-Jung
Copy link
Collaborator

Hey, thanks for reporting, the sounds as if the PA data is either not found or is ill-formatted (only presences/absences, not enough points or column PA formatted as factor or similar or somewhere there is a NA value in between).
Either way this could be catched in a message I guess.
Before sending any test data could you please update the packages and install the current dev branch?

Note threshold supports also withheld point data (parameter point) as well.

@Martin-Jung
Copy link
Collaborator

Hi,
I tested a few things today and could not reproduce the error you report. If it still occurs after the suggestions above, please send me a small(!) reprex.
Thanks,
Martin

@Martin-Jung Martin-Jung self-assigned this May 9, 2024
@Martin-Jung
Copy link
Collaborator

Closed but feel free to comment if the error (re)appears

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants