如何解决R公式中的y〜1,y〜0和y〜-1有什么区别?
在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
不包括拦截
最后两个在功能上是等效的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。