Strange behavior of I() in left-/right-hand side of formula
Posted
by
adibender
on Stack Overflow
See other posts from Stack Overflow
or by adibender
Published on 2012-12-14T22:08:36Z
Indexed on
2013/10/17
15:56 UTC
Read the original article
Hit count: 403
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?
© Stack Overflow or respective owner