intEff | R Documentation |
Norton and Ai (2003) and Norton, Wang and Ai (2004) discuss methods for calculating the appropriate marginal effects for interactions in binary logit/probit models. These functions are direct translations of the Norton, Wang and Ai (2004) Stata code.
intEff(obj, vars, data)
obj |
A binary logit or probit model estimated with |
vars |
A vector of the two variables involved in the interaction. |
data |
A data frame used in the call to |
A list is returned with two elements - byobs
and
atment
. The byobs
result gives the interaction effect
evaluated at each observation. The atmean
element has the marginal
effect evaluated at the mean. Each eleement contains an element int
which is a data frame with the following variable:
int_eff |
The correctly calucalted marginal effect. |
linear |
The incorrectly calculated marginal effect following the linear model analogy. |
phat |
Predicted Pr(Y=1|X). |
se_int_eff |
Standard error of
|
zstat |
The interaction effect divided by its standard error |
The X
element of each returned result is the X-matrix used to
generate the result.
Dave Armstrong
Norton, Edward C., Hua Wang and Chunrong Ai. 2004. Computing
Interaction Effects and Standard Errors in Logit and Probit Models. The
Stata Journal 4(2): 154-167.
Ai, Chunrong and Edward C. Norton. 2003. Interaction Terms in Logit and Probit Models. Economics Letters 80(1): 123-129.
Norton, Edward C., Hua Wang and Chunrong Ai. 2004. inteff: Computing Interaction Effects and Standard Errors in Logit and Probit Models, Stata Code.
data(france)
mod <- glm(voteleft ~ age*lrself + retnat + male, data=france, family=binomial)
out <- intEff(obj=mod, vars=c("age", "lrself"), data=france)
out <- out$byobs$int
plot(out$phat, out$int_eff, xlab="Predicted Pr(Y=1|X)",
ylab = "Interaction Effect")
ag <- aggregate(out$linear, list(out$phat), mean)
lines(ag[,1], ag[,2], lty=2, col="red", lwd=2)
legend("topright", c("Correct Marginal Effect", "Linear Marginal Effect"),
pch=c(1, NA), lty=c(NA, 2), col=c("black", "red"), lwd=c(NA, 2), inset=.01)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.