Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Parameter Estimation in fmle #79

Open
MartaCousido opened this issue Jun 18, 2024 · 1 comment
Open

Inconsistent Parameter Estimation in fmle #79

MartaCousido opened this issue Jun 18, 2024 · 1 comment

Comments

@MartaCousido
Copy link

MartaCousido commented Jun 18, 2024

When using the fmle function to fit the Ricker stock-recruitment model to a FLStock object with 150 iterations, some iterations result in NA for the estimated parameters. However, if the model is fitted individually to those specific iterations (i.e., providing to fmle an FLStock object with only that iteration), the parameters are estimated correctly.

I can't find any explanation for this. It would be very useful to check what could be causing it.

I attached the RData where you can find in the stk_stf object the FLStock. The iters for which the parameters are NA are (53, 73, 108), below I provide the code:

data_FLSR <- as.FLSR(stk_stf)
model(data_FLSR) <- ricker()
system.time(stk_fit_FLSR <- fmle(data_FLSR))

Then fitting each ones of the iterations with NAs

a<-as.numeric(stk_fit_FLSR@params[1])
b<-as.numeric(stk_fit_FLSR@params[2])
inda=which(is.na(a))
indb=which(is.na(b))

i=1 #for example
data_FLSR_aux <- as.FLSR(stk_stf[,,,,,inda[i]])
model(data_FLSR_aux) <- ricker()
fmle(data_FLSR_aux)
data test.zip

Thanks for your help

@iagomosqueira
Copy link
Member

iagomosqueira commented Jul 4, 2024

The starting values from the initial function were not being correctly recomputed. This usually does not create a problem, but in 3 iters in your dataset they were too far to allow 'optim()' to find a solution.

This has been fixed in the commit above, so please reinstall from github or r-universe and check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants