Calculates the cross-derivative required to evaluate interactions in logistic/probit regression models.
secondDiff(
obj,
vars,
data,
method = c("AME", "MER"),
vals = NULL,
typical = NULL
)
An object of class glm
that will be used to find the
cross-derivative.
A vector of two variables to be used in calculating the derivative.
A data frame.
Indicate whether you want to use average marginal effects (AME) or marginal effects at representative values (MER).
A named list of length 2 where each element gives the minimum and maximum values used in the calculation.
A named vector of values at which to hold variables constant.
A list with two elements:
The average second difference in each iteration of the bootstrap.
If type == 'AME'
, ind
is returned with
the second difference and measures of uncertainty for each individual
observation in the original dataset
If type == 'MER'
,
probs
is returned with the full matrix of simulated predicted
probabilities for the four conditions.
The function calculates the second difference as (Pr(Y=1|x1=max, x2=max) - Pr(Y=1|x1=min, x2=max)) - (Pr(Y=1|x1=max, x2=min) - Pr(Y=1|x1=min, x2=min)). The function uses a parametric bootstrap to calculate the sampling distribution of the second difference.