The meaning of tilde operator in model?

r

Solution

Only `0` (without intercept) and `1` (with intercept) have meaning in `?formula`. So `u~2` will result in error.

Now `plot(u~0)` and `plot(u~1)` both plot `u` against running index, resulting in the same plot. See `?plot.formula`

Problem

``` u=1:25 plot(u~1) plot(u~0) ``` Why can't `plot(u~2)`produce a plot? What is the difference between `plot(u~0)`and `plot(u~1)`? Why do they have the same results? ``` y=1:25 x=sin(2:26) plot(y~x) plot(y,x) ``` and what is the difference between `plot(y~x)` and `plot(y,x)` then? ``` x<-c(318,910,200,409,415,502,314,1210,1022,1225) y<-c(524,1019,638,815,913,928,605,1516,1219,1624) lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x 395.567 0.896 lm(y~x+1) Call: lm(formula = y ~ x + 1) Coefficients: (Intercept) x 395.567 0.896 ``` Why they have the same coefficients?

Original source