Closed dfrankow closed 3 years ago
Here is a workaround, but it feels weird.
> model$call$data <- the_df
> margins(model)
Average marginal effects
lm(formula = y ~ x, data = structure(list(x = c(1, 2, 3), y = c(5, 9, 10)), class = "data.frame", row.names = c(NA, -3L)))
x
2.5
Alternatively, you can set the data
argument to margins()
explicitly.
I have:
I don't know how to get margins for an
lm
model built inside a function, because model$call$data goes out of scope, so find_data cannot find the data. I believe the relevant prediction code is here.Suggestions?
My code: