ali-johnston/ebird_sdms_DD_paper

Errors happen for 05_a_25_encounter_models.R

kang37 opened this issue · 0 comments

Hi, thanks for sharing the code! As you mentioned, "So if you want to just run the models, you can proceed directly to scripts 05, 06, and 07", I tried that, but errors happened when I ran line 39. The error message is as follows.

Rows: 42539 Columns: 17                                                                                                    
── Column specification ────────────────────────────────────────────────────────────────
Delimiter: ","
chr  (10): checklist_id, observer_id, sampling_event_identifier, state_code, localit...
dbl   (5): latitude, longitude, effort_distance_km, chwwid, woothr
lgl   (1): all_species_reported
date  (1): observation_date

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
[1] ""                                                                                                                     
[1] "======================================="
[1] "RUNNING FOR SIM 1"
[1] "PREPARING DATA"
Resolution: 13, Area (km^2): 31.9926151554038, Spacing (km): 5.58632116604267, CLS (km): 6.38233997895802
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1974)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1986)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1971)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1971)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1971)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2076)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2001)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1971)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1986)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2016)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1971)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2016)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2079)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 1974)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2076)
Joining with `by = join_by(checklist_id, sampling_event_identifier, type)`
Rows: 3395 Columns: 2                                                                                                      
── Column specification ────────────────────────────────────────────────────────────────
Delimiter: ","
chr (1): checklist_id
dbl (1): route_id

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Resolution: 13, Area (km^2): 31.9926151554038, Spacing (km): 5.58632116604267, CLS (km): 6.38233997895802
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2100)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2010)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2001)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2031, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2187, 2004)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2028, 2187)
FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress():  coordinate out of range: (2025, 2187)
Joining with `by = join_by(species_observed, checklist_id)`
[1] "RUNNING MODELS"
[1] "------- Running encounter rate model -------"
[1] "raw data n = 16204"
[1] "Keeping only presences"
[1] "50000 background points"
Error in `pmap()`:
ℹ In index: 1.
Caused by error in `sample_n()`:
! Can't compute indices.
Caused by error:
! `size` must be less than or equal to 440 (size of data).
ℹ set `replace = TRUE` to use sampling with replacement.
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: In dir.create(figure_folder, recursive = TRUE) :
  'figures/encounter/RF_sample_together_woothr_2024-01-10' already exists
2: In dir.create(output_folder, recursive = TRUE) :
  'output/encounter/RF_sample_together_woothr_2024-01-10' already exists
3: One or more parsing issues, call `problems()` on your data frame for details, e.g.:
  dat <- vroom(...)
  problems(dat) 
4: There was 1 warning in `mutate()`.
ℹ In argument: `time_observations_started =
  as.numeric(as.character(time_observations_started))`.
Caused by warning:
! NAs introduced by coercion 
5: There was 1 warning in `mutate()`.
ℹ In argument: `number_observers = as.numeric(as.character(number_observers))`.
Caused by warning:
! NAs introduced by coercion 
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) : 
  invalid first argument
Error in assign(cacheKey, frame, .rs.CachedDataEnv) : 
  attempt to use zero-length variable name

Line 39 is the beginning of a loop, so I looked into the loop line by line. Before line 199, everything seems to be fine. But after running line 199, an error happened.

ppm_bbs_stop <- mutate(mod_set, ppms = map(models, validate, data = ebird_test_bbs, bbs_combine = FALSE)) %>%
        select(-models) %>% unnest(cols = c(ppms)) %>%
        mutate(val_type = "bbs")
# Error in `mutate()`:
#   ℹ In argument: `ppms = map(models, validate, data = ebird_test_bbs, bbs_combine
#                              = FALSE)`.
#   Caused by error:
#     ! object 'models' not found
#   Run `rlang::last_trace()` to see where the error occurred.

Could you help me with that? Thanks.