Using the debt
data set from the package faraway
. So basically firstly I was asked to create a model using multinom
function and use ccarduse
as the response and prodebt
as the single covariate. Then I had to create a plot of predicted probabilities of belonging to each credit card use category against prodebt
score.
mod1 <- multinom(ccarduse ~ prodebt, debt)
inclevels <- 0:464
debt$ccarduse <- as.factor(debt$ccarduse)
debt$prodebt <- as.factor(debt$prodebt)
preds <- predict(mod1, data.frame(income=inclevels), type="probs")
# Warning message:
# 'newdata' had 465 rows but variables found have 464 rows
Plot of predicted probabilities of belonging to each credit card use category against prodebt score
plot(inclevels, preds[, 1], type="l", ylim=c(.15, .6), xlab="prodebt",
ylab="Probabilities of credit card use", cex.lab=1.3, cex.axis=1.3)
lines(inclevels, preds[, 2], lty=2)
lines(inclevels, preds[, 3], lty=3)
legend(x="topright", c("1", "2", "3"), lty=c(3, 2, 1), cex=1.5)
As seen I got a warning message and the plot looks really creepy. Is there anything I did wrong or I could fix to make it look neat.