# Variance of a sum of fixed and random effects' estimates

• Operating System: Windows 10
• brms Version: brms 2.8

I fitted a nonlinear mixed-effects model on repeated-measures paired data.
My model looks the following way:

fit_model <- function(Data){

fit<- brm(
bf(LDL ~ 15 + (alpha-15) / (1 + exp ((gamma-Time) / delta)),
alpha ~ 1 + (1|Cat) + (1|Sample) ,
gamma ~ 1 + (1|Cat) + (1|Sample),
delta ~ 1,
nl = TRUE),
prior = c(
prior(normal(1500, 30), class=“b”,nlpar = “alpha”),
prior(normal(2.5,0.07), class=“b”, nlpar = “gamma”),
prior(normal(0.2,0.05), class=“b”, lb=0, ub=0.5, nlpar = “delta”),
prior(student_t(3, 0, 10), class=“sigma”),
prior(student_t(3, 0, 10), class=“sd”, nlpar=“alpha”),
prior(student_t(3, 0, 10), class=“sd”, nlpar=“gamma”),
prior(normal(0.4,0.03 ), class=“sd”, group=“Sample”, coef=“Intercept”, nlpar=“gamma”),
prior(normal(300,10), class=“sd”, group=“Sample”, coef=“Intercept”, nlpar=“alpha”),
prior(normal(0.2,0.15), class=“sd”, group=“Cat”, coef=“Intercept”, nlpar=“gamma”),
prior(normal(17,6), class=“sd”, group=“Cat”, coef=“Intercept”, nlpar=“alpha”)),
data = Data, family = gaussian(),
chains = 3,
iter=10000,
warmup = 1000,
cores = getOption(“mc.cores”,1L),
thin = 1,
control = list(adapt_delta = 0.99999, stepsize=0.00001, max_treedepth=15)
)

return(fit)
}

Now that I have fitted my model, I need to decide on how to use it:

1. I could use it to predict the values of the response variable at certain time point, for each subject.

2. I could use the values obtained for gamma = fixef for gamma + ranefs (gamma|Sample) + (gamma|Cat).

Both of these make sense in the context of my problem.

Now, in the first case the Est. Error of my predicted values is automatically given by the predict() function.
But in the second case I sum up three estimated values for the fixed and random effects, each of which has a different Est Error.

So I would like to ask whether there is an easy way to calculate an Est Error for the sum of these values in brms() (something very basic I am missing out?), in order to be able to make a choice.

For examining the posterior distribution for some transformation of parameters, I like to use `tidybayes::spread_draws`, compute the transformation in a new column, then look at the quantiles of the posterior distribution of the transformation across whatever groupings I am interested in.

1 Like

Agreed to what @nerutenbeck said. In general, you do all the computations on the level of the posterior samples (i.e., per posterior sample) and the summarize only after all transformations have been done.

1 Like