To compute the average marginal effect of X1 on the response scale:
avg_slopes(fit, variables="X1")
shape: (1, 3)
term
contrast
estimate
str
str
f64
"X1"
"dY/dX"
-1.016344
You can also report group-specific average marginal effects:
avg_slopes(fit, variables="X1", by="f1")
shape: (30, 4)
f1
term
contrast
estimate
f64
str
str
f64
0.0
"X1"
"dY/dX"
-1.016344
1.0
"X1"
"dY/dX"
-1.016344
2.0
"X1"
"dY/dX"
-1.016344
3.0
"X1"
"dY/dX"
-1.016344
4.0
"X1"
"dY/dX"
-1.016344
…
…
…
…
25.0
"X1"
"dY/dX"
-1.016344
26.0
"X1"
"dY/dX"
-1.016344
27.0
"X1"
"dY/dX"
-1.016344
28.0
"X1"
"dY/dX"
-1.016344
29.0
"X1"
"dY/dX"
-1.016344
Linear hypothesis tests
Suppose we want to test the linear restriction \(X_1 = X_2\). The hypotheses() function uses the model’s estimated covariance matrix, so it works naturally with PyFixest objects.
hypotheses(fit, "X1 - X2 = 0")
shape: (1, 8)
term
estimate
std_error
statistic
p_value
s_value
conf_low
conf_high
str
f64
f64
f64
f64
f64
f64
f64
"X1-X2=0"
-0.850445
0.1086
-7.830952
4.8850e-15
47.540568
-1.063297
-0.637592
Non-linear hypothesis tests
For non-linear transformations, marginaleffects applies the delta method automatically. This is useful for ratio-style summaries or uplift calculations.