I want to perform a linear regression with some categorical predictor $z$ and some other continuous and categorical control variables. I use one-hot dummy encoding for $z$, with e.g. $z_a$ as the base level and dummies for levels $z_b, z_c,$ and $z_d$. However, with this regression I can only compare and test the difference between levels $z_b, z_c,$ and $z_d$ with level $z_a$, but not with each other.
To compare $z_b$ and $z_c$ I could use a new dummy encoding with $z_b$ as base level and perform a new regression. For all pair-wise comparisons I could choose each level of $z$ as the base level once. Is there an easier way to do this (in Python or R)?
From what I understand, with Tukey's test I can compare all means, but cannot correct for any other variables.