Guest User

Untitled

a guest
Oct 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. Y ~ X1
  2. Y ~ X2
  3.  
  4. df <- data.frame(
  5. x1 = c(0, 0, 0, 1, 1, 1),
  6. x2 = c(0, 1, 2, -1, 0, 1),
  7. y = c(0, 2, 4, 2, 4, 6)
  8. )
  9.  
  10. > summary(lm(y ~ x1, data=df))$r.squared
  11. [1] 0.2727273
  12. > summary(lm(y ~ x2, data=df))$r.squared
  13. [1] 0.2066116
  14. > summary(lm(y ~ x1 + x2, data=df))$r.squared
  15. [1] 1
Add Comment
Please, Sign In to add comment