kaskr / adcomp

AD computation with Template Model Builder (TMB)
Other
178 stars 81 forks source link

error in OneStepGeneric method of TMB::oneStepPredict #366

Open timjmiller opened 2 years ago

timjmiller commented 2 years ago

Description:

This is not likely to happen, but if a value of an unused parameter is NaN, then factor(NaN*NA) here does not produce the right input for the map argument of MakeADFun.

I copied and edited validation.R and tmbprofile.R to deduce where the the map list element for the unused parameter was changed.

Reproducible Steps:

1) Make input initial parameter list with a value = log(-1) for an unused parameter. 2) Fit model 3) run TMB::oneStepPredict(method="oneStepGeneric").

Current Output:

Error in if (xnext + that < parm.range[1]) { : missing value where TRUE/FALSE needed

(repeated for each observation)

Expected Output:

Normal execution of TMB:oneStepPredict: return data.frame with calculated residuals.

Possible Solution:

change referenced line to map <- lapply(args$parameters[fix], function(x)factor(rep(NA,length(x))))

TMB Version:

1.9.1, commit = e499559

R Version:

R version 4.1.3 (2022-03-10)

Operating System:

Windows 10