Created
November 27, 2019 04:43
-
-
Save vikjam/1fecb8db81e19a15a0d9d43c077807a0 to your computer and use it in GitHub Desktop.
Marginal means
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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