offset 偏移项(网上似乎是这样翻译的),在公式里实际含义是什么?
model1 <- lm(mpg ~ wt + cyl, offset = am, data = mtcars)
model2 <- lm(mpg ~ wt + cyl, data = mtcars)
就是 model1 和 model2 的区别是什么
根据 ?lm
帮助对 offset 项的解释
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector or matrix of extents matching those of the response. One or more offset terms can be included in the formula instead or as well, and if more than one are specified their sum is used. See ?model.offset
.
?offset
的解释
An offset is a term to be added to a linear predictor, such as in a generalised linear model, with known coefficient 1 rather than an estimated coefficient.
就是说这一项不用估计,它的回归系数就是 1
> model1
Call:
lm(formula = mpg ~ wt + cyl, data = mtcars, offset = am)
Coefficients:
(Intercept) wt cyl
38.166 -2.818 -1.522
> model2
Call:
lm(formula = mpg ~ wt + cyl, data = mtcars)
Coefficients:
(Intercept) wt cyl
39.686 -3.191 -1.508
> model3 <- lm(mpg - am ~ wt + cyl, data = mtcars)
> model3
Call:
lm(formula = mpg - am ~ wt + cyl, data = mtcars)
Coefficients:
(Intercept) wt cyl
38.166 -2.818 -1.522