Hello I have the following logistic model with a categorical variable interaction which I wish to plot in R but I am struggling to find any solutions -
M <-glm(disorder~placement*ethnic, family=binomial)
The ethnic variable has three categories (White, Black & Other) The 'other' category interacts with the variable placement to produce a significant result.
I've tried the following but it isn't displaying a line:
disorder_1 <- cbind(disorder) - 1
any_ic_dat <- as.data.frame(cbind(ethnic,disorder_1,placement))
g <- glm(disorder_1~placement+ethnic, family=binomial,any_ic_dat)
plot(placement,disorder_1)
x <- seq(0,19, length.out=1500)
mydata <- data.frame(ethnic='Other', placement=x)
y.ethnic<-predict(g,newdata=mydata)
lines(x,y.ethnic, col='red')
How would I plot this on a graph?
Thank you in advance!
Sarah


predict.glm– John Jan 05 '13 at 14:16