Plotting individual fitted lines for each level of a random factor

Hi,

I want to plot offspring age on the x-axis and no_of_times_mother_carries/no_of_times_mother_moves on the y-axis. I want to then add fitted lines for each level of mother ID. Could someone please help me with plotting such a graph?

brm.formula = brmsformula(formula = no_of_times_mother_carries|trials(no_of_times_mother_moves) ~ z.offspringAge + males_P_A +(1 + z.offspringAge | motherID), family = ‘beta_binomial’)

Hey @Revathe, is there a way you could pose your question with an open data set that shares the same basic structure of your data? That might make it easier for others to help. For possible data set ideas, consider executing data(package = "brms") or data(package = "lme4").

Thanks for the suggestion, but I am unable to find an open dataset with a similar structure as mine. Since I cannot share my data, would it help if I explained the structure of the dataset?

no_of_times_mother_carries: integer value (can include 0); average value 15
no_of_times_mother_moves: non-zero integer value; average value 50
z.offspringAge: z-transformed age (range: >0 to 8)
males_P_A: categorical (2 levels)
motherID: categorical (11 levels)

no_of_times_mother_carries is always less than or equal to no_of_times_mother_moves
~1000 rows of data

The z.age range is not the same across the levels of mother ID - it can start and end anywhere between >0 and 8.

Each level of mother ID has observations that fall under each level of males_P_A (essentially, 11*2).

I figured out how to plot this graph but any suggestions are welcome!

1 Like

Can you share the code and the resulting plot, I’d like to see it, and I imagine others probably would find it useful as well