levenc / posologyr

Model-Informed Precision Dosing (MIPD) with R
https://levenc.github.io/posologyr/
GNU Affero General Public License v3.0
12 stars 1 forks source link

Is the `error_model` function on the standard deviation scale like monolix or the variance scale like NONMEM? #46

Closed mattfidler closed 11 months ago

mattfidler commented 11 months ago

Is the error_model function on the standard deviation scale like monolix or the variance scale like NONMEM?

Is sigma the variance or standard deviation?

levenc commented 11 months ago

The error_model function is on the standard deviation scale. That is, g in the excerpt of objective_function:

# Objective function for the Empirical Bayes Estimates
# doi: 10.4196/kjpp.2012.16.2.97
objective_function <- function(y_obs=NULL,f=NULL,g=NULL,
                               eta=NULL,solve_omega=NULL){

---snip---

  U_y   <-  sum(((y_obs - f)/g)^2 + log(g^2))

  # the transpose of a diagonal matrix is itself
  U_eta <- eta %*% solve_omega %*% eta

---snip---

  OFV <- U_y + U_eta

  return(OFV)
}

As for sigma, nothing is really enforced yet. It may be one or the other; it depends on the way the error_model function is written. It's probably not the most elegant (e.g. see return(sqrt(g)) in https://levenc.github.io/posologyr/articles/multiple_endpoints.html). I guess there would be some advantages to adopting a convention and sticking to it.

mattfidler commented 11 months ago

Thanks for the clarification