PhilipMostert / PointedSDMs

Wrapper function for 'inlabru' for modeling species distribution models from disparate datasets.
23 stars 2 forks source link

Undefined objects in predict.bruSDM leading to errors #12

Closed RRTogunov closed 2 months ago

RRTogunov commented 2 months ago

See line comments:

I receive an error on line [368] (https://github.com/PhilipMostert/PointedSDMs/blob/cba293af1eca4f5b89626a7681f25f732306c70d/R/bruSDM_predict.R#L368) of predict.bruSDM

formula_components <- c(covariates, intercept_terms, spatial_obj, marks_spatial, marks_intercepts)

that Error: objectintercept_termsnot found (also that marks_spatial and marks_intercepts are not found). In my case, the logical if (!is.null(unlist(object[['species']][['speciesIn']]))) is FALSE, so the code doesn't correctly define intercept_terms or marks_intercepts. Similarly, the logical if (spatial) (link) is also FALSE for me, so marks_spatial was also undefined.

PhilipMostert commented 2 months ago

The issue here was due to an over-extended curly bracket and neglecting the marks_spatial object in the prediction. This has been fixed in the latest push.