DAintfun2(obj, varnames, rug=TRUE, ticksize=-.03, hist=FALSE, hist.col="gray75",
nclass=c(10, 10), scale.hist=.5, border=NA, name.stem = "cond_eff",
xlab = NULL, ylab = NULL, plot.type = "screen")
lm
polygon
indicating the color of the histogram bins.hist
.polygon
indicating how the border of the histogram bins should be printed (NA
for no border).varnames
given the second and the secovarnames
given the second and the seconame.stem
written to the appropriate file type and the third will produpar(mfrow=c(1,2))
) or two figures starting with name.stem
are produced where each gives the conditional effect of one variable based on the values of another.effects
package, upon which this function depends heavily.
Specifically, if the model is
$$y_{i} = b_{0} + b_{1}x_{i1} + b_{2}x_{i2} + b_{3}x_{i1}\times x_{i2} + \ldots + e_{i},$$
this function plots calculates the conditional effect of $X_{1}$ given $X_{2}$
$$\frac{\partial y}{\partial X_{1}} = b_{1} + b_{3}X_{2}$$
and the variances of the conditional effects
$$V(b_{1} + b_{3}X_{2}) = V(b_{1} + X_{2}^{2}V(b_{3}) + 2(1)(X_{2})V(b_{1},b_{3}))$$
for different values of $X_{2}$ and then switches the places of $X_{1}$ and $X_{2}$, calculating the conditional effect of $X_{2}$ given a range of values of $X_{1}$. 95% confidence bounds are then calculated and plotted for each conditional effects along with a horizontal reference line at 0.data(InteractionEx)
mod <- lm(y ~ x1*x2 + z, data=InteractionEx)
DAintfun2(mod, c("x1", "x2"), hist=TRUE, scale.hist=.3)
Run the code above in your browser using DataLab