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

Error "'alag(.)'/'rate(.)'/'dur(.)' cannot depend on the state values" only when fitting a data structure that once worked #526

Closed
andreasmeid opened this issue Jun 12, 2023 · 10 comments

Comments

@andreasmeid
Copy link

Dear Matt,

I just have a strange problem with nlmixr2: When trying to fit a QSP model to two data sets that are actually identically structured, everything works fine with one data set, but with the other data set I get the inexplicable error message "'alag(.)'/'rate(.)'/'dur(.)' cannot depend on the state values". I attached the necessary elements so that the code below can be run (cave: estimation might take considerable time).

Where could my error lie and how should I proceed alternatively?

Many thanks and best wishes

Andreas

load("test.RData")
library(rxode2)
library(nlmixr2)

with potassium_data, everthing works fine

fit_potassium_data_oral <- nlmixr2(qsp_model_wo_max, potassium_data, est="focei")

with potassium_data_oral, the subsequent error message is returned

fit_potassium_data_oral <- nlmixr2(qsp_model_wo_max, potassium_data_oral, est="focei")

unhandled error message: EE:[lsoda] 500000 steps taken before reaching tout

@(lsoda.c:750)691)

Error : 'alag(.)'/'rate(.)'/'dur(.)' cannot depend on the state values

test.zip

@mattfidler
Copy link
Member

It seems that the alag() issue comes from the table step.

You can use foceiControl(calcTables=FALSE) to avoid it though it doesn't produce a table step.

However since it takes a bit of time to run, I'm uploading the fit object without the table attached so I can debug by simply adding addTable(fit)

@mattfidler
Copy link
Member

rxode2-526.zip

@WouterAh
Copy link

WouterAh commented Jun 15, 2023

Hi @mattfidler,

After updating nlmixr2 and rxode2 to version 2.0.9 and 2.0.12, respectively, I have been encountering the same issue with some models that used to run just fine prior to updating. I was actually (on and off) working on a reproducible example to share with you before I wanted to contact you, however, I didn't manage to successfully generate one at the time of writing.

The reason I'm posting now is that I might have some additional information, which I hope helps in finding a solution to this issue. I noticed that changing slight things in my model specification (e.g. reducing the number of compartments, removing eta's) leads to different errors that might be related to this issue:
Error in .foceiFitInternal(.env) : On initial gradient evaluation, one or more parameters have a zero gradient Change model, try different initial estimates or use outerOpt="bobyqa") Restart 1 Error : focei$rxInv needs to be of class'rxSymInvCholEnv' Error : focei$rxInv needs to be of class'rxSymInvCholEnv'
(switching to bobyqa here again results in the alag() issue)

And:
Theta reset (ETA drift)

which continues indefinitely (or at least for the many hours I left my nlmixr2 to run). One thing that all these models have in common in my case is that they incorporate a covariate when defining parameters in the model block. When removing these covariates from the model block or incorporating them in an if statement resolves all the issues I've encountered up to this point.

Not sure if it is of any help, but figured it would be better than nothing!

Best regards,
Wouter

@mattfidler
Copy link
Member

Pull #529 fixes the issue for me (at least from the fit, the table output is produced). I can't say about the rest of the issues you describe.

@andreasmeid
Copy link
Author

Dear Matt and Wouter,

many thanks for far. Actually, setting foceiControl(calcTables=FALSE) worked for me, because I can access the $parFixedDf table. Of course, it would the nice to figure out what happens with addTable(fit), but for the moment, I guess, the issue is pragmatically solved for my purpose.

Many thanks and best wishes

Andreas

@mattfidler
Copy link
Member

Thanks @andreasmeid

addTable(fit) works with pull request #529. I'm working through some platform issues for windows and hope to merge it soon.

I will mention it on this thread when it is done.

@mattfidler
Copy link
Member

mattfidler commented Jun 16, 2023

Hi @andreasmeid

addTable() should work with the first fit.

nlmixr2/nlmixr2est#364

Will graciously fail and return the fit without the table step if something like this happens in the future.

@WouterAh
Copy link

WouterAh commented Jun 27, 2023

Pull #529 fixes the issue for me (at least from the fit, the table output is produced). I can't say about the rest of the issues you describe.

Dear Matt,

Just wanted to let you know that also in my case the issues mentioned earlier are resolved after updating to the current development version of nlmixr2/rxode2. Thanks a lot! :)

Best regards,
Wouter

@mattfidler
Copy link
Member

Glad to hear it.

@mattfidler
Copy link
Member

I'm going to close this for now.

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

3 participants