openpharma / brms.mmrm

R package to run Bayesian MMRMs using {brms}
https://openpharma.github.io/brms.mmrm/
Other
18 stars 2 forks source link

"Effect size" in brm_summary() #29

Closed wlandau closed 1 year ago

wlandau commented 1 year ago

Similar to #28, my company's TFLs report something we have been calling "effect size", which is the marginal posterior of the treatment difference divided by the residual standard deviation for that time point. (I can loop back to check whether this is still necessary to report.) I thought it would be easy to calculate, but it is challenging to get posterior samples of the residual standard deviations. In the reference vignettes, we have fixed effects for time instead of marginal standard deviation parameters, and they can be negative. (Which, as an aside, seems strange for an MMRM.)

wlandau commented 1 year ago

It actually looks like there is a sigma parameter in the Stan code. I see:

model {
  // likelihood including constants
  if (!prior_only) {
    // initialize linear predictor term
    vector[N] mu = rep_vector(0.0, N);
    // initialize linear predictor term
    vector[N] sigma = rep_vector(0.0, N);
    mu += Intercept + Xc * b;
    sigma += X_sigma * b_sigma;
    sigma = exp(sigma);
    target += normal_time_het_flex_lpdf(Y | mu, sigma, Lcortime, nobs_tg, begin_tg, end_tg, Jtime_tg);
  }
  // priors including constants
  target += lprior;
}

But these sigmas are not returned. For our purposes, maybe we need them.

wlandau commented 1 year ago

Just figured out how to get the sigmas: https://github.com/RConsortium/brms.mmrm/issues/36#issuecomment-1648449046