0
votes

I'm running a probit regression in R. The model mixes some continuous and categorical variables (encoded as factors). I want to compute marginal effects of each variable. To do so I use the command margins from margins package, this command returns AME and recognizes the factors and displays the marginal effects for each level of them. Therefore how are the categorical variables treated when computing marginal effects? If continuous variables are held at their mean value (by default), how are those categorical variables fixed?

I hope the question is clear enough, it's more a theoretical issue.

1
Please provide a small reproducable example in order to make answering your question easier. You can read more about this here. For your specific question, talking about marginal effects of factors in any model should be according to their base level. If interactions are present, one should be careful about how marginal effects are interpreted, as these are dependant on the values of other variables.Oliver
@Oliver You can find a reproducable example below. Thanks in anticipationJérémie P.

1 Answers

0
votes

Here is a reproducable example as suggested by Olivier.

library(stats)
library(margins)

# Generate Data
set.seed(1234)
# Continuous
y<-rnorm(1000)
x1<-4*runif(1000)
x2<-2*rnorm(1000)
# Categorical
c1<-as.factor(ifelse(x1<=0.9,"A",
                 ifelse(x1>0.9 & x1<=2.4,"B",
                        ifelse(x1>2.4 & x1<=3.5,"C","D"))))
c2<-as.factor(ifelse(x2>2,"Y","N"))
table(c1)
> c1
> A   B   C   D 
> 201 397 268 134

table(c2)
> c2
> N   Y 
> 825 175

# Dummy dependent variable
y<-ifelse(y>0,1,0)
table(y)
> y
> 0   1 
> 517 483

probit<-glm(y ~ x1 + x2 + c1 + c2,family=binomial(link="probit"))

# AME
margins<-summary(margins(probit))
margins[,c(1,2)]
> factor     AME
>    c1B  0.0068
>    c1C  0.0620
>    c1D  0.0800
>    c2Y -0.0176
>     x1 -0.0371
>     x2  0.0037

# COMPUTE PARTIAL DENSITY FUNCTION               
pdf<-mean(dnorm(predict(probit)))

# Compute Manually AME of x1 (Continous Variable)
round(pdf*coef(probit)[2],4) # This is the same AME returned by the margins command ! 
 > x1 
 > -0.0371

#  1. Compute Manually AME of C1 and C2 for each level (Categorical Variable) using  pdf
round(pdf*coef(probit)[4],4) # AME_C1 Level B
> c1B 
> 0.0069 

round(pdf*coef(probit)[5],4) # AME_C1 Level C
> c1C 
> 0.0623 

round(pdf*coef(probit)[6],4) # AME_C1 Level D
> c1D 
> 0.0804 

# They all are slightly different to those returned my margins command

round(pdf*coef(probit)[7],4) # AME_C2 (dummy)
> c2Y 
> -0.0176 

Therefore my question is : " Does margins command computes marginal effects by using a discrete change for dummy and categorical data ?"

In theory, If the variable Xj is continous, the marginal probability effect is : [https://i.stack.imgur.com/OtEEx.jpg]

However if Xj is a dummy :

[https://i.stack.imgur.com/XMwrx.jpg]