strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
603 stars 91 forks source link

Confidence intervals not extending all the way along line #870

Open adityac95 opened 1 year ago

adityac95 commented 1 year ago

Hi, thanks for your great package.

I built a linear mixed effects model called em_lmer_cadencesc_priors_props_int with the following formula:

response ~ prior_dcs 
           + prior_dcs:proportion_dcs 
           + (1|stim_id) 
           + (prior_dcs + prior_dcs:proportion_dcs||participant_private_id)

Having fit the model, I subsequently tried to plot it using sjPlot's plot_model function as follows:

plot_model(em_lmer_cadencesc_priors_props_int,
           type='pred',
           terms=c('prior_dcs','cadence_sum_contrast','proportion_dcs [.2,.5,.8]'))

However, the confidence intervals are only displayed part-way along the lines:

image

Is there any way to get them to extend the whole way along? The maximum possible value of prior_dcs is 20.

adityac95 commented 1 year ago

BTW, when I plot at just a single level of proportion_dcs, the confidence interval extends all the way:

plot_model(em_lmer_cadencesc_priors_props_int,
           type='pred',
           terms=c('prior_dcs','cadence_sum_contrast','proportion_dcs [.2,]'))

image

adityac95 commented 1 year ago

Hi, I'm still having this issue -- any ideas?

strengejacke commented 1 year ago

the range of ylim (see ?ggplot2::ylim) is not large enough. I suggest using ggpredict() directly, the plot() method is more flexible (see also https://strengejacke.github.io/ggeffects/articles/introduction_plotmethod.html#control-y-axis-appearance).

You could do

library(ggeffects)
pr <- ggpredict(
  em_lmer_cadencesc_priors_props_int,
  terms=c('prior_dcs','cadence_sum_contrast','proportion_dcs [.2,.5,.8]')
)
plot(pr, limits = c(0, 20))