0

R for Beginners: Modeling Regression Effects Using REffects Library

Regression is a very popular statistical technique. In this post, I’ll show you how to plot regression effects using the R ‘effects’ library (https://cran.r-project.org/web/packages/effects/effects.pdf). This library provides a set of easy-to-write commands to visualize the effects of each variable in your regression model. The visualizations provide easy-to-understand plots that are very helpful when you interpret your model.

Here’s a simple R script for a logistic regression model plotted using the R effects library.

##############################################################################

logit1 <- glm(Hashtag ~ COMSTRS+COMCOP+ADVSS+BOUND+IDENT+GRPCOM+INFODIS, data = data, family = “binomial”)
summary(logit1)

library(effects)
plot(allEffects(logit1))
#########################################################

Here’re the results:

Call:
glm(formula = Hashtag ~ COMSTRS + COMCOP + ADVSS + BOUND + IDENT +
GRPCOM + INFODIS, family = “binomial”, data = data)

Deviance Residuals:
Min 1Q Median 3Q Max
-1.5409 -1.3369 0.8532 1.0259 2.1899

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.0149 0.5323 -3.785 0.000153 ***
COMSTRS 2.3823 0.5386 4.423 9.73e-06 ***
COMCOP 2.8381 0.6027 4.709 2.49e-06 ***
ADVSS 2.6210 0.7355 3.564 0.000366 ***
BOUND 0.3499 0.6732 0.520 0.603244
IDENT -0.2877 0.7094 -0.406 0.685086
GRPCOM 1.0341 0.8612 1.201 0.229852
INFODIS 1.4351 0.5823 2.465 0.013716 *

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 1260.0 on 908 degrees of freedom
Residual deviance: 1132.8 on 901 degrees of freedom
AIC: 1148.8

Number of Fisher Scoring iterations: 4

 
Chamil Rathnayake

Traversing Bits

Leave a Reply

Your email address will not be published. Required fields are marked *