问题
Hi I'm learning Statsmodel and can't figure out the difference between : and * (interaction terms) for formulas in StatsModels OLS regression. Could you please give me a hint to figure this out?
Thank you!
The documentation: http://statsmodels.sourceforge.net/devel/example_formulas.html
回答1:
":" will give a regression without the level itself. just the interaction you have mentioned.
"*" will give a regression with the level itself + the interaction you have mentioned.
for example
a. GLMmodel = glm("y ~ a: b" , data = df)
you'll have only one independent variable which is the results of "a" multiply by "b"
b. GLMmodel = glm("y ~ a * b" , data = df)
you'll have 3 independent variables which is the results of "a" multiply by "b" + "a" itself + "b" itself
来源:https://stackoverflow.com/questions/33050104/difference-between-the-interaction-and-term-for-formulas-in-statsmodels-ols