Create a hiearchical linear regression with 5 levels

This should not be a problem. You can check out this notebook to see how to handle nested data and bake it into hierarchical models. You might need to recode some of the values in your data to make things a bit easier for yourself. For examples, if you category 1 has 2 “first colors” and category 2 has 3, then you might want to code your “first colors” as:

cat1_color1
cat1_color2
cat2_color1
cat2_color2
cat2_color3

Then the number of “first color”-related parameters would be equal to the number of unique “first color” values in your data. Similar things could be done for the second color.

1 Like