Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import statsmodels.api as sm
- from statsmodels.formula.api import ols
- # Define target & independent variables
- # C(var_name) indicates variable is categorical
- formula = 'Quantity ~ Discount + C(Employee) + C(Region) + C(CategoryName)'
- # Fit ordinary least squares model to data
- lm = ols(formula, df).fit()
- # Save 2-tail ANOVA test results to dataframe
- table = sm.stats.anova_lm(lm, typ=2)
- print(table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement