简体   繁体   English

相互作用之间的区别:和 * StatsModels OLS 回归中公式的术语

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

Hi I'm learning Statsmodel and can't figure out the difference between: and * (interaction terms) for formulas in StatsModels OLS regression.您好,我正在学习 Statsmodel,无法弄清楚 StatsModels OLS 回归中公式的:和 *(交互项)之间的区别。 Could you please give me a hint to figure this out?你能给我一个提示来解决这个问题吗?

Thank you!谢谢!

The documentation: http://statsmodels.sourceforge.net/devel/example_formulas.html文档: 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. “*” 给予水平本身+你所提到的交互的回归。

for example 例如

a . a GLMmodel = glm("y ~ a: b" , data = df)

you'll have only one independent variable which is the results of "a" multiply by "b" 你将只有一个自变量,它是“a”乘以“b”的结果

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 你将有3个独立变量,这是“a”乘以“b”+“a”本身+“b”本身的结果

Using A*B is really just shorthand for A + B + A:B使用A*B实际上只是A + B + A:B简写

A:B specifies the interaction itself. A:B指定交互本身。 This is literally the product of the two variables.这实际上是两个变量的乘积。 As such, it rarely makes sense to fit a model with only this term, so we almost always fit the main effects, A and B too (see here for reasons why).因此,仅用这一项来拟合 model 几乎没有意义,因此我们几乎总是拟合主效应, AB (请参阅此处了解原因)。 Since this is so common, the shorthand notation A*B for this is quite common in many statistical software packages/platforms.由于这很常见,因此缩写符号A*B在许多统计软件包/平台中很常见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM