I am trying to compute probit regression that includes interaction terms. When I compute marginal effects after the main coefficients R gives me marginal effects for interaction terms and Stata doesn't. It says that Stata doesn't compute marginal effects for interaction terms because logically it's not possible. But then how does R compute them? and if it oes are they correct ?

I tried both Stata and R for the analysis and I am confused.

  • 7
    $\begingroup$ Can you add a toy example or R + Stata code with the output? $\endgroup$
    – dimitriy
    Nov 21, 2022 at 1:48
  • 2
    $\begingroup$ Please give a precise definition of marginal effect in this context. To me marginalization is unconditioning and I don't know why you would uncondition on anything while looking at something as highly conditional as an interaction effect. $\endgroup$ Nov 22, 2022 at 12:41
  • $\begingroup$ R calculates them in the same way that they would for a term not involved in an interaction b*dnorm(xb), but as Stata suggests, they are meaningless. You cannot change the interaction while holding constant the constitutive terms. $\endgroup$ Dec 16, 2022 at 0:50

1 Answer 1


Here is an example where I compute the same average marginal effects using R and Stata. The margin's vignette is also useful to explain marginal effects with interaction terms using R: https://cran.r-project.org/web/packages/margins/vignettes/Introduction.html

In Stata, the margins command can be used to compute marginal effects for interaction terms.

use "https://dss.princeton.edu/training/students.dta", clear

* Create the Math dummy variable
gen math= major=="Math"
encode gender, gen(sex)

probit math c.age##i.sex

* Compute marginal effects for interaction term
margins, dydx(*)
  Average marginal effects
  Number of   obs     =         30 Model VCE    : OIM
  Expression   : Pr(math), predict() dy/dx w.r.t. : age 2.sex

  Delta-method dy/dx   Std. Err.      z   P>z [95% Conf. Interval]        
  age   -.0087594   .0124467    -0.70 0.482   .0331544    .0156356
  sex  Male     -.361844   .1711841    -2.11  0.035   .6973588   -.0263293
  Note: dy/dx for factor levels is the discrete   change from the base level.

In R, the margins package can be used to compute marginal effects for interaction terms.


mydata <-  read.dta("http://dss.princeton.edu/training/students.dta")

# Create the Math dummy variable
mydata$math <- ifelse(mydata$major == "Math", 1, 0)

model <- glm(math ~ age + gender + age:gender, data = mydata, 
             family = binomial(link = "probit"))

# Compute marginal effects for interaction term
m <- margins(model)
 factor     AME     SE       z      p   lower   upper
 age -0.0088 0.0123 -0.7112 0.4770 -0.0329  0.0154  
 genderMale -0.3618 0.1716 -2.1084 0.0350 -0.6982 -0.0255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.