pharmpy / pharmr

R wrapper to Pharmpy
GNU Lesser General Public License v3.0
19 stars 4 forks source link

When I run AMD in python, it always stops at ruvsearch and reports an error #142

Open leahww opened 1 year ago

leahww commented 1 year ago

Hello everyone, I'm experiencing a problem. When I run this code in python 3.9.12.

from pharmpy.modeling import *
from pharmpy.tools import run_amd, load_example_modelfit_results
model = load_example_model("pheno")
results = load_example_modelfit_results("pheno")
order = ['structural', 'iivsearch', 'residual', 'covariates']
run_amd(model, results=results, order=order)

It always stops at the ruvsearch step and reports an error. Here is the first three error messages.

D:\Unusualsoftware\Python39\lib\site-packages\pharmpy\tools\external\nonmem\run.py:117: UserWarning: Expected result files do not exist, copying everything: time_varying3_1
  warnings.warn(f'Expected result files do not exist, copying everything: {basename}')
D:\Unusualsoftware\Python39\lib\site-packages\pharmpy\tools\external\nonmem\run.py:117: UserWarning: Expected result files do not exist, copying everything: time_varying1_1
  warnings.warn(f'Expected result files do not exist, copying everything: {basename}')
D:\Unusualsoftware\Python39\lib\site-packages\pharmpy\tools\external\nonmem\run.py:117: UserWarning: Expected result files do not exist, copying everything: time_varying2_1
  warnings.warn(f'Expected result files do not exist, copying everything: {basename}')

I checked iivsearch,both successfully run results.csv and subfolders for each model.I also installed the tflite package. I don't know what went wrong. Could you please advise.

stellabelin commented 1 year ago

Hi! Thanks for reporting! If you check the best model from IIVSearch (will be ranked first in results.csv), do the .lst and .ext-files look okay? And in the table file, do you have values for CWRES?

leahww commented 1 year ago

Hi, thanks for your reply. I am very sorry for not seeing your message in time. I checked the best model for IIVSearch, and it's .lst and .ext files are fine (compared to the IIVSearch warp for the model below that runs smoothly, and the results are consistent), and CWRES has values. Also, I tried removing 'residual' from 'order' to make it order = ['structural', 'iivsearch', 'covariates'] and it worked fine. In addition, I also tried running run_ruvsearch alone with the following code, and it reported the same error as before.

from pharmpy.modeling import load_example_model
from pharmpy.tools import run_ruvsearch, load_example_modelfit_results

model = load_example_model("pheno")
results = load_example_modelfit_results("pheno")
run_ruvsearch(model=model, results=results)
stellabelin commented 1 year ago

Hi! Thanks for sending a minimal example code, I tried running it locally and it worked on my machine so I cannot reproduce this behavior. The error you report happens when e.g. the .ext and .lst-files do not exist, and in this case it looks like it's the time varying proxy models that fail. What do the STDOUT/STDERR files look like?

leahww commented 1 year ago

Hi, thanks for your reply, I checked my STDOUT/STDERR files and at runruvsearch/model all STDERR files are blank and the following code appears in all STDERR files:

Starting NMTRAN

 AN ERROR WAS FOUND IN THE CONTROL STATEMENTS.

AN ERROR WAS FOUND ON LINE 6 AT THE APPROXIMATE POSITION NOTED:
 Y = THETA(1) + ETA_BASE + EPS(2)/IPRED + EPS(1)
                 X       
 THE CHARACTERS IN ERROR ARE: ETA_BASE
  208  UNDEFINED VARIABLE.

In runruvsearch/model all $DATA is power_1.csv. I genuinely appreciate your help and support.