R: Functions for Estimating Interaction Effects in Logit and...
intEff
R Documentation
Functions for Estimating Interaction Effects in Logit and Probit Models
Description
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.
Usage
intEff(obj, vars, data)
Arguments
obj
A binary logit or probit model estimated with glm.
vars
A vector of the two variables involved in the interaction.
data
A data frame used in the call to obj.
Value
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 int_eff.
zstat
The interaction effect divided by its standard error
Author(s)
Dave Armstrong (UW-Milwaukee, Department of Political Science)
References
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. http://www.stata-journal.com/software/sj4-3/.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(DAMisc)
Loading required package: car
Loading required package: effects
Attaching package: 'effects'
The following object is masked from 'package:car':
Prestige
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DAMisc/intEff.Rd_%03d_medium.png", width=480, height=480)
> ### Name: intEff
> ### Title: Functions for Estimating Interaction Effects in Logit and Probit
> ### Models
> ### Aliases: intEff
>
> ### ** Examples
>
> data(france)
> mod <- glm(voteleft ~ age*lrself + retnat + male, data=france, family=binomial)
> out <- intEff(obj=mod, vars=c("age", "lrself"), data=france)
> 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)
>
>
>
>
>
> dev.off()
null device
1
>