Random parameter model in brms

I am trying to fit an ordered regression model but with random parameters as explained in random parameter multinomial for the multinomial model.

This means allowing the variable coefficients to vary across the population according to some pre-specified distribution and If a coefficient is found to vary significantly across observations, it implies that each observation has its own coefficient.

I understand that brms can fit the multilevel models but my data cannot be clustered because each observation represents an accident with its corresponding attributes. I have 926 accidents and below is the sample of the data I am working on with Y as response variable and all the X’s as predictors. I have been looking around the forum but could not find anything to help me with my problem I will appreciate some pointers on how to achieve this using Brms (if possible). Thank you.

ID	Y	X1	X2	X3	X4	X5
1	Minor	Thursday	Spring	Weekday	Day	No
2	PDO	Wednesday	Spring	Weekday	Dark	Yes
3	Serious	Friday	Summer	Weekend	Dark	Yes
4	PDO	Wednesday	Summer	Weekday	Day	No
5	PDO	Thursday	Summer	Weekday	Day	Yes
6	Minor	Tuesday	Fall	Weekday	Day	No
7	Serious	Sunday	Summer	Weekend	Day	No
8	PDO	Friday	Spring	Weekend	Day	Yes
9	Serious	Thursday	Spring	Weekday	Day	Yes
10	Minor	Thursday	Spring	Weekday	Dark	Yes
11	PDO	Saturday	Spring	Weekend	Day	No
12	PDO	Thursday	Summer	Weekday	Dark	No
13	PDO	Saturday	Fall	Weekend	Day	No
14	Minor	Monday	Summer	Weekday	Day	No
15	Minor	Monday	Summer	Weekday	Dark	No
16	Minor	Monday	Spring	Weekday	Dark	No
17	PDO	Sunday	Spring	Weekend	Dark	Yes
18	Minor	Sunday	Spring	Weekend	Day	Yes
19	Minor	Friday	Fall	Weekend	Day	No
20	Minor	Sunday	Summer	Weekend	Dark	Yes

brms example.csv (1014 Bytes)

Hi, it’s a little unclear what you would like to do. Could you please clarify?

I took a brief look at your data but couldnt see variables called X or Y.

Thank you for your response, I have edited the topic and added a link that explains the random parameter model for multinomial regression. I am trying to achieve the same for bayesian ordered regression.

I don’t have time to read the paper you linked to, but for response distributions that don’t have a free scale parameter, you can include a per-observation random effect: brm(Y ~ X1 + ... + (1 | ID), ...). Not sure about multinomial but maybe worth a shot eh?

Thank you again. I have come to realize what I am looking for is what is called Distributional Models in the BRMS package. The example of the model provided in the BRMS tutorial however considers the gaussian distribution and models both the mean and standard errors as: brm(bf(Y~X1+…,sigma~X1+…),data=…)

Are these models possible for ordered response variables, and how can I specify the other parameters of the apart from the mean. Please excuse me if the question is so basic. I would appreciate any help.

The paper below explains how to fit ordinal models with brms (Box 1, page 7). You can model the latent scale with something like brm(bf(Y ~ X, disc ~ X), ...).

Hi @matti, thank you for pointing me in the right direction. I was able to specify the model for my data as described in the paper for the cumulative ordinal regression. However, I came to an impasse again due to an error after fitting a category specific model because some of my variables did not follow the proportional odds (PO) assumption.

I started with a very simple model with a single variable (that does not follow the PO assumption) and accounting for unequal variances. My line of code was as shown below.

model1<- brm(bf(Severity~cs(Time),disc~0+cs(Time)),data =source1,
family = acat(“probit”),
chains=4,inits=0,warmup = 1000,iter = 4000,algorithm = “sampling”, seed = 125,
control = list(adapt_delta = 0.99,max_treedepth = 20))

Apart from other warnings that are common when fitting the models. I got an error as shown in the picture below.

I am wondering what is wrong in my model specification and how I can get rid of the error. Thank you for the help.

It looks like the error could be a bug in brms (i.e. it should fail with a more informative error message), paging @paul.buerkner

Hmm, yeah that looks strange. @hjosee can you make a minimal reproducible example for me to check out what exactly is happening?

Thank you for your reply. I have attached subset of the data used for fitting the model. Time was treated as categorical variable and the code specification was as mentioned in my previous post.

model1<- brm(bf(Severity~cs(Time),disc~0+cs(Time)),data =source1,
family = acat(“probit”),
chains=4,inits=0,warmup = 1000,iter = 4000,algorithm = “sampling”, seed = 125,
control = list(adapt_delta = 0.99,max_treedepth = 20))

brms example.csv (7.6 KB)

The problem is simply that category specific effects are not supported for disc but only for the main parameter. I am not even sure CS on disc would be sensible, that is, identified at all.

In any case, the error message is confusing and I will try to improve it.

1 Like

The error message is now hopefully more informative.