deca
deca

Reputation: 740

Set y-axis for glm probit regression in effect plot

I am currently computing binomial probit glm in R.

For analysis of interaction effects, I use the effects package. I want to plot different interactions, where one of the interacting variables is held constant at a fixed level. I do this for several values of the variable to see how the effect evolves.

I use the following operation:

    plot(effect("varL",hx1,given.values=c("varP"=0.7)))
    plot(effect("varL",hx1,given.values=c("varP"=0.1)))

However, to graphically compare the different plots, the y-axis should be the same for all plots, which is not the case. When plotting for different varP values, the y axis changes its range.

When specifying ylim, the plot is also incorrect and shows a completely different segment than specified.

I tried what was recommended in this post (Scaling axis in a GLM plot with library "effects"), however, it resulted in an error message:

plot(effect("varL",hx1,given.values=c("varP"=0.7)), ylim = qlogis(c(0, 0.20)))

Error in valid.viewport(x, y, width, height, just, gp, clip, xscale, yscale,  : 
  invalid 'yscale' in viewport

Now my question: how can I set the y-axis for plotting interaction effects with the effect package using a probit glm model? I am sure the problem is that ylim takes the values as specified without adjusting them into the logit and probit scale. qlogis likely works for logit, but not probit.

Below some code to replicate the issue. You see that the y axis "jumps around", which I want to avoid.

install.packages("effects")
require(effects)

varL <- rnorm(100, mean = 1000, sd = 10)
varP <- rnorm(100, mean = 5)
entry <- as.factor(sample(0:1, 100, replace = TRUE))

dat <- data.frame(varL, varP, entry)

hx1 <- glm(entry ~ varL*varP, data = dat, family = binomial(link = "probit"))



plot(effect("varL",hx1,given.values=c("varP"=min(dat$varP))))
plot(effect("varL",hx1,given.values=c("varP"=max(dat$varP))))

Here are the plots with the "jumping" y-axes:

enter image description here

enter image description here

Upvotes: 0

Views: 1063

Answers (1)

person
person

Reputation: 45

I had a similar problem with logistic regression,actually, and I used the advice Change the y axis on Effect plot in R

Basically all that I needed to do is add the argument rescale.axis=F in addition to ylim=c(0,1)

Upvotes: 1

Related Questions