# Brms conditional\_effects show exact value

**URL:** <https://discourse.mc-stan.org/t/brms-conditional-effects-show-exact-value/34912>\
**Category:** Modeling\
**Tags:** specification, brms\
**Created:** [April 25, 2024, 2:52pm UTC](https://discourse.mc-stan.org/t/brms-conditional-effects-show-exact-value/34912 "2024-04-25T14:52:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ananas](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ananas/32/18379_2.png) [@ananas](https://discourse.mc-stan.org/u/ananas)\
**Post date:** [April 25, 2024, 2:52pm UTC](https://discourse.mc-stan.org/t/brms-conditional-effects-show-exact-value/34912/1 "2024-04-25T14:52:32Z")

</div>

Hi,

I’m currently using conditional\_effects(fit, “condition”) that shows this graph for a ordinal regression model:

 ![Screenshot 2024-04-25 at 9.51.41 AM](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/3/a/3a74d01ab1ac1e2d6ba003a49c5b1681d737bc27.png)  
I want to show the exact numbers of mean and sd in this graph. How should I do that?

Thank you!

---

<div class="post-metadata">

**Author:** ![joels](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/joels/32/10442_2.png) [@joels](https://discourse.mc-stan.org/u/joels)\
**Post date:** [April 25, 2024, 5:23pm UTC](https://discourse.mc-stan.org/t/brms-conditional-effects-show-exact-value/34912/2 "2024-04-25T17:23:18Z")

</div>

You can modify the plot generated by `conditional_effects` or create your own plot. I show both methods below with a reproducible example.

```no-highlight
library(tidyverse)
theme_set(theme_bw())
library(brms)

m = brm(Petal.Width ~ Species, data=iris, cores=4, 
        file="tmp", backend="cmdstanr")

ce = conditional_effects(m)

```

`conditional_effects` actually returns a list containing a data frame for each predictor variable in the model . These data frames are used to generate the conditional effects plots. You can get the exact values from these data frames.

```no-highlight
# Look at the structure of the conditinal_effects() object
str(ce)

```

> ```no-highlight
> List of 1
> $ Species:'data.frame':	3 obs. of 8 variables:
> ..$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 2 3
> ..$ Petal.Width: num [1:3] 1.2 1.2 1.2
> ..$ cond__ : Factor w/ 1 level "1": 1 1 1
> ..$ effect1__ : Factor w/ 3 levels "setosa","versicolor",..: 1 2 3
> ..$ estimate__ : num [1:3] 0.247 1.326 2.026
> ..$ se__ : num [1:3] 0.0297 0.0277 0.0285
> ..$ lower__ : num [1:3] 0.189 1.268 1.967
> ..$ upper__ : num [1:3] 0.304 1.383 2.085
> ..- attr(*, "effects")= chr "Species"
> ..- attr(*, "response")= chr "Petal.Width"
> ..- attr(*, "surface")= logi FALSE
> ..- attr(*, "categorical")= logi FALSE
> ..- attr(*, "ordinal")= logi FALSE
> ..- attr(*, "points")='data.frame':	150 obs. of 4 variables:
> .. ..$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
> .. ..$ resp__ : num [1:150] 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
> .. ..$ cond__ : Factor w/ 1 level "1": 1 1 1 1 1 1 1 1 1 1 ...
> .. ..$ effect1__: Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
> - attr(*, "class")= chr "brms_conditional_effects"
> 
> ```

```no-highlight
# Look at the data frame conditional_effects created for Species
ce$Species

```

> ```no-highlight
> Species Petal.Width cond __effect1__ estimate __se__ lower __upper__
> 1 setosa 1.199333 1 setosa 0.2473169 0.02974676 0.1886225 0.3040592
> 2 versicolor 1.199333 1 versicolor 1.3256387 0.02766471 1.2675946 1.3831360
> 3 virginica 1.199333 1 virginica 2.0259349 0.02848083 1.9668068 2.0846869
> 
> ```

```no-highlight
# Modify conditional effects plot
# Use cat_args to remove point markers
plot(ce, ask=FALSE, cat_args=list(colour=NA))[[1]] + 
  geom_label(aes(label=round(estimate__, 2)), size=3) +
  geom_text(aes(label=sprintf("SE: %0.3f", se__)), nudge_x=0.35, 
            hjust=1, colour="red", size=3)

```

 ![Rplot02](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/b/d/bdaebfcdf4438d71ab6840c0e47b45eb826cf58c.png)

```no-highlight
# Create your own plot
ce$Species %>% 
  ggplot(aes(Species, estimate__)) +
  geom_errorbar(aes(ymin=lower __, ymax=upper__ ), width=0.3) +
  geom_label(aes(label=round(estimate__, 2)), size=3) +
  geom_text(aes(label=sprintf("SE: %0.3f", se__)), nudge_x=0.35, 
            hjust=1, colour="red", size=3) +
  labs(y="Petal Width")

```

 ![Rplot01](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/f/9/f925494847bcb6cdc817c754ba1d8af290028518.png)
