@@ -109,9 +109,9 @@ model_parameters.predictions <- function(model,
109109 insight :: check_if_installed(" marginaleffects" )
110110
111111 # Bayesian models have posterior draws as attribute
112- is_bayes <- ! is.null(suppressWarnings(marginaleffects :: get_draws(model , " PxD" )))
112+ is_bayesian <- ! is.null(suppressWarnings(marginaleffects :: get_draws(model , " PxD" )))
113113
114- if (is_bayes ) {
114+ if (is_bayesian ) {
115115 # Bayesian
116116 out <- suppressWarnings(bayestestR :: describe_posterior(
117117 model ,
@@ -137,10 +137,11 @@ model_parameters.predictions <- function(model,
137137 out $ rowid <- out $ Type <- out $ rowid_dedup <- NULL
138138
139139 # find at-variables
140- at_variables <- attributes(model )$ newdata_at
141- if (is.null(at_variables )) {
142- at_variables <- attributes(model )$ by
143- }
140+ at_variables <- c(
141+ marginaleffects :: components(model , " variable_names_datagrid" ),
142+ marginaleffects :: components(model , " variable_names_by" ),
143+ marginaleffects :: components(model , " variable_names_by_hypothesis" )
144+ )
144145
145146 # find cofficient name - differs for Bayesian models
146147 coef_name <- intersect(c(" Predicted" , " Coefficient" ), colnames(out ))[1 ]
@@ -153,7 +154,7 @@ model_parameters.predictions <- function(model,
153154 }
154155
155156 # extract response, remove from data frame
156- reg_model <- attributes (model ) $ model
157+ reg_model <- marginaleffects :: components (model , " model" )
157158 if (! is.null(reg_model ) && insight :: is_model(reg_model )) {
158159 resp <- insight :: find_response(reg_model )
159160 # check if response could be extracted
0 commit comments