Covariate impact on the ratio of dependent variables in BRMS multivariate model

I am using a multivariate specification in brms to model two correlated outcomes, (y_1, y_2) jointly. However, the outcome of interest is actually y_1/y_2, which is calculated after model run. I am interested in estimating the relationship between a covariate, c_1 on the ratio y_1/y_2. I have added this covariate into the multivariate model for y_1, and y_2, which results in two coefficients: y_1\_c_1 y_2\_c_1. How can I use this information to estimate y_1/y_2\_c_1?

Unfortunately, I cannot share my data here, however, I have built an example which builds off of Paul Bürkner’s vingette on multivariate models. Not sure that it maps to any outcome of interest in reality, but the data provide a vehicle to describe my goal.


## Read in the data
data("BTdata", package = "MCMCglmm")

## Model for y1 (tarsus) 
m1 <- bf(tarsus ~ hatchdate + (1 | p | fosternest))

## Model for y2 (back)
m2 <- bf(back ~ hatchdate + (1 | p | fosternest))

## Fit the model 
fit <- brm(
    m1 + m2 + set_rescor(FALSE),
    data = BTdata, chains = 2, cores = 2,
    control = list(adapt_delta = 0.95)
)

## Print model summary
summary(fit)

## Add draws 
estimates <- add_epred_draws(object = fit,
                             newdata=BTdata)

## Calculate the ratio of tarsus to back 
estimateSummary <- estimates %>%
    pivot_wider(names_from = .category, 
                names_prefix = "mod_",
                values_from = .epred) %>%
    mutate(ratio = mod_tarsus / mod_back) %>% 
    ungroup() %>%
    mean_qi(ratio, na.rm=T)
    
### How to estimate the relationship between hatchdate on ratio? 

Thank you.

1 Like