StatsModels OLS 回归中公式的交互作用和 * 项之间的差异 [英] Difference between the interaction : and * term for formulas in StatsModels OLS regression
问题描述
我正在学习 Statsmodel,但无法弄清楚 StatsModels OLS 回归中公式的 : 和 *(交互项)之间的区别.你能给我一个提示来解决这个问题吗?
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?
谢谢!
文档:http://statsmodels.sourceforge.net/devel/example_formulas.html
推荐答案
":" 将给出一个回归没有级别本身.只是你提到的互动.
":" 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.
例如
一.GLMmodel = glm("y ~ a: b" , data = df)
你将只有一个自变量,它是a"乘以b"的结果
you'll have only one independent variable which is the results of "a" multiply by "b"
b.GLMmodel = glm("y ~ a * b" , data = df)
您将有 3 个自变量,它们是a"乘以b"的结果+ "a" 本身 + "b" 本身
you'll have 3 independent variables which is the results of "a" multiply by "b" + "a" itself + "b" itself
这篇关于StatsModels OLS 回归中公式的交互作用和 * 项之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!