Cross-Classified Data Structure in Brms - Longitudinal Best Approach?


I have a non-nested panel data structure of firms across 24 different countries and 24 different years. Not every firm has data for every year. Every firm belongs to one country. I model this data structure using the following brms() syntax.

y ~ 1 + x1 + ( 1 + x1 | year:country) + (1|year) + (1|country)

  1. Does this model formula / approach make sense in terms of modelling this non-nested multiple membership structure?

  2. Is it correct to say that this structure implies that individual firms are nested within all three groups (country, year, country:year), rather than only within country:year groups? (I ask because it also possible, apparently, to treat country:years as cross-classified within countries and years along with individual firms as strictly nested in country:years.)***

Many thanks,


*** Alexander W. Schmidt-Catran and Malcolm Fairbrother, `The Random Effects in Multilevel Models: Getting Them Wrong and Getting Them Right’, European Sociological Review, 2016, Vol. 32, No. 1, 23–38.

  1. What I am a little confused about is that x1 has a varying effect over the year:country combinations but not over the years or contries themselves. Does this assumption make sense?

  2. Seems sensible to me although I don’t understand what exactly you mean with the sentence in parantheses and I don’t have the time to look at the reference right now.

1 Like

Thanks for this, Paul.

Could you expand a little on your point .1 if you have a moment?

Point 2. Fairbrother (below) describes Model F as follows: “Model F treats country-years as cross-classified within countries and years, and individuals as strictly nested in country-years.”

And to your Point 1. above, Fairbrother says of Model A: " This structure implicitly treats any time-invariant country-level variable as a time-varying one, and thus as having 100 unique values [20 countries each with 5 unique values]. Conversely, the model does not regard repeated observations on countries as nested within countries".

Many thanks,

With regard to (1) I would probably write

1 + x1 + ( 1 + x1 | year:country) + (1 + x1 | year) + (1 + x1 | country)

if x1 is varying both within year and country.

The nested structure presented in the paper is likely equivalent to the sort of non-nested formulation that you use in brms. This can be checked by taking the hierarchical equations from the paper (if they are some) and writing down all within the same linear predictor.


Thank you!

Sorry, one more thing, would this equation below, as estimated by brms():

1 + x1 + ( 1 + x1 | year:country) + (1 + x1 | year) + (1 + x1 | country)

be considered to be a cross-classified data structure with firms nested separately within countries, and then separately within years, and then separately within country:years? Just wondering how best to understand it hierarchically within brms().

Since I would speculate that we would want years to be nested within year:country; and same with our country groups: surely they should also be thought of as being nested within year:country? But not sure if that would make a difference theoretically and practically…


I would say you could call that structure cross-classified in the way you described.
I would personally speak of year:country being nested within year and country (not the other way round) in the same way as students are nested within classes.