Simulate \(y\) data for a linear regression with one continuous predictor \(x_1\) and one a binary predictor \(x_2\), and an interaction term. This is linear regression with varying intercept and varying slope.
Code
dg$y =0+2*x1 +3*x2 +2*x1*x2 +rnorm(n, 0, .1)g =ggplot(dg, aes(x1, y, group = x2))+geom_point(alpha =0.1)g %>%pub(xlim =c(0,1))