Difference between the interaction : and * term for formulas in StatsModels OLS regression

谁说我不能喝 提交于 2019-12-09 13:15:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!