first.diff.fitted

Computes the first difference in fitted values, or a series of first differences, from an estimated regression model. Inference in supported via the delta method or bootstrapping.

For example:

library(catregs)
data("Mize19AH")
m1 <- glm(alcB ~woman*parrole + age + race2 + race3 + race4 + income + ed1 + ed2 + ed3 + ed4,family="binomial",data=Mize19AH)
des2<-margins.des(m1,expand.grid(woman=c(0,1),parrole=c(0,1)))
des2
##   woman parrole      age     race2       race3      race4   income       ed1
## 1     0       0 28.41653 0.2189459 0.005804504 0.02995124 34.50605 0.1811005
## 2     1       0 28.41653 0.2189459 0.005804504 0.02995124 34.50605 0.1811005
## 3     0       1 28.41653 0.2189459 0.005804504 0.02995124 34.50605 0.1811005
## 4     1       1 28.41653 0.2189459 0.005804504 0.02995124 34.50605 0.1811005
##         ed2       ed3        ed4
## 1 0.4100302 0.2542373 0.09774785
## 2 0.4100302 0.2542373 0.09774785
## 3 0.4100302 0.2542373 0.09774785
## 4 0.4100302 0.2542373 0.09774785
first.diff.fitted(m1,des2,compare=c(4,2)) # Pr(Drink | Mothers) - Pr(Drink | Childless Women)
##   First Difference Standard Error Statistic p-value     ll     ul
## 1           -0.168          0.022    -7.814       0 -0.211 -0.126
first.diff.fitted(m1,des2,compare=c(3,1)) # Pr(Drink | Fathers) - Pr(Drink | Childless Men)
##   First Difference Standard Error Statistic p-value     ll    ul
## 1           -0.106          0.024    -4.476       0 -0.153 -0.06