SAM icon indicating copy to clipboard operation
SAM copied to clipboard

Error when undertaking a forecast with zero F

Open pdolder opened this issue 5 years ago • 2 comments

Hi,

the stockasssessment::forecast function now returns a summary tables with quantiles for a stochastic forecast but this causes an error if you're projecting a stock with zero catch advice in any year, i.e.

forecast(fit, fval = c(0.8,0.6,0,0.2), ave.years=2017:2019, rec.years=2005:2019, splitLD=TRUE, nosim = 50001)

Error in quantile.default(x, c(0.5, 0.025, 0.975)) : missing values and NaN's not allowed if 'na.rm' is FALSE

pdolder avatar Nov 11 '20 12:11 pdolder

Hi,

This is correct F=0 will fail in the current implementation. A quick workaround is to set F to a very small number instead (e.g. F=1e-9)

fishfollower avatar Nov 11 '20 12:11 fishfollower

Hi,

Thanks, yes this is what I ended doing. To understand, are you saying this is a feature, i.e. expected behaviour in this case?

pdolder avatar Nov 17 '20 08:11 pdolder