# Question for conditional_effects

Hello,

I have a question about conditional_effects. When I have a brms object and put it inside the conditional_effects, which a low-level function was used to generate that data for its plot? I find I can extract the data inside the output list, but I find the row number of that data does not meet the data I used to fitted the brms model. So I was wondering how these data were generated.

I am doing a mixed-effect ordinal logit regression:
brm(formula = form ~ dose + (1|id), data = p504, family = cumulative(“probit”), prior = c(prior(normal(0,10), class = “Intercept”),
prior(cauchy(0,10), class = “b”), prior(cauchy(0,1), class = “sd”))

I found with the code:
conditional_effects(brms_object, categorical = TRUE, probs = c(0.025, 0.975),robust = TRUE)
I got 300 rows with each probability of three outcomes column by column. It does not have id in the model.

However, when I try to use
fitted(brms_object, probs = c(0.025, 0.975, 0.25, 0.75)) which require id and dose.
I got 374 rows same to my data, with id show inside.

Can you explain how the data generated? is it different from the fitted function? If I want an output with 10 kinds of dose (my x, continue variable), without a specific id inside which the function of fitted required me to add id in the conditions (I guess it would be the population-level effect?), what should I do?

Thank you

Hi there,

There’s a lot to unpack in your post. The formula is helpful but without the data its use is limited. A small example with simulated data may be helpful.

Regardless, you should know that conditional_effects() has several knobs you can turn to fit your needs. As a default, ‘random effects’ are not included. In your case that means that the effect of ‘id’ is ignored. You can set re_formula=“NULL” in the conditional_effects() call to include these. Similarly, you can choose to use fitted() or predict() behind the scenes.

My understanding, which may be false, is that conditional_effects() won’t include all the rows in your data. Instead it sets up a data frame of ‘conditions’ (i.e. the value you are going to ‘condition’ the effect of an predictor on the outcome on). So, if you have a model like outcome ~ 1 + age, and you have 1000 different age values in the data set, conditional_effects() will basically create a sequence of 100 age values ranging from min(age) to max(age) and then use this as ‘new data’ into either fitted() or predict() and then plot the values. The 100 points is the default setting and gives smooth plots. Again, you can change this.

The documentation for the function explains this: http://paul-buerkner.github.io/brms/reference/conditional_effects.html

I’m not sure exactly what your goal was with the call to conditional_effects, if not to display the effect of dose on form. If my answer doesn’t help hopefully someone else weighs in!

Hugo

Thank you, your answer helps me a lot. It makes sense that conditional_effects would produce the same results to fitted() by re_formula=“NULL”. However, I would also want to have the same results as conditonal_effects() from fitted(). Do you know how to turn off “random effects” in fitted()?

In the fitted() function the default is to include ‘random’ effects - ie re_formula is set to NULL. If you include re_formula=NA that will ignore all ‘random’ effects.

See the documentation for details: https://www.rdocumentation.org/packages/brms/versions/2.14.0/topics/fitted.brmsfit

Thank you so much
{"ft_lang_label":"__label__en","ft_lang_prob":0.91774625,"math_prob":0.8537954,"size":2823,"snap":"2022-27-2022-33","text_gpt3_token_len":690,"char_repetition_ratio":0.13267116,"word_repetition_ratio":0.0,"special_character_ratio":0.2621325,"punctuation_ratio":0.13103448,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9818522,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-28T21:20:42Z\",\"WARC-Record-ID\":\"<urn:uuid:694de581-4151-4aa1-bbf9-c978ecbaa366>\",\"Content-Length\":\"29223\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:518afae1-c647-453f-a2ae-490f7966aef0>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc273f91-0df0-4898-8e28-0722487075ec>\",\"WARC-IP-Address\":\"64.62.250.111\",\"WARC-Target-URI\":\"https://discourse.mc-stan.org/t/question-for-conditional-effects/18810\",\"WARC-Payload-Digest\":\"sha1:ULCDXMJBKNJ2LV6ORY24QJDNHOYQJPWX\",\"WARC-Block-Digest\":\"sha1:QXOJQYV54GPKIUJVV5CMXWMNMRRXN2YF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103617931.31_warc_CC-MAIN-20220628203615-20220628233615-00437.warc.gz\"}"}