Reputation: 67
In R formulas (e.g. for lm
), which is the difference between y ~ 1
, y ~ 0
and y ~ -1
?
Upvotes: 1
Views: 600
Reputation: 17805
From the ?formula
documentation:
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’.
So:
y ~ 1
includes an intercepty ~ 0
does not include an intercepty ~ -1
does not include an interceptThe last two are functionally equivalent.
Upvotes: 4