ggPMXdevelopment / ggPMX

ggPMX R package
37 stars 10 forks source link

Feature request: Plot regressor as covariates #342

Open tmss1 opened 1 year ago

tmss1 commented 1 year ago

Variables defined as "regressor" in the Monolix dataset, as needed by the structural model in Monolix, are no longer recognised as covariates in ggPMX and cannot be plotted for covariate evaluation from the controller.

It would be helpful if we could plot these "regressor" variables needed by Monolix in all covariate evaluation plots for model diagnostics.

baltcir1 commented 1 year ago

You can use the option strats in the controller creation to specify additional stratification factors which are not covariates: strats: character extra stratification variables

tmss1 commented 1 year ago

Thanks @baltcir1, It would not just appear in standard covariate plots when using, e.g., pmx_plot_eta_cats() though. Do you have an example on how I can use these additional stratification factors (e.g., if I added strats = c("regressor1","regressor2") in the controller), how can I add them to the plot above and show them with other covariates?

baltcir1 commented 1 year ago

Hi @tmss1,

indeed, it won't appear in pmx_plot_eta_cats(). You can try the following (force adding this regressor in cats):

my_cats = ctr %>% get_cats()
my_new_cats = c(my_cats, "my_regressor")
ctr %>% set_data(cats = my_new_cats)

If this doesn't work, as a workaround, you could add a column in Monolix that is a copy of your regressor column set as a categorical covariate.

Of course, all this applies also to the case where your regressor is a continuous variable.