【问题标题】:What is the difference between y ~ 1, y ~ 0 and y ~ -1 in R formulas?R公式中y~1,y~0和y~-1有什么区别?
【发布时间】:2021-02-19 05:33:00
【问题描述】:

在 R 公式中(例如 lm),y ~ 1y ~ 0y ~ -1 之间的区别是什么?

【问题讨论】:

  • 其中一些 answers 可能会有所帮助 - 这个问题非常接近重复。

标签: r formula lm


【解决方案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 不包括拦截

最后两个在功能上是等价的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多