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
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." $\endgroup$ – Nick S Sep 23 '20 at 20:01statsmodels
does give. $\endgroup$ – Nick S Sep 23 '20 at 22:46