3

I want to report the marginal effects in the place of the usual estimated effects, using stargazer()

When the marginal effects are estimated, the results are turned into a vector, which I couldn't report in a pratical way and with the same kind of informations I would be able to, if it was a glm/lm object.

Here's a simple example:

library(dplyr)
library(stargazer)

#we create a toy data frame
pikachu <- data.frame(
employed=c(0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0,1,1,1,0,1,0,1,0),
                      highiq=c(1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,1,0,0,0,1,0),
                      income=set.seed(6)%>%
                        c(rnorm(25,mean = 600,sd=400)))

#and run a probit regression
reg01 <- glm(employed ~ income + highiq,
             family = binomial(link="probit"),
             data = pikachu)

#next we estimate the marginal effects
ProbitScalar <- mean(dnorm(predict(reg01, type = "link")))
meffects <- ProbitScalar * coef(reg01)

#then we report the marg. effects
stargazer(meffects, type = "text")

I expected to be able to represent the marginal effects just like the usual results (glm class object) can be represented. Preferably with SE and significance included.

#desired result's form:
stargazer(reg01, type = "text")
Flower
  • 43
  • 5

1 Answers1

0

As far as I know, this is not possible with stargazer(), but it is very easy to achieve with the modelsummary and marginaleffects packages (disclaimer: I am the author):

library(marginaleffects)
library(modelsummary)

set.seed(6)
pikachu <- data.frame(
    employed = c(0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0),
    highiq = c(1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0),
    income = c(rnorm(25, mean = 600, sd = 400)))

reg01 <- glm(employed ~ income + highiq,
             family = binomial(link="probit"),
             data = pikachu)

mfx <- marginaleffects(reg01)

modelsummary(mfx)
Model 1
highiq 0.130
(0.197)
income 0.000
(0.000)
Num.Obs. 25
AIC 38.3
BIC 42.0
Log.Lik. -16.167
F 0.943
RMSE 1.21
Vincent
  • 15,809
  • 7
  • 37
  • 39