if (FALSE) {
# fit an example model
data(book.tee.data)
egdata <- book.tee.data$book.tee.dataframe
result <- ddf(dsmodel = ~mcds(key = "hn", formula = ~sex),
data = egdata[egdata$observer==1, ], method = "ds",
meta.data = list(width = 4))
# make a base plot, showpoints=FALSE makes the plot less busy
plot(result, showpoints=FALSE)
# add lines for sex one at a time
add.df.covar.line(result, data.frame(sex=0), lty=2)
add.df.covar.line(result, data.frame(sex=1), lty=3)
# add a legend
legend(3, 1, c("Average", "sex==0", "sex==1"), lty=1:3)
# alternatively we can add both at once
# fixing line type and varying colour
plot(result, showpoints=FALSE)
add.df.covar.line(result, data.frame(sex=c(0,1)), lty=1,
col=c("red", "green"))
# add a legend
legend(3, 1, c("Average", "sex==0", "sex==1"), lty=1,
col=c("black", "red", "green"))
}
Run the code above in your browser using DataLab