Strange behavior of I() in left-/right-hand side of formula
- by adibender
set.seed(98234)
y <- rnorm(100)
x <- rnorm(100)
lm0 <- lm(y ~ x)
lm1 <- lm(I(y) ~ I(x))
all work perfectly fine and I guess we can agree that ´lm0´ is what one would expect to happen. lm1 is equal to lm0 (judging by coefficients). So are
set.seed(98234)
lm3 <- lm(I(rnorm(100)) ~ rnorm(100))
set.seed(98234)
lm4 <- lm(rnorm(100) ~ I(rnorm(100)))
But when I() is on neither or both sides of the formula I don't get the results from above:
set.seed(98234)
lm2 <- lm(I(rnorm(100)) ~ I(rnorm(100)))
set.seed(98234)
lm5 <- lm(rnorm(100) ~ rnorm(100))
Any ideas why?