second.diff.fitted

Computes the second difference in fitted values 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
second.diff.fitted(m1,des2,compare=c(4,2,3,1),rounded=5) # [Pr(Drink | Mothers) - Pr(Drink | Childless Women)] - [Pr(Drink | Fathers) - Pr(Drink | Childless Men)]
##   Second Difference Standard Error Statistic p-value       ll       ul
## 1           -0.0622        0.03166  -1.96428  0.0495 -0.12425 -0.00014
# Note that this is reported as the "Second Difference" in Table 3 of Mize (2019: 104, "Best Practices for Estimating, Interpreting, and Presenting Nonlinear Interaction Effect. Sociological Science. 6(4): 81-117.")