Skip to content

Instantly share code, notes, and snippets.

@vikjam
Created November 27, 2019 04:43
Show Gist options
  • Save vikjam/1fecb8db81e19a15a0d9d43c077807a0 to your computer and use it in GitHub Desktop.
Save vikjam/1fecb8db81e19a15a0d9d43c077807a0 to your computer and use it in GitHub Desktop.
Marginal means
* Marginal means in Stata
* https://www.stata.com/features/overview/marginal-analysis/
* Probit
webuse nlsw88, clear
quietly probit union wage c.age c.age#c.age collgrad
margins, dydx(age)
library(haven)
library(margins)
# Marginal means in R
# https://cran.r-project.org/web/packages/margins/vignettes/Introduction.html
# Probit
nlsw88 <- read_dta("http://www.stata-press.com/data/r8/nlsw88.dta")
glm_model <- glm(union ~ wage + age + I(age^2) + collgrad, data = nlsw88, family = binomial(link = "probit"))
summary(margins(glm_model, variables = "age"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment