Skip to contents

Refit a marginaleffects object with new data

Usage

refit(object, ...)

# S3 method for class 'marginaleffects'
refit(object, data = NULL, newdata = NULL, vcov = NULL, ...)

# S3 method for class 'predictions'
refit(object, data = NULL, newdata = NULL, vcov = NULL, ...)

# S3 method for class 'comparisons'
refit(object, data = NULL, newdata = NULL, vcov = NULL, ...)

# S3 method for class 'slopes'
refit(object, data = NULL, newdata = NULL, vcov = NULL, ...)

# S3 method for class 'hypotheses'
refit(object, data = NULL, newdata = NULL, vcov = NULL, ...)

Arguments

object

A marginaleffects object (predictions, comparisons, or slopes)

...

Additional arguments passed to methods

data

Optional data frame to refit the underlying model

newdata

Optional data frame to re-evaluate the marginaleffects call

vcov

Optional logical or variance-covariance matrix specification to pass to the marginaleffects call

Value

A marginaleffects object

Details

If data is supplied, the underlying model is refitted using that data. If newdata is supplied, the marginaleffects call is re-evaluated with the new data. Both can be supplied together to refit the model and make predictions on new data.