# How to calculate statistics for categorical variable level omitted by one-hot encoding?

I'm performing an ordinary least squares regression on a dataset whose predictors are two categorical variables and the dependent variable is continuous.

The resulting model gives me stats like the coefficient and p-value for each value (level) of the categorical variables, except one value is omitted for each variable. After some helpful pointers on my last question, I now realize that's because of the one-hot encoding, and why.

This this answer gives some useful tips on calculating the coefficients of the missing predictors, but I also need the p-values as well.

## Details

I'm using statsmodels in Python, so it'd be great if there was a way to do it using that. Here's how I created and fit the model:

model = statsmodels.formula.api.ols('rates ~ C(models) + C(groups)', data=df)
fitted_model = model.fit()


And here's how my data is structured:

Group    Model    Rate
----------------------
Group A  Model 1  1.3
Group B  Model 7  0.43
Group B  Model 1  0.77
Group G  Model 2  3.2

• You need the p-value of what hypothesis test? – Dave Sep 23 '20 at 19:03
• ... and once you can tell us that, you may discover this is the same as your first question. – whuber Sep 23 '20 at 19:44
• @Dave So I'm using the p-values provided by statsmodels, and my understanding is that's a measure of whether that particular predictor is significantly correlated with the dependent variable. The library's definition is "The two-tailed p values for the t-stats of the params." – Nick S Sep 23 '20 at 20:01
• What hypothesis do you want to test? – Dave Sep 23 '20 at 20:28
• @Dave I think my null hypothesis is that this particular value of this categorical variable is not predictive of the outcome variable. At least, that's my understanding of the other p-values that statsmodels does give. – Nick S Sep 23 '20 at 22:46