@@ -12,7 +12,7 @@ model_parameters.marginaleffects <- function(model,
1212 insight :: check_if_installed(" marginaleffects" )
1313
1414 # Bayesian models have posterior draws as attribute
15- is_bayesian <- ! is.null(suppressWarnings (marginaleffects :: get_draws(model , " PxD" )))
15+ is_bayesian <- suppressWarnings( ! is.null(marginaleffects :: get_draws(model , " PxD" )))
1616
1717 if (is_bayesian ) {
1818 # Bayesian
@@ -48,9 +48,7 @@ model_parameters.marginaleffects <- function(model,
4848 # do not print or report these columns
4949 out <- out [, ! colnames(out ) %in% c(" predicted_lo" , " predicted_hi" ), drop = FALSE ]
5050
51- if (inherits(model , " marginalmeans" )) {
52- attr(out , " coefficient_name" ) <- " Marginal Means"
53- } else if (inherits(model , " comparisons" )) {
51+ if (inherits(model , " comparisons" )) {
5452 attr(out , " coefficient_name" ) <- " Estimate"
5553 attr(out , " title" ) <- " Contrasts between Adjusted Predictions"
5654 if (" Type" %in% colnames(out )) {
@@ -137,10 +135,11 @@ model_parameters.predictions <- function(model,
137135 out $ rowid <- out $ Type <- out $ rowid_dedup <- NULL
138136
139137 # find at-variables
140- at_variables <- attributes(model )$ newdata_at
141- if (is.null(at_variables )) {
142- at_variables <- attributes(model )$ by
143- }
138+ at_variables <- c(
139+ marginaleffects :: components(model , " variable_names_datagrid" ),
140+ marginaleffects :: components(model , " variable_names_by" ),
141+ marginaleffects :: components(model , " variable_names_by_hypothesis" )
142+ )
144143
145144 # find cofficient name - differs for Bayesian models
146145 coef_name <- intersect(c(" Predicted" , " Coefficient" ), colnames(out ))[1 ]
@@ -153,7 +152,7 @@ model_parameters.predictions <- function(model,
153152 }
154153
155154 # extract response, remove from data frame
156- reg_model <- attributes (model ) $ model
155+ reg_model <- marginaleffects :: components (model , " model" )
157156 if (! is.null(reg_model ) && insight :: is_model(reg_model )) {
158157 resp <- insight :: find_response(reg_model )
159158 # check if response could be extracted
0 commit comments