New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple comparisons with brmsfit #95
Comments
You can actually do that with the First, we have to make sure we understand the coding of our factors (it's the same as for other packages). In the example, dummy coding is used. If we want to compare a1:b1 with a2:b2, we have to find out, how both of these combinations are represented. a1 and b2 are the reference levels so that a1:b2 is just the intercept. a2:b2 is represented by the intercept + the two main effects + the interaction. Accordingly, we can write: (hyp1 <- hypothesis(fit, "Intercept + Aa2 + Bb2 + Aa2:Bb2 = Intercept"))
plot(hyp1) Of course, the intercept cancels out, so we can remove it from the equation. To do multiple comparions, just pass the hypotheses as a charecter vector, e.g: (hyp2 <- hypothesis(fit, c("Aa2 + Bb2 + Aa2:Bb2 = 0", "Intercept = 0"),
alpha = 0.025))
plot(hyp2) It this what you had in mind? |
Thanks a lot for the clear answer! I tried with:
but for binomial model it returned If the contrast coding is same in other packages and the default contrasts ("contr.treatment") are used, may I refit the model with
|
The coding is the same as in other packages. If you really need to get the model.matrix to understand what contrasts you applied, you can can write: fixed_form <- brms:::extract_effects(fit$formula)$fixed
mm <- brms:::get_model_matrix(fixed_form, data = fit$data) Be aware though, that internal functions may change without notice in future updates (for those two it's unlikely so it should be ok to use them). |
That's perfect! It is exactly what I need. |
I am glad to hear that! :-) |
Hi Paul, I'm trying to implement the functions in the present post but they seem unreliable now. Is there any new way to get a contrast matrix and to do contrast analysis in brms right now? |
The ways brms supports contrasts of factors is the same as in most other R packages dealing with such models. As such, brms sticks to this approach and does not implement a new one. |
Ok this is clear, but I have problems to call the following functions and I can't find detailed references out there :(
|
This is because they are internal functions which are not designed to be applied by users. |
Dear Paul and brms-users, |
Dear Paul and brms-users!
Could you please tell me how to perform multiple comparisons with brmsfit object?
Here is a small example with dummy data:
Is it possible to test for the difference of factor combinations (e.g. a1-b1 vs a2-b2)?
I'm looking something similar to the
glht
function from multcomp package.May I state that two combinations differ if their credible intervals (from
predict
) doesn't overlap? Or Estimate for one factor combination (e.g., a1-b1) doesn't belong to the interval for the other factor combination (e.g., a2-b2)?Or it is somehow possible to test it with
hypothesis.brmsfit
?I really appreciate any advice you can provide.
With best regards,
Vladimir
The text was updated successfully, but these errors were encountered: