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.
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