【发布时间】:2021-02-19 05:33:00
【问题描述】:
在 R 公式中(例如 lm),y ~ 1、y ~ 0 和 y ~ -1 之间的区别是什么?
【问题讨论】:
-
其中一些 answers 可能会有所帮助 - 这个问题非常接近重复。
在 R 公式中(例如 lm),y ~ 1、y ~ 0 和 y ~ -1 之间的区别是什么?
【问题讨论】:
来自?formula 文档:
The ‘-’ operator removes the specified terms, so that ‘(a+b+c)^2 -
a:b’ is identical to ‘a + b + c + b:c + a:c’. It can also used to
remove the intercept term: when fitting a linear model ‘y ~ x - 1’
specifies a line through the origin. A model with no intercept
can be also specified as ‘y ~ x + 0’ or ‘y ~ 0 + x’.
所以:
y ~ 1 包含一个拦截y ~ 0 不包含拦截y ~ -1 不包括拦截最后两个在功能上是等价的。
【讨论】: