
Marginal slopes (partial derivatives) via marginaleffects
Source:R/effects.R
morie_effects_slopes.RdThin extender over marginaleffects::slopes() for continuous
marginal effects (Stata-style margins, dydx()).
Arguments
- model
A fitted model object.
- variables
Character vector of focal variables. When
NULL, the marginaleffects default (all continuous predictors) is used.- ...
Further arguments forwarded to
marginaleffects::slopes().
Examples
if (requireNamespace("marginaleffects", quietly = TRUE)) {
set.seed(1)
df <- data.frame(y = rnorm(60), x = rnorm(60), g = factor(rep(c("a", "b"), 30)))
fit <- stats::lm(y ~ x + g, data = df)
head(morie_effects_slopes(fit, variables = "x"))
}
#>
#> Estimate Std. Error z Pr(>|z|) S 2.5 % 97.5 %
#> -0.0353 0.122 -0.288 0.773 0.4 -0.275 0.205
#> -0.0353 0.122 -0.288 0.773 0.4 -0.275 0.204
#> -0.0353 0.122 -0.289 0.773 0.4 -0.275 0.204
#> -0.0353 0.122 -0.288 0.773 0.4 -0.275 0.204
#> -0.0353 0.122 -0.289 0.773 0.4 -0.275 0.204
#> -0.0353 0.122 -0.288 0.773 0.4 -0.275 0.204
#>
#> Term: x
#> Type: response
#> Comparison: dY/dX
#>