0
votes

I would like to plot the predicted probabilities of Y (binary outcome) over the range of observed x values (x=age). I use the following code to produce the plot:

(1) I calculate the predicted probabilities of Y over a specified range of x-values (xlevels = x.list) for my independent variable (age), and save it in an object.

prob   <-  effect(c("age"),M, xlevels = x.list)  

(2) Then I plot that object, customising certain plot appearances (such as axis labels, color of confidence intervals, etcetera).

plot(prob, 
     xlab="x", 
     ylab="Pred. prob.", 
     confint=list(col="red", alpha=0.3),
     lines=list(col="red")
     rug=FALSE, main="")

This produces a plot that almost looks like the one I would like to have. However, when trying to customise the main title, the y and x axis limits, as well as the ticks on the axis, the plot gets produced, but unfortunately also messed up (the y axis does not range from 0 to 1, and the actual line with confidence intervals gets pushed out of the plots' margins).

  plot(prob, 
     xlab="x", 
     ylab="Pred. prob.", 
     confint=list(col="red", alpha=0.3),
     lines=list(col="red")
     rug=TRUE,
     axes=list(y=lim={c(0, 1, 0.1)})))

In particular, I would like to change the y-axis so that it ...

(a) ranges from 0-1

(b) with where ticks in increments of 0.1.

(c) I further would like to rid of the box around the plot, i.e. only have the x and y axis drawn.

I have been trying to read up on ?plot.eff, but unfortunately cannot get the legacy arguments to work. Any input on how the code should be modified to get it to work would be much appreciated.

1

1 Answers

0
votes

axes=list(y=lim={c(0, 1, 0.1)})) looks very strange, have you tried just ylim=c(0,1)

also do main=""