Please forgive my ignorance. All I'm trying to do is add a squared term to my regression without going through the trouble of defining a new column in my dataframe. I'm using statsmodels.formula.api (as stats) because the format is similar to R, which I am more familiar with.
hours_model = stats.ols(formula='act_hours ~ h_hours + C(month) + trend', data = df).fit()
The above works as expected.
hours_model = stats.ols(formula='act_hours ~ h_hours + h_hours**2 + C(month) + trend', data = df).fit()
This omits h_hours**2 and returns the same output as the line above.
I've also tried: h_hours^2, math.pow(h_hours,2), and poly(h_hours,2) All throw errors.
Any help would be appreciated.
h_hours
values? If it's treated as categorical, then you need to convert to float or some other type that is treated by patsy as numeric. – Backstitch