What is the simplest way to calculate average marginal effect, marginal effect at the mean and marginal effect at representative values for a logit model?
I found this example, but the explanation is messy and frankly I don't understand it: https://cran.r-project.org/web/packages/margins/vignettes/Introduction.html
I am using a STATA dataset ANES.dta with information from the 2000 presidential election in the USA. This is what the content of the dataset looks like:
dat <- structure(list(age = c(49, 63, 40, 47, 26, 48, 41, 18, 31, 22
), gender = c(1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L), race = c(1L, 
1L, 1L, 1L, 2L, 1L, 1L, 1L, 5L, 1L), education = c(3L, 3L, 3L, 
4L, 4L, 2L, 2L, 2L, 3L, 3L), income = c(4L, 3L, 3L, 3L, 4L, 3L, 
3L, 3L, 4L, 3L), attendance = c(2L, 5L, 5L, 5L, 4L, 5L, 4L, 1L, 
0L, 3L), lib_con = c(59, 49, 94, 24, 29, 19, 39, 49, 79, 49), 
pro_choice = c(2L, 4L, 3L, 4L, 4L, 2L, 4L, 1L, 1L, 4L), vote = c(1, 
0, 1, 0, 0, 0, 0, 1, 1, 0), black = c(0, 0, 0, 0, 1, 0, 0, 
0, 0, 0)),row.names = c(NA, -10L), class = c("data.frame"))
Here is the head of the dataset:
age gender race education income attendance lib_con pro_choice vote black
1   49      1    1         3      4          2      59          2    1     0
4   63      1    1         3      3          5      49          4    0     0
5   40      2    1         3      3          5      94          3    1     0
8   47      2    1         4      3          5      24          4    0     0
9   26      2    2         4      4          4      29          4    0     1
10  48      2    1         2      3          5      19          2    0     0 
And here is the code for my model:
rm(list=ls())
library(foreign)
dat <- read.dta("ANES.dta", convert.factors = FALSE)
dat_clear <- na.omit(dat)
head(dat_clear)
m1_logit <- glm(vote ~ gender + income + pro_choice ,
                data = dat_clear, family = binomial(link = "logit") , 
                na.action = na.omit)
summary(m1_logit)
 
    