5 modeldf()

The function modeldf() has similar features to tidying model objects with additions. The margin of error (moe) and confidence interval columns (ci\_\) would inform those in the health sciences the impact range of their variables of interest–other discplines may benefit as well from these estimates. The variance inflation factors (VIF)–which are estimated with vif() from car–measure the extent of collinearity in linear models.

5.1 Case 1: OLS

model.lm <- lm(data    = mtcars, 
               formula = mpg ~ disp + hp + wt + gear + am)

modeldf(model = model.lm, conf = 0.90) 
##          term         coef         se        moe    ci_lower    ci_upper
## 1 (Intercept) 32.108024910 4.84359733 8.26132640 23.84669851 40.36935131
## 2          am  1.605381694 1.78234460 3.03999888 -1.43461719  4.64538058
## 3        disp  0.005352328 0.01178752 0.02010500 -0.01475267  0.02545733
## 4        gear  0.651585626 1.21191542 2.06706466 -1.41547904  2.71865029
## 5          hp -0.042892355 0.01424230 0.02429192 -0.06718428 -0.01860043
## 6          wt -3.113042246 1.17912588 2.01113824 -5.12418048 -1.10190401
##            t            p      vif
## 1  6.6289625 4.959127e-07       NA
## 2  0.9007134 3.760085e-01 3.583076
## 3  0.4540675 6.535481e-01 9.668205
## 4  0.5376494 5.953915e-01 3.621713
## 5 -3.0116168 5.721679e-03 4.319422
## 6 -2.6401271 1.382770e-02 6.029643
# conf = 0.95 is the default value; can be omitted.

5.2 Case 2: GLM (logit)

model.glm <- glm(data   = mtcars, formula = am ~ mpg + disp + hp, 
                 family = binomial(link = 'logit'))

modeldf(model = model.glm, conf = 0.85) 
##          term        coef          se        moe     ci_lower    ci_upper
## 1 (Intercept) -33.8128314 24.17533401 24.5646824 -84.33645885 -9.24814900
## 2        disp  -0.0654460  0.04304626  0.0434281  -0.15279531 -0.02201789
## 3          hp   0.1493636  0.07871156  0.1696229   0.06680399  0.31898646
## 4         mpg   1.2849763  0.89894752  1.8600069   0.37394599  3.14498315
##           z          p       vif
## 1 -1.398650 0.16191796        NA
## 2 -1.520364 0.12841942 15.021316
## 3  1.897607 0.05774791 23.014959
## 4  1.429423 0.15288269  8.822745
# conf = 0.95 is the default value; can be omitted.

5.3 Case 3: NLS

model.nls <- nls(Ozone ~ theta0 + Temp^theta1, airquality)

modeldf(model = model.nls, conf = 0.80) 
##   parameter        coef         se         moe    ci_lower    ci_upper
## 1    theta0 -121.608226 13.2364581 17.24120193 -138.579289 -104.367024
## 2    theta1    1.170315  0.0182639  0.02228835    1.145183    1.192604
##           t            p
## 1 -9.187369 2.167395e-15
## 2 64.078073 3.014033e-91
# conf = 0.95 is the default value; can be omitted.