easystats/see

plot.parameters_simulate formatting VS parameters_model formatting

madebyafox opened this issue · 0 comments

Noticed today that the output plot for plot(simulate_parameters(model)) is not nicely formatted as is the simple model parameters plot, plot(model_parameters(model)).

A couple issues that emerge with a complex model (in this case, a hierarchical multinomial logistic regression)

plot is not faceted by response variable level, as is done automagically with plot(model_parameters)
show_intercept=F only removes the intercept for the first equation in the multinomial model, not the subsequent intercepts

REPREX

##MBLOGIT EXAMPLE

library(mclogit)
#> Loading required package: Matrix
library(easystats)
#> Warning: package 'easystats' was built under R version 4.2.3
#> # Attaching packages: easystats 0.6.0.8
#> ✔ bayestestR  0.13.0.10   ✔ correlation 0.8.3.3  
#> ✔ datawizard  0.7.0.5     ✔ effectsize  0.8.3.6  
#> ✔ insight     0.19.1.2    ✔ modelbased  0.8.6.3  
#> ✔ performance 0.10.2.7    ✔ parameters  0.20.2.14
#> ✔ report      0.5.7.1     ✔ see         0.7.5.1

#CREATE MIXED MULTINOMIAL LOGISTIC REGRESSION MODEL
pict  <- base::readRDS(url("https://slcladal.github.io/data/pict.rda", "rb"))
m1.mn <- mblogit(formula = Response ~ Gender + Group,
              random = ~ 1 | Item,
              data = pict)
#> 
#> Iteration 1 - deviance = 1667.891 - criterion = 0.8014916
#> Iteration 2 - deviance = 1576.67 - criterion = 0.08187338
#> Iteration 3 - deviance = 1550.621 - criterion = 0.03072031
#> Iteration 4 - deviance = 1541.316 - criterion = 0.009764653
#> Iteration 5 - deviance = 1537.509 - criterion = 0.002514804
#> Iteration 6 - deviance = 1536.103 - criterion = 0.000306996
#> Iteration 7 - deviance = 1535.722 - criterion = 4.709478e-05
#> Iteration 8 - deviance = 1535.593 - criterion = 7.320379e-06
#> Iteration 9 - deviance = 1535.547 - criterion = 1.195585e-06
#> Iteration 10 - deviance = 1535.529 - criterion = 1.993986e-07
#> Iteration 11 - deviance = 1535.522 - criterion = 3.342435e-08
#> Iteration 12 - deviance = 1535.519 - criterion = 5.601294e-09
#> converged

#PLOT MODEL COEFS
## nicely stacked by outcome variable level,  with sensical parameter names
mp <- model_parameters(m1.mn, exponentiate = T)
plot(mp, stack=F)

#PLOT SIMULATED PARAMETERS
## not faceted by outcome variable level
ms <-simulate_parameters(m1.mn) 
plot(ms, stack=F, show_intercept=T, normalize_height=T)

Created on 2023-03-27 with reprex v2.0.2