So I get a bit confused by the lm()-command. I tried it with
The answers can be found on the help page for the function. In the
Details section we have:
A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response.
There are more details (also linked to from the
lm help page to
formula. In the details sections for
formula, we have:
The ~ operator is basic in the formation of such models. An expression of the form y ~ model is interpreted as a specification that the response y is modelled by a linear predictor specified symbolically by model.
So to summarize, you define your model in symbolic terms where the LHS is your response variable, and the RHS are your predictor variable(s). You get different answers because in one model,
y is your response variable and the other is
If you weren't aware, you can access the help page for nearly all functions with
? at the command line, i.e.