InsightRX / PKPDposterior

R package for full-Bayesian inference in the context of model-informed precision dosing
Other
3 stars 1 forks source link

Fix combined error / ruv implementation (issue #33) #34

Open marianklose opened 10 months ago

marianklose commented 10 months ago

In case you agree with the issue described in #33, I guess it could be simply fixed within parse_model_definitions(). In the likelihood section it leads to this change in the model.stan file (if generated with write_stan_model()):

original

dv_pk ~ normal(ipred_obs_pk, (ruv_prop_pk * ipred_obs_pk + ruv_add_pk));

new

dv_pk ~ normal(ipred_obs_pk, (sqrt(pow(ruv_prop_pk * ipred_obs_pk, 2) + pow(ruv_add_pk, 2))));

and similarily in the simulate_posterior section:

original

for(i in 1:n_obs_pk){
    ipred_ruv_pk[i] = normal_rng(ipred_obs_pk[i], (ruv_prop_pk * ipred_obs_pk[i] + ruv_add_pk));
  }

new

for(i in 1:n_obs_pk){
  ipred_ruv_pk[i] = normal_rng(ipred_obs_pk[i], (sqrt(pow(ruv_prop_pk * ipred_obs_pk[i], 2) + pow(ruv_add_pk, 2))));
}