Created
July 2, 2020 18:32
-
-
Save cddesja/c32be7f794b7b0cec9a685ada678f95d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mtcars$vs.f <- ifelse(mtcars$vs == 0, "0", "1") | |
mtcars.0 <- subset(mtcars, vs.f == "0") | |
mtcars.1 <- subset(mtcars, vs.f == "1") | |
coef(lm(mpg ~ cyl * vs.f, data = mtcars)) # association between 1 should be strong | |
coef(lm(mpg ~ cyl, data = mtcars.0)) # association between 0 smaller | |
coef(lm(mpg ~ cyl, data = mtcars.1)) # association between 1 larger | |
cor(mtcars.0$mpg, mtcars.0$cyl) | |
cor(mtcars.1$mpg, mtcars.1$cyl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment