rbchan / unmarked

R package for hierarchical models in ecological research
https://rbchan.github.io/unmarked/
37 stars 25 forks source link

simulate method for unmarkedFitGDS fails when there are NAs in siteCovs #163

Closed kenkellner closed 4 years ago

kenkellner commented 4 years ago

When running this simulate method in parboot the design matrices are generated without cleaning up NAs. This can result in missing values for the lambda vector:

https://github.com/rbchan/unmarked/blob/1034723788e450d59d73d3c52b18e612b42474e6/R/unmarkedFit.R#L4371

Eventually these NAs reach the size argument of rmultinom which errors instead of returning another NA (unlike most random number functions in R?)

https://github.com/rbchan/unmarked/blob/1034723788e450d59d73d3c52b18e612b42474e6/R/unmarkedFit.R#L4412

Probably need to put a check in here and skip running rmultinom when lambda = NA and directly set the value of y to NA.