1

UPDATE BELOW

I am running a logistic regression model in R, in which the DV has four categories, one of which, however, is the baseline. The baseline category represents the absence of the phenomenon I am predicting, whereas the other three categories represent three different types of that phenomenon. To do this I am using the nnet package (nnet::multinom). In the regression table I obtain, everything is perfect, the baseline is treated as the baseline and only the coefficients (and SEs, stars etc.) for the effects on the three non-baseline categories are shown, as they should. However, When trying to plot the marginal effects, using a number of different methods, such as the plot_cap function from the marginaleffects package, and the plot_model function from the sjPlot package, the marginal effects of all of the categories are plotted, including the baseline category, and those of non-baseline categories 1 and 2 are plotted in accordance with the regression results, but the third non-baseline category is represented as a flat line, whereas its coefficient is actually quite large in one case. I'm feeling that the function may have taken category 3 as the baseline, but I'm not 100% sure. If it is indeed the baseline that is the problem, how do I force the plotting functions to pick the baseline I want?

For the plots, I'm using the following codes:

plot_cap: plot_cap(model_2, condition = c("clientelism", "group"), type = "probs")
plot_model: plot_model(model_1, type = "pred", terms = c("distance_coalition_mean"))

As you can see below, I'm plotting the marginal effects of different IVs from 2 different models using different methods, and they all show up with a flat line for the third category. The coefficient for the effect of clientelism on the outcome being of category 3 in model 2 is 8.58, significant at the 0.01 level, and the effect of distance_coalition_mean on category 3 in model 1 is 0.341 (not significant).

marginal effects of clientelism, using plot_cap:

enter image description here

marginal effects of distance_coalition_mean, using plot_model:

enter image description here

I defined the baseline of the DV in the following way:

data$main_DV2 <- relevel(data$main_DV, ref = "0")

Out of this dataset, I then created two subsets, one to be used with model_1 (sample_1) and the other with model_2 (sample_2).

The model specifications are the following:

model_1 <- nnet::multinom(main_DV2 ~ seat_share_assembly + distance_coalition_mean + distance_opposition_mean + cabinet_seat_share + age_democracy + inflation + committees_per_portfolio + prestige1 + Benin + Brazil + Chile + Indonesia + Kenya + Malawi + Philippines + Uruguay, data = sample_1, trace = FALSE)

model_2 <- nnet::multinom(main_DV2 ~ seat_share_assembly + distance_coalition_mean + distance_opposition_mean + clientelism*local_org_strength + cabinet_seat_share + age_democracy + inflation + committees_per_portfolio + prestige1 + Benin + Brazil + Chile + Indonesia + Kenya + Malawi + Philippines + Uruguay, data = sample_2, trace = FALSE)

I'd greatly appreciate any help!

UPDATE

I obtained the predicted probabilities for both models using the predictions(model_x) functions from the marginaleffects package, which showed that the predicted probabilities for group 3 are significantly smaller than those for the other groups:

Model 1:

distribution predicted probabilities model 1

Model 2:

distribution predicted probabilities model 2

Hence, the flat line for group 3 seems to be a scale problem. My question then becomes how to change the scale for only the graph corresponding to group 3 in the second figure I posted, either using plot_model method described above or using

plot_cap(model_2, condition = "clientelism", type = "probs") + facet_wrap(~group)

which also generates 4 separate graphs rather than a single combined one. I haven't been able to find this in the documentation of neither the marginaleffects nor the sjPlot packages.

Jorissimo
  • 11
  • 4
  • 1
    Can you make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and provide your dataset using `dput()`? – jrcalabrese Jan 17 '23 at 14:52
  • The thing is that I'm aiming to publish an article based on these data and so I cannot simply post it here. I'm not sure how dput works, does it somehow encrypt the data? – Jorissimo Jan 17 '23 at 17:09
  • You don't need to post your exact data, but you can recreate your issue using a built-in dataset (e.g., `mtcars`, `iris`) or making up fake/sample data. If you made fake data, you would provide it using `dput(name_of_data)`. [Read more about `dput()` here](https://stat.ethz.ch/R-manual/R-devel/library/base/html/dput.html). – jrcalabrese Jan 17 '23 at 17:17
  • Okay, sounds good. I will try to replicate the issue with mtcars. – Jorissimo Jan 17 '23 at 17:27

0 Answers0