I need to add regression lines for each different combination of Sex and Race(white/nonwhite). These are the models and the plot I made, but I have no clue on where to put these lines and how to do it.
colors <- interaction(Race, Sex)
shapes = c(16)
shapes <- shapes[as.numeric(Sex)]
plot(Years_Service, Average_Score, main="Score by Time", xlab="Years of service", ylab="AVG Score", col = colors, pch=16)
legend("topleft", title="Legend", legend=c("White Male"," White Female", "Nonwhite Male", "Nonwhite Female"),
col=c("blue", "red", "green", "black"), pch=16, cex=0.54)
lines(lowess(Years_Service, Average_Score),col=2)
model1<-lm(Average_Score~Years_Service+Sex+Race)
summary(model1)
plot(Average_Score)
model2<-lm(Years_Service~Sex)
summary(model2)
plot(model2)
model3<-lm(Years_Service~Race)
summary(model3)
plot(model3)
Thanks in advance.