DistanceDevelopment / mrds

R package for mark-recapture-distance-sampling analysis
GNU General Public License v3.0
4 stars 4 forks source link

Numerical problems without covariate scaling in Amakihi #53

Closed lenthomas closed 2 years ago

lenthomas commented 2 years ago

The Amahiki example dataset runs into numerical problems if you don't scale the MAS covariate in the following analysis. This seems strange to me as I thought mrds did its own internal scaling. I believe the issue of covariate scaling was looked into and changed in the recent work on the MCDS optimizer. The following example is likely indicative of a wider issue.

library(Distance)
data(amakihi)
trunc <- 82.5
conv <- convert_units("meter", NULL, "hectare")
#Seems to run OK with scaling
aukhn2 <- ds(data=amakihi, transect = "point", convert_units = conv,
             key="hn", formula=~OBs+scale(MAS), truncation = trunc)
#Numerical problems without scaling
aukhn2 <- ds(data=amakihi, transect = "point", convert_units = conv,
             key="hn", formula=~OBs+MAS, truncation = trunc)             

On mrds 2.2.6 the last line gives

Model contains covariate term(s): no adjustment terms will be included.
Fitting half-normal key function
AIC= -Inf
Some variance-covariance matrix elements were NA, possible numerical problems; only estimating detection function.
dill commented 2 years ago

Fixed in 5cd5dcf to use absolute scaling rather than scaling relative to sd(distance)