2

I have read the documentation about the I() function, but I have a hard time understanding what it actually does.

Could you please explain to me in what cases is it useful and how does it impact the computation in the models below?

data(cars)
m1 <- lm(dist ~ speed  + I(speed^2), data = cars)
m2 <- lm(dist ~ speed  + speed^2, data = cars)
summary(m1)
summary(m2)

When I try to inspect the differences between:

a <- I(cars$speed^2)
b <- cars$speed^2

The output of a and b is the same, but the class is different.

Thank you.

Cowboy_Owl
  • 77
  • 1
  • 6
  • 1
    You might find this helpful: [r4ds.had.co.nz/model-basics.html#transformations](http://r4ds.had.co.nz/model-basics.html#transformations) – markus Sep 25 '18 at 09:54
  • 1
    I have added a answer [HERE](https://stackoverflow.com/questions/24192428/what-does-the-capital-letter-i-in-r-linear-regression-formula-mean) that might give you some insight into `I` function: – Andre Elrico Sep 25 '18 at 10:00

0 Answers0