0

I am currently working on a study in which we estimate the relationship between a country-level variable (variable 'SSI1Z') and the association between an individual-level independent variable ('edu_lvl') and dependent variable ('political_interestZ'). We want to analyze the relationships on both the mean of our dependent variable, as well as the variance around that mean. Moreover, we want to include a cross-level interaction term between the individual-level IV (coded in three categories) and the country-level IV. Therefore, we used a multilevel (on three levels: (1) individual, (2) country ('S003'), (3) wave ('wave')) location-scale analysis with the package 'brms' (using Stan) in R. We used the following code:

model <- bf(political_interestZ ~ as.factor(edu_lvl) + SSI1Z + as.factor(edu_lvl):SSI1Z + (1|wave) + (1|S003) + (as.factor(edu_lvl) - 1|S003), sigma ~ as.factor(edu_lvl) + SSI1Z + as.factor(edu_lvl):SSI1Z + (1|wave) + (1|S003) + (as.factor(edu_lvl) - 1|S003))

modelout <- brm(model, data = Data, chains = 4, cores = 7, iter = 2500, control = list(adapt_delta = .99995, max_treedepth = 15), seed = 1234, save_all_pars = T)

This analysis ran for a long time (we included more control variables), but we got our results. However, for some time now I have been trying to calculate predicted values for this model, on both the location and the scale part. I would like to have an overview of the predicted values, as well as create a graphic presentation of the cross-level interaction effect for both the mean (Graph 1 -> x-axis: SSI1Z, y-axis: predicted means for political_interestZ, with edu_lvl as linetype) and the variance (Graph 2 -> x-axis: SSI1Z, y-axis: predicted sigmas for political_interestZ, with edu_lvl as linetype).

I tried to use the package ggeffects, but it seems that I'm not able to generate predicted values for both the location and the scale side with this package. Does anyone have any suggestions on how to do this?

Many thanks in advance.

PS: I haven't included the dataset, as it is very large, but I can upload some data if necessary.

  • Is there a reason why the generic `predict` function doesn't give you what you need? – Melissa Key Jun 09 '23 at 16:29
  • I don't think it provides you with the predicted values for all the categories of your individual-level variable? I.e., it does not give you the values for the reference category of a categorical variable, or am I wrong? – Leandros Kavadias Jun 12 '23 at 07:22

0 Answers0