Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Y ~ X1
- Y ~ X2
- df <- data.frame(
- x1 = c(0, 0, 0, 1, 1, 1),
- x2 = c(0, 1, 2, -1, 0, 1),
- y = c(0, 2, 4, 2, 4, 6)
- )
- > summary(lm(y ~ x1, data=df))$r.squared
- [1] 0.2727273
- > summary(lm(y ~ x2, data=df))$r.squared
- [1] 0.2066116
- > summary(lm(y ~ x1 + x2, data=df))$r.squared
- [1] 1
Add Comment
Please, Sign In to add comment