Load the Libraries + Functions

Load all the libraries or functions that you will use to for the rest of the assignment. It is helpful to define your libraries and functions at the top of a report, so that others can know what they need for the report to compile correctly.

The data for this project has already been loaded. Here you will be distinguishing between the uses for let, allow, and permit. You should pick two of these verbs to examine and subset the dataset for only those columns. You can use the droplevels() function to help drop the empty level after you subset.

library(Rling)
library(car)
## Loading required package: carData
library(base64enc)
library(rms)
## Loading required package: Hmisc
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## Loading required package: SparseM
## 
## Attaching package: 'SparseM'
## The following object is masked from 'package:base':
## 
##     backsolve
## 
## Attaching package: 'rms'
## The following objects are masked from 'package:car':
## 
##     Predict, vif
library(visreg)
library(VIF)
## 
## Attaching package: 'VIF'
## The following object is masked from 'package:rms':
## 
##     vif
## The following object is masked from 'package:car':
## 
##     vif
data(let)
head(let)
##   Year  Reg   Verb Neg Permitter Imper
## 1 2003  MAG  allow  No    Inanim    No
## 2 2005 SPOK  allow  No    Inanim    No
## 3 1990 SPOK    let  No      Anim    No
## 4 2007 SPOK  allow  No    Inanim    No
## 5 1997  MAG permit  No      Anim   Yes
## 6 1996  MAG  allow  No      Anim    No

Description of the Data

The data is from the COCA: Corpus of Contemporary American English investigating the verb choice of let, allow, and permit. These are permissive constructions that are often paired with the word to. Predict the verb choice in the Verb column with the following independent variables:

Sample Size Requirements

table(droplevels(let)$Verb)
## 
##    let  allow permit 
##    187    167    164

Running a Binary Logistic Regression

model = lrm(Verb ~ Reg + Permitter+ Imper,
            data = let)
model
## Logistic Regression Model
##  
##  lrm(formula = Verb ~ Reg + Permitter + Imper, data = let)
##  
##                        Model Likelihood     Discrimination    Rank Discrim.    
##                           Ratio Test           Indexes           Indexes       
##  Obs           518    LR chi2     248.15    R2       0.428    C       0.759    
##   let          187    d.f.             4    g        1.730    Dxy     0.518    
##   allow        167    Pr(> chi2) <0.0001    gr       5.643    gamma   0.596    
##   permit       164                          gp       0.302    tau-a   0.346    
##  max |deriv| 9e-08                          Brier    0.124                     
##  
##                   Coef    S.E.   Wald Z Pr(>|Z|)
##  y>=allow          0.7679 0.1768  4.34  <0.0001 
##  y>=permit        -1.1173 0.1834 -6.09  <0.0001 
##  Reg=SPOK          0.0076 0.1893  0.04  0.9681  
##  Permitter=Inanim  1.1607 0.2023  5.74  <0.0001 
##  Permitter=Undef   1.1276 0.3702  3.05  0.0023  
##  Imper=Yes        -3.4539 0.4223 -8.18  <0.0001 
## 

Coefficients

Interactions

model1 = glm(Verb ~ Reg + Permitter + Imper,
             family = binomial,
             data = let)
model2 = glm(Verb ~ Permitter + Imper*Reg,
             family = binomial,
             data = let)
anova(model1, model2, test = "Chisq")
## Analysis of Deviance Table
## 
## Model 1: Verb ~ Reg + Permitter + Imper
## Model 2: Verb ~ Permitter + Imper * Reg
##   Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
## 1       513     393.38                          
## 2       512     379.40  1   13.973 0.0001855 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Outliers

influencePlot(model2)

##        StudRes         Hat       CookD
## 18  -0.7017301 0.035714286 0.001745854
## 36   3.1365078 0.012048193 0.168699187
## 45  -2.4917395 0.006173684 0.020789048
## 59   1.7935140 0.035714286 0.023472032
## 119 -2.0556891 0.033974915 0.038790368

Assumptions

rms::vif(model)
##         Reg=SPOK Permitter=Inanim  Permitter=Undef        Imper=Yes 
##         1.049413         1.155355         1.114566         1.062978