# Plotting the results of your logistic regression Part 1: Continuous by categorical interaction
We'll run a nice, complicated logistic regresison and then make a plot that highlights a continuous by categorical interaction.
```{r generate_fake_data}
set.seed(24601) # setting this so the random results will be repeatable
library(MASS)
covmat <- matrix(c(1.0, 0.2, 0.6,
0.2, 1.0, -0.5,
0.6, -0.5, 1.0), nrow=3) # the true cov matrix for my data
data <- mvrnorm(300, mu=c(0,0,0), Sigma=covmat) # generate random data that match that cov matrix
colnames(data) <- c("X1", "X2", "DV")
data <- as.data.frame(data)
data$group <- gl(n=3, k=ceiling(nrow(data)/3), labels=c("a", "b", "c", "d"))
# add some group differences and interaction stuff...
data$DV <- with(data, ifelse(group=="c" & X1 > 0, DV+rnorm(n=1, mean=1),
ifelse(group=="b" & X1 > 0, DV+rnorm(n=1, mean=2) , DV)))
# make DV binary
data$DV <- ifelse(data$DV > 0, 1, 0)
head(data)
This file has been truncated. show original