How to add continuous variable in a hierarchical model


Hi, I am trying to build a hierarchical model but need some guidance, thanks in advance for your help!

I am trying to model the a pollution changes with time of some cities. The city is a discrete variable that can be added to the hierarchical model with no problem. The question is how to pool the variables that are continuous, such as population of each city (kind of continuous) and the coordinate of each city (cities close to each other might be similar). Any thought or example will be much appreciated!


The continuous variable you can put in the fixed effect, or the random effect associated with each city. In the mixed effect model formula it would be something like:
Pollution ~ ... + population + (1|cities)
Pollution ~ ... + (1 + population|cities)

As for the coordinated of each city, usually this is modelled as a CAR model, see an example here: