请问R语言线性拟合中,如何才能不添加截距项?一般用lm()进行回归的时候都会自动产生截距项,那么怎样才能不产生截距项呢?谢谢!
请问R语言线性拟合中,如何才能不添加截距项?
lm(y~x+0)
</p><br />
lm(y ~ x - 1)<br />
</p>回复 第3楼 的 nan.xiao:中级会员就是猛啊,代码写这么漂亮。
仰视楼上[s:11]
谢谢两位高手!
回复 第4楼 的 cloud_wei:哎 你就甭揶揄我啦 [s:18]
4 个月 后
回复 第3楼 的 nan.xiao:为什么用lm(y~x-1)拟合的直线还是不经过原点呢
回复 第7楼 的 rjblwhp:为什么你不给个可重复运行的例子呢?
对原始数据中心标准化以后好像也不会有截距项
回复 第7楼 的 rjblwhp:One possibility is that the particular parameterization (say, for a factor instead of a continuous covariate) masked that fact. Another possibility is that the range of <bblatex>x</bblatex> is far from 0, which makes it seemingly not passing the origin.