0

I am using a binary logistic regression model to investigate the causes of populism in Denmark using the below regression model:

Denmark <- glm(popvt ~ trstprl + trstplt + stfgov + stfdem + mnactic + agegroup + eisced, 
               data = dktrim, 
               family = binomial(link = "logit"))

Where popvt is a two-level factor, trstprl/trstplt/stfgov/stfdem a set of integers ranging from 0-10, and mnactic, agegroup and eisced are four-, four- and three-level factors respectively.

After successfully running the regression I used sjPlot's plot_model to obtain a plot model of odds ratios for each independent variable, as shown here: Plot of Odds Ratios in explaining support for populist parties in Denmark through this code:

plot_DK <- plot_model(Denmark)

I would like to reduce the scale of the x-axis for odds ratios to between 0.1 and 5.

But when I attempt to do so with the following I get the error:

Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale. Error: Discrete value supplied to continuous scale

plot_DK + xlim(0.1, 5)

I had the same error when I used:

plot_DK + scale_x_continuous(0.1, 5)

I know that ggplot2 and sjPlot are definitely compatible as I was able to recolour the plot despite being unable to change the x-axis.

How do I resolve this error?

vpz
  • 984
  • 1
  • 15
  • 26
Old Sol
  • 3
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 28 '20 at 21:35
  • Maybe you could use the `axis.lim` parameter of the `plot_model` function to specify direclty the x axis when defining the plot.. – Raphaele Adjerad Mar 29 '20 at 07:18

0 Answers0