library(rpart) #classification and regression trees
library(partykit) #treeplots
## Loading required package: grid
library(randomForest) #random forests
## randomForest 4.6-12
## Type rfNews() to see new features/changes/bug fixes.
library(gbm) #gradient boosting
## Loading required package: survival
## Loading required package: lattice
## Loading required package: splines
## Loading required package: parallel
## Loaded gbm 2.1.3
library(caret) #tune hyper-parameters
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:randomForest':
##
## margin
##
## Attaching package: 'caret'
## The following object is masked from 'package:survival':
##
## cluster
require(ggplot2)
library(nnet)
library(NeuralNetTools)
library(mlbench)
data(PimaIndiansDiabetes)
dim(PimaIndiansDiabetes)
## [1] 768 9
set.seed(123)
ind = sample(2, nrow(PimaIndiansDiabetes), replace=TRUE, prob=c(0.7,0.3))
train = PimaIndiansDiabetes[ind==1,]
test = PimaIndiansDiabetes[ind==2,]
str(train)
## 'data.frame': 539 obs. of 9 variables:
## $ pregnant: num 6 8 5 3 2 8 10 10 1 5 ...
## $ glucose : num 148 183 116 78 197 125 168 139 189 166 ...
## $ pressure: num 72 64 74 50 70 96 74 80 60 72 ...
## $ triceps : num 35 0 0 32 45 0 0 0 23 19 ...
## $ insulin : num 0 0 0 88 543 0 0 0 846 175 ...
## $ mass : num 33.6 23.3 25.6 31 30.5 0 38 27.1 30.1 25.8 ...
## $ pedigree: num 0.627 0.672 0.201 0.248 0.158 ...
## $ age : num 50 32 30 26 53 54 34 57 59 51 ...
## $ diabetes: Factor w/ 2 levels "neg","pos": 2 2 1 2 2 2 2 1 2 2 ...
control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_glm <- train(train[,1:8], train[,9],
method = "glm",
preProc = c("center", "scale"),
trControl = control)
# Predict using the test data
pred<-predict(my_glm,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, plot variable importance
print(varImp(my_glm, scale = FALSE))
## glm variable importance
##
## Overall
## glucose 7.9215
## mass 5.0108
## pedigree 2.3031
## pregnant 2.2838
## age 2.0050
## pressure 1.9604
## insulin 1.3429
## triceps 0.1872
plot(varImp(my_glm, scale = FALSE), main="Variable Importance using GLM")

summary(my_glm)
##
## Call:
## NULL
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3792 -0.7097 -0.4091 0.7182 2.9452
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.92819 0.11779 -7.880 3.26e-15 ***
## pregnant 0.30570 0.13386 2.284 0.0224 *
## glucose 1.15961 0.14639 7.921 2.35e-15 ***
## pressure -0.24969 0.12737 -1.960 0.0499 *
## triceps -0.02486 0.13281 -0.187 0.8515
## insulin -0.17334 0.12907 -1.343 0.1793
## mass 0.74699 0.14908 5.011 5.42e-07 ***
## pedigree 0.26396 0.11461 2.303 0.0213 *
## age 0.26776 0.13355 2.005 0.0450 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 692.01 on 538 degrees of freedom
## Residual deviance: 499.21 on 530 degrees of freedom
## AIC: 517.21
##
## Number of Fisher Scoring iterations: 5
control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_stepglm <- train(train[,1:8], train[,9],
method = "glmStepAIC",
preProc = c("center", "scale"),
trControl = control)
## Start: AIC=478.14
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 460.21 476.21
## <none> 460.14 478.14
## - age 1 462.25 478.25
## - insulin 1 462.44 478.44
## - pressure 1 464.17 480.17
## - pedigree 1 465.52 481.52
## - pregnant 1 467.85 483.85
## - mass 1 485.29 501.29
## - glucose 1 528.91 544.91
##
## Step: AIC=476.21
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 460.21 476.21
## - age 1 462.35 476.35
## - insulin 1 463.47 477.47
## - pressure 1 464.45 478.45
## - pedigree 1 465.54 479.54
## - pregnant 1 467.93 481.93
## - mass 1 486.73 500.73
## - glucose 1 530.79 544.79
## Start: AIC=463.06
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 445.11 461.11
## <none> 445.06 463.06
## - insulin 1 447.19 463.19
## - pregnant 1 447.31 463.31
## - pedigree 1 447.74 463.74
## - pressure 1 448.14 464.14
## - age 1 451.01 467.01
## - mass 1 468.88 484.88
## - glucose 1 527.45 543.45
##
## Step: AIC=461.11
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 445.11 461.11
## - pregnant 1 447.34 461.34
## - pedigree 1 447.75 461.75
## - insulin 1 448.10 462.10
## - pressure 1 448.38 462.38
## - age 1 451.22 465.22
## - mass 1 470.38 484.38
## - glucose 1 529.85 543.85
## Start: AIC=459.15
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 441.16 457.16
## <none> 441.15 459.15
## - age 1 443.16 459.16
## - insulin 1 443.27 459.27
## - pedigree 1 445.88 461.88
## - pressure 1 447.19 463.19
## - pregnant 1 447.68 463.68
## - mass 1 469.48 485.48
## - glucose 1 520.39 536.39
##
## Step: AIC=457.16
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - age 1 443.16 457.16
## <none> 441.16 457.16
## - insulin 1 443.67 457.67
## - pedigree 1 445.92 459.92
## - pressure 1 447.29 461.29
## - pregnant 1 447.68 461.68
## - mass 1 472.59 486.59
## - glucose 1 522.01 536.01
##
## Step: AIC=457.16
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree
##
## Df Deviance AIC
## <none> 443.16 457.16
## - insulin 1 445.86 457.86
## - pedigree 1 448.05 460.05
## - pressure 1 448.28 460.28
## - pregnant 1 458.58 470.58
## - mass 1 473.69 485.69
## - glucose 1 533.44 545.44
## Start: AIC=467.41
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 449.41 465.41
## - age 1 450.04 466.04
## - pedigree 1 450.61 466.61
## - insulin 1 451.15 467.15
## <none> 449.41 467.41
## - pressure 1 453.93 469.93
## - pregnant 1 456.76 472.76
## - mass 1 475.52 491.52
## - glucose 1 530.92 546.92
##
## Step: AIC=465.41
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - age 1 450.04 464.04
## - pedigree 1 450.61 464.61
## <none> 449.41 465.41
## - insulin 1 451.52 465.52
## - pressure 1 454.04 468.04
## - pregnant 1 456.76 470.76
## - mass 1 477.94 491.94
## - glucose 1 532.01 546.01
##
## Step: AIC=464.04
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree
##
## Df Deviance AIC
## - pedigree 1 451.22 463.22
## <none> 450.04 464.04
## - insulin 1 452.35 464.35
## - pressure 1 454.31 466.31
## - pregnant 1 464.11 476.11
## - mass 1 478.15 490.15
## - glucose 1 541.62 553.62
##
## Step: AIC=463.22
## .outcome ~ pregnant + glucose + pressure + insulin + mass
##
## Df Deviance AIC
## - insulin 1 453.12 463.12
## <none> 451.22 463.22
## - pressure 1 455.40 465.40
## - pregnant 1 465.07 475.07
## - mass 1 479.74 489.74
## - glucose 1 543.29 553.29
##
## Step: AIC=463.12
## .outcome ~ pregnant + glucose + pressure + mass
##
## Df Deviance AIC
## <none> 453.12 463.12
## - pressure 1 457.38 465.38
## - pregnant 1 468.54 476.54
## - mass 1 480.08 488.08
## - glucose 1 550.57 558.57
## Start: AIC=477.57
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 459.57 475.57
## - insulin 1 461.08 477.08
## <none> 459.57 477.57
## - pregnant 1 462.41 478.41
## - pressure 1 462.65 478.65
## - pedigree 1 464.69 480.69
## - age 1 465.94 481.94
## - mass 1 486.49 502.49
## - glucose 1 519.65 535.65
##
## Step: AIC=475.57
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 461.37 475.37
## <none> 459.57 475.57
## - pregnant 1 462.42 476.42
## - pressure 1 462.71 476.71
## - pedigree 1 464.77 478.77
## - age 1 465.96 479.96
## - mass 1 489.55 503.55
## - glucose 1 520.94 534.94
##
## Step: AIC=475.37
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 461.37 475.37
## - pregnant 1 464.68 476.68
## - pressure 1 464.71 476.71
## - pedigree 1 465.79 477.79
## - age 1 468.22 480.22
## - mass 1 490.04 502.04
## - glucose 1 523.95 535.95
## Start: AIC=457.48
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 439.58 455.58
## - insulin 1 440.83 456.83
## <none> 439.48 457.48
## - pressure 1 443.52 459.52
## - pregnant 1 443.92 459.92
## - pedigree 1 446.02 462.02
## - age 1 446.25 462.25
## - mass 1 469.41 485.41
## - glucose 1 513.02 529.02
##
## Step: AIC=455.58
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 441.55 455.55
## <none> 439.58 455.58
## - pressure 1 443.88 457.88
## - pregnant 1 444.03 458.03
## - pedigree 1 446.02 460.02
## - age 1 446.45 460.45
## - mass 1 471.50 485.50
## - glucose 1 514.81 528.81
##
## Step: AIC=455.55
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 441.55 455.55
## - pressure 1 445.83 457.83
## - pregnant 1 446.58 458.58
## - pedigree 1 447.12 459.12
## - age 1 448.77 460.77
## - mass 1 471.86 483.86
## - glucose 1 519.29 531.29
## Start: AIC=473.12
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 455.27 471.27
## - insulin 1 456.32 472.32
## <none> 455.12 473.12
## - pressure 1 458.25 474.25
## - age 1 458.27 474.27
## - pregnant 1 460.31 476.31
## - pedigree 1 461.23 477.23
## - mass 1 481.40 497.40
## - glucose 1 521.62 537.62
##
## Step: AIC=471.27
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 457.19 471.19
## <none> 455.27 471.27
## - age 1 458.53 472.53
## - pressure 1 458.66 472.66
## - pregnant 1 460.42 474.42
## - pedigree 1 461.26 475.26
## - mass 1 482.72 496.72
## - glucose 1 523.35 537.35
##
## Step: AIC=471.19
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 457.19 471.19
## - age 1 460.74 472.74
## - pressure 1 460.83 472.83
## - pedigree 1 462.28 474.28
## - pregnant 1 462.96 474.96
## - mass 1 483.40 495.40
## - glucose 1 527.53 539.53
## Start: AIC=462.7
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 445.04 461.04
## - insulin 1 445.17 461.17
## <none> 444.70 462.70
## - pressure 1 448.01 464.01
## - age 1 448.24 464.24
## - pedigree 1 450.12 466.12
## - pregnant 1 450.85 466.85
## - mass 1 473.43 489.43
## - glucose 1 517.29 533.29
##
## Step: AIC=461.04
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 446.10 460.10
## <none> 445.04 461.04
## - age 1 448.63 462.63
## - pressure 1 448.81 462.81
## - pedigree 1 450.32 464.32
## - pregnant 1 451.18 465.18
## - mass 1 474.83 488.83
## - glucose 1 520.23 534.23
##
## Step: AIC=460.1
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 446.10 460.10
## - pressure 1 450.09 462.09
## - age 1 450.14 462.14
## - pedigree 1 450.75 462.75
## - pregnant 1 452.42 464.42
## - mass 1 474.98 486.98
## - glucose 1 524.11 536.11
## Start: AIC=465.53
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 447.60 463.60
## - pressure 1 448.76 464.76
## <none> 447.53 465.53
## - insulin 1 449.72 465.72
## - age 1 450.65 466.65
## - pregnant 1 451.63 467.63
## - pedigree 1 455.52 471.52
## - mass 1 475.22 491.22
## - glucose 1 518.80 534.80
##
## Step: AIC=463.6
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - pressure 1 448.95 462.95
## <none> 447.60 463.60
## - insulin 1 450.80 464.80
## - age 1 450.82 464.82
## - pregnant 1 451.69 465.69
## - pedigree 1 455.53 469.53
## - mass 1 477.14 491.14
## - glucose 1 521.29 535.29
##
## Step: AIC=462.95
## .outcome ~ pregnant + glucose + insulin + mass + pedigree + age
##
## Df Deviance AIC
## <none> 448.95 462.95
## - age 1 451.69 463.69
## - insulin 1 452.17 464.17
## - pregnant 1 452.74 464.74
## - pedigree 1 456.95 468.95
## - mass 1 477.23 489.23
## - glucose 1 521.70 533.70
## Start: AIC=458.24
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 440.28 456.28
## - insulin 1 441.95 457.95
## <none> 440.24 458.24
## - pregnant 1 443.35 459.35
## - pressure 1 444.17 460.17
## - age 1 445.51 461.51
## - pedigree 1 445.90 461.90
## - mass 1 462.21 478.21
## - glucose 1 519.12 535.12
##
## Step: AIC=456.28
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 442.16 456.16
## <none> 440.28 456.28
## - pregnant 1 443.42 457.42
## - pressure 1 444.18 458.18
## - age 1 445.51 459.51
## - pedigree 1 446.05 460.05
## - mass 1 464.69 478.69
## - glucose 1 520.47 534.47
##
## Step: AIC=456.16
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 442.16 456.16
## - pregnant 1 445.78 457.78
## - pressure 1 446.30 458.30
## - pedigree 1 447.36 459.36
## - age 1 447.70 459.70
## - mass 1 465.18 477.18
## - glucose 1 524.68 536.68
## Start: AIC=454.07
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 436.07 452.07
## - insulin 1 437.96 453.96
## <none> 436.07 454.07
## - pregnant 1 438.77 454.77
## - age 1 440.86 456.86
## - pressure 1 442.06 458.06
## - pedigree 1 442.71 458.71
## - mass 1 464.50 480.50
## - glucose 1 521.00 537.00
##
## Step: AIC=452.07
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 436.07 452.07
## - insulin 1 438.35 452.35
## - pregnant 1 438.77 452.77
## - age 1 440.87 454.87
## - pressure 1 442.21 456.21
## - pedigree 1 442.74 456.74
## - mass 1 467.28 481.28
## - glucose 1 523.09 537.09
## Start: AIC=474.9
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 456.93 472.93
## - insulin 1 457.58 473.58
## <none> 456.90 474.90
## - age 1 459.50 475.50
## - pressure 1 459.96 475.96
## - pedigree 1 460.77 476.77
## - pregnant 1 463.39 479.39
## - mass 1 478.94 494.94
## - glucose 1 525.93 541.93
##
## Step: AIC=472.93
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 457.87 471.87
## <none> 456.93 472.93
## - age 1 459.58 473.58
## - pressure 1 460.15 474.15
## - pedigree 1 460.77 474.77
## - pregnant 1 463.41 477.41
## - mass 1 480.77 494.77
## - glucose 1 527.05 541.05
##
## Step: AIC=471.87
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 457.87 471.87
## - age 1 460.73 472.73
## - pressure 1 461.17 473.17
## - pedigree 1 461.37 473.37
## - pregnant 1 464.78 476.78
## - mass 1 480.87 492.87
## - glucose 1 533.63 545.63
## Start: AIC=462.13
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 444.84 460.84
## - insulin 1 445.60 461.60
## <none> 444.13 462.13
## - pressure 1 448.14 464.14
## - pregnant 1 449.44 465.44
## - pedigree 1 449.59 465.59
## - age 1 449.70 465.70
## - mass 1 470.92 486.92
## - glucose 1 517.73 533.73
##
## Step: AIC=460.84
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 444.84 460.84
## - insulin 1 447.91 461.91
## - pressure 1 449.47 463.47
## - pedigree 1 450.01 464.01
## - pregnant 1 450.08 464.08
## - age 1 450.61 464.61
## - mass 1 471.48 485.48
## - glucose 1 521.88 535.88
## Start: AIC=478.24
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 460.33 476.33
## <none> 460.24 478.24
## - insulin 1 462.53 478.53
## - pressure 1 463.68 479.68
## - age 1 464.05 480.05
## - pedigree 1 464.97 480.97
## - pregnant 1 465.06 481.06
## - mass 1 488.04 504.04
## - glucose 1 528.65 544.65
##
## Step: AIC=476.33
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 460.33 476.33
## - insulin 1 463.55 477.55
## - pressure 1 464.05 478.05
## - age 1 464.21 478.21
## - pedigree 1 464.98 478.98
## - pregnant 1 465.14 479.14
## - mass 1 490.07 504.07
## - glucose 1 530.47 544.47
## Start: AIC=464.84
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 446.97 462.97
## <none> 446.84 464.84
## - age 1 449.44 465.44
## - pressure 1 449.84 465.84
## - insulin 1 450.17 466.17
## - pregnant 1 451.51 467.51
## - pedigree 1 455.70 471.70
## - mass 1 473.27 489.27
## - glucose 1 519.99 535.99
##
## Step: AIC=462.97
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 446.97 462.97
## - age 1 449.50 463.50
## - pressure 1 449.87 463.87
## - insulin 1 450.39 464.39
## - pregnant 1 451.71 465.71
## - pedigree 1 456.01 470.01
## - mass 1 477.28 491.28
## - glucose 1 521.09 535.09
## Start: AIC=463.22
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 445.24 461.24
## - insulin 1 447.06 463.06
## - pressure 1 447.18 463.18
## <none> 445.22 463.22
## - pedigree 1 449.03 465.03
## - age 1 449.04 465.04
## - pregnant 1 449.70 465.70
## - mass 1 475.20 491.20
## - glucose 1 516.39 532.39
##
## Step: AIC=461.24
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 445.24 461.24
## - pressure 1 447.33 461.33
## - insulin 1 447.69 461.69
## - pedigree 1 449.03 463.03
## - age 1 449.12 463.12
## - pregnant 1 449.71 463.71
## - mass 1 477.84 491.84
## - glucose 1 517.85 531.85
## Start: AIC=456.02
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 438.42 454.42
## <none> 438.02 456.02
## - insulin 1 440.36 456.36
## - pregnant 1 441.11 457.11
## - age 1 441.39 457.39
## - pressure 1 442.01 458.01
## - pedigree 1 444.51 460.51
## - mass 1 462.07 478.07
## - glucose 1 525.48 541.48
##
## Step: AIC=454.42
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 438.42 454.42
## - pregnant 1 441.45 455.45
## - age 1 441.86 455.86
## - insulin 1 442.61 456.61
## - pressure 1 442.83 456.83
## - pedigree 1 444.74 458.74
## - mass 1 462.58 476.58
## - glucose 1 528.88 542.88
## Start: AIC=467.86
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 450.11 466.11
## <none> 449.86 467.86
## - insulin 1 452.02 468.02
## - pressure 1 452.28 468.28
## - age 1 453.13 469.13
## - pedigree 1 454.75 470.75
## - pregnant 1 454.82 470.82
## - mass 1 473.63 489.63
## - glucose 1 524.47 540.47
##
## Step: AIC=466.11
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 452.04 466.04
## <none> 450.11 466.11
## - pressure 1 452.36 466.36
## - age 1 453.28 467.28
## - pregnant 1 455.08 469.08
## - pedigree 1 455.12 469.12
## - mass 1 477.85 491.85
## - glucose 1 524.91 538.91
##
## Step: AIC=466.04
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 452.04 466.04
## - pressure 1 454.31 466.31
## - age 1 455.52 467.52
## - pedigree 1 456.33 468.33
## - pregnant 1 457.49 469.49
## - mass 1 478.25 490.25
## - glucose 1 529.20 541.20
## Start: AIC=467.35
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 449.38 465.38
## - insulin 1 449.82 465.82
## <none> 449.35 467.35
## - age 1 452.13 468.13
## - pressure 1 454.17 470.17
## - pedigree 1 454.66 470.66
## - pregnant 1 455.03 471.03
## - mass 1 477.98 493.98
## - glucose 1 515.51 531.51
##
## Step: AIC=465.38
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 450.11 464.11
## <none> 449.38 465.38
## - age 1 452.21 466.21
## - pressure 1 454.43 468.43
## - pedigree 1 454.68 468.68
## - pregnant 1 455.09 469.09
## - mass 1 479.98 493.98
## - glucose 1 517.41 531.41
##
## Step: AIC=464.11
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 450.11 464.11
## - age 1 453.08 465.08
## - pedigree 1 455.01 467.01
## - pressure 1 455.24 467.24
## - pregnant 1 456.26 468.26
## - mass 1 480.01 492.01
## - glucose 1 524.35 536.35
## Start: AIC=474.04
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 456.23 472.23
## - insulin 1 456.91 472.91
## - pedigree 1 457.22 473.22
## <none> 456.04 474.04
## - pressure 1 459.25 475.25
## - age 1 460.21 476.21
## - pregnant 1 461.74 477.74
## - mass 1 483.14 499.14
## - glucose 1 521.58 537.58
##
## Step: AIC=472.23
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - pedigree 1 457.36 471.36
## - insulin 1 457.76 471.76
## <none> 456.23 472.23
## - pressure 1 459.74 473.74
## - age 1 460.56 474.56
## - pregnant 1 461.89 475.89
## - mass 1 484.49 498.49
## - glucose 1 523.65 537.65
##
## Step: AIC=471.36
## .outcome ~ pregnant + glucose + pressure + insulin + mass + age
##
## Df Deviance AIC
## - insulin 1 458.55 470.55
## <none> 457.36 471.36
## - pressure 1 460.78 472.78
## - age 1 461.62 473.62
## - pregnant 1 462.98 474.98
## - mass 1 485.91 497.91
## - glucose 1 526.27 538.27
##
## Step: AIC=470.55
## .outcome ~ pregnant + glucose + pressure + mass + age
##
## Df Deviance AIC
## <none> 458.55 470.55
## - pressure 1 462.12 472.12
## - age 1 463.12 473.12
## - pregnant 1 464.57 474.57
## - mass 1 486.05 496.05
## - glucose 1 532.87 542.87
## Start: AIC=465.61
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 448.06 464.06
## - insulin 1 448.35 464.35
## <none> 447.61 465.61
## - pressure 1 450.88 466.88
## - age 1 451.74 467.74
## - pregnant 1 454.09 470.09
## - pedigree 1 454.18 470.18
## - mass 1 473.32 489.32
## - glucose 1 516.85 532.85
##
## Step: AIC=464.06
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 449.62 463.62
## <none> 448.06 464.06
## - pressure 1 451.80 465.80
## - age 1 452.33 466.33
## - pedigree 1 454.41 468.41
## - pregnant 1 454.50 468.50
## - mass 1 474.17 488.17
## - glucose 1 519.83 533.83
##
## Step: AIC=463.62
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 449.62 463.62
## - pressure 1 453.49 465.49
## - age 1 454.30 466.30
## - pedigree 1 455.25 467.25
## - pregnant 1 456.51 468.51
## - mass 1 474.64 486.64
## - glucose 1 523.47 535.47
## Start: AIC=468.59
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 450.59 466.59
## - insulin 1 451.62 467.62
## <none> 450.59 468.59
## - pedigree 1 452.90 468.90
## - age 1 453.31 469.31
## - pressure 1 455.72 471.72
## - pregnant 1 457.83 473.83
## - mass 1 475.25 491.25
## - glucose 1 525.22 541.22
##
## Step: AIC=466.59
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 451.84 465.84
## <none> 450.59 466.59
## - pedigree 1 452.90 466.90
## - age 1 453.31 467.31
## - pressure 1 455.86 469.86
## - pregnant 1 457.83 471.83
## - mass 1 477.45 491.45
## - glucose 1 526.59 540.59
##
## Step: AIC=465.84
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## - pedigree 1 453.74 465.74
## <none> 451.84 465.84
## - age 1 454.72 466.72
## - pressure 1 457.35 469.35
## - pregnant 1 459.64 471.64
## - mass 1 477.64 489.64
## - glucose 1 532.36 544.36
##
## Step: AIC=465.74
## .outcome ~ pregnant + glucose + pressure + mass + age
##
## Df Deviance AIC
## <none> 453.74 465.74
## - age 1 456.67 466.67
## - pressure 1 459.26 469.26
## - pregnant 1 461.47 471.47
## - mass 1 480.93 490.93
## - glucose 1 537.57 547.57
## Start: AIC=473.99
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 456.00 472.00
## - insulin 1 457.73 473.73
## <none> 455.99 473.99
## - pressure 1 460.59 476.59
## - age 1 460.70 476.70
## - pedigree 1 461.96 477.96
## - pregnant 1 463.38 479.38
## - mass 1 477.88 493.88
## - glucose 1 520.74 536.74
##
## Step: AIC=472
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 456.00 472.00
## - insulin 1 458.00 472.00
## - pressure 1 460.66 474.66
## - age 1 460.71 474.71
## - pedigree 1 462.02 476.02
## - pregnant 1 463.38 477.38
## - mass 1 480.18 494.18
## - glucose 1 521.37 535.37
## Start: AIC=457.17
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 439.28 455.28
## - age 1 440.46 456.46
## <none> 439.17 457.17
## - insulin 1 442.01 458.01
## - pressure 1 443.94 459.94
## - pregnant 1 444.03 460.03
## - pedigree 1 444.24 460.24
## - mass 1 470.25 486.25
## - glucose 1 525.57 541.57
##
## Step: AIC=455.28
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - age 1 440.61 454.61
## <none> 439.28 455.28
## - insulin 1 443.43 457.43
## - pregnant 1 444.15 458.15
## - pedigree 1 444.29 458.29
## - pressure 1 444.38 458.38
## - mass 1 472.36 486.36
## - glucose 1 528.37 542.37
##
## Step: AIC=454.61
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree
##
## Df Deviance AIC
## <none> 440.61 454.61
## - pressure 1 445.11 457.11
## - insulin 1 445.29 457.29
## - pedigree 1 445.60 457.60
## - pregnant 1 451.44 463.44
## - mass 1 472.79 484.79
## - glucose 1 539.29 551.29
## Start: AIC=464.33
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 446.34 462.34
## <none> 446.33 464.33
## - age 1 449.35 465.35
## - pedigree 1 449.64 465.64
## - insulin 1 450.17 466.17
## - pressure 1 450.55 466.55
## - pregnant 1 452.08 468.08
## - mass 1 470.08 486.08
## - glucose 1 527.01 543.01
##
## Step: AIC=462.34
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 446.34 462.34
## - age 1 449.35 463.35
## - pedigree 1 449.69 463.69
## - pressure 1 450.60 464.60
## - insulin 1 450.83 464.83
## - pregnant 1 452.10 466.10
## - mass 1 473.12 487.12
## - glucose 1 528.17 542.17
## Start: AIC=471.4
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 453.48 469.48
## - insulin 1 454.90 470.90
## <none> 453.40 471.40
## - pressure 1 455.77 471.77
## - age 1 456.22 472.22
## - pedigree 1 458.25 474.25
## - pregnant 1 458.74 474.74
## - mass 1 477.69 493.69
## - glucose 1 526.82 542.82
##
## Step: AIC=469.48
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 453.48 469.48
## - insulin 1 455.78 469.78
## - pressure 1 456.05 470.05
## - age 1 456.37 470.37
## - pedigree 1 458.27 472.27
## - pregnant 1 458.78 472.78
## - mass 1 478.85 492.85
## - glucose 1 528.80 542.80
## Start: AIC=469.14
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 451.34 467.34
## - insulin 1 452.00 468.00
## - pressure 1 453.04 469.04
## <none> 451.14 469.14
## - pregnant 1 453.68 469.68
## - pedigree 1 455.83 471.83
## - age 1 456.22 472.22
## - mass 1 479.25 495.25
## - glucose 1 517.49 533.49
##
## Step: AIC=467.34
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 452.88 466.88
## <none> 451.34 467.34
## - pressure 1 453.45 467.45
## - pregnant 1 453.86 467.86
## - pedigree 1 455.89 469.89
## - age 1 456.62 470.62
## - mass 1 480.88 494.88
## - glucose 1 519.82 533.82
##
## Step: AIC=466.88
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 452.88 466.88
## - pressure 1 455.17 467.17
## - pregnant 1 455.77 467.77
## - pedigree 1 456.77 468.77
## - age 1 458.62 470.62
## - mass 1 481.15 493.15
## - glucose 1 524.30 536.30
## Start: AIC=470.42
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 452.46 468.46
## - pregnant 1 454.40 470.40
## <none> 452.42 470.42
## - pressure 1 454.85 470.85
## - insulin 1 455.50 471.50
## - age 1 456.44 472.44
## - pedigree 1 457.28 473.28
## - mass 1 482.63 498.63
## - glucose 1 527.08 543.08
##
## Step: AIC=468.46
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - pregnant 1 454.43 468.43
## <none> 452.46 468.46
## - pressure 1 455.08 469.08
## - age 1 456.56 470.56
## - insulin 1 456.86 470.86
## - pedigree 1 457.28 471.28
## - mass 1 484.58 498.58
## - glucose 1 530.83 544.83
##
## Step: AIC=468.43
## .outcome ~ glucose + pressure + insulin + mass + pedigree + age
##
## Df Deviance AIC
## <none> 454.43 468.43
## - pressure 1 456.61 468.61
## - pedigree 1 459.15 471.15
## - insulin 1 459.67 471.67
## - age 1 465.30 477.30
## - mass 1 487.07 499.07
## - glucose 1 533.66 545.66
## Start: AIC=462.32
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 444.43 460.43
## - insulin 1 444.65 460.65
## <none> 444.32 462.32
## - pregnant 1 447.52 463.52
## - pressure 1 448.15 464.15
## - age 1 450.95 466.95
## - pedigree 1 454.13 470.13
## - mass 1 472.39 488.39
## - glucose 1 511.39 527.39
##
## Step: AIC=460.43
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 445.06 459.06
## <none> 444.43 460.43
## - pregnant 1 447.60 461.60
## - pressure 1 448.51 462.51
## - age 1 451.19 465.19
## - pedigree 1 454.14 468.14
## - mass 1 474.12 488.12
## - glucose 1 513.35 527.35
##
## Step: AIC=459.06
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 445.06 459.06
## - pregnant 1 448.47 460.47
## - pressure 1 449.14 461.14
## - age 1 452.06 464.06
## - pedigree 1 454.40 466.40
## - mass 1 474.13 486.13
## - glucose 1 519.80 531.80
## Start: AIC=459.35
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 441.54 457.54
## <none> 441.35 459.35
## - insulin 1 443.52 459.52
## - pedigree 1 444.52 460.52
## - age 1 444.59 460.59
## - pressure 1 445.02 461.02
## - pregnant 1 445.84 461.84
## - mass 1 469.13 485.13
## - glucose 1 517.44 533.44
##
## Step: AIC=457.54
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 441.54 457.54
## - insulin 1 443.56 457.56
## - age 1 444.71 458.71
## - pedigree 1 444.84 458.84
## - pressure 1 445.05 459.05
## - pregnant 1 446.03 460.03
## - mass 1 473.50 487.50
## - glucose 1 517.98 531.98
## Start: AIC=468.59
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 450.64 466.64
## - insulin 1 451.48 467.48
## <none> 450.59 468.59
## - pedigree 1 453.90 469.90
## - pressure 1 454.84 470.84
## - pregnant 1 455.72 471.72
## - age 1 456.25 472.25
## - mass 1 477.18 493.18
## - glucose 1 514.29 530.29
##
## Step: AIC=466.64
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 451.52 465.52
## <none> 450.64 466.64
## - pedigree 1 454.03 468.03
## - pressure 1 454.85 468.85
## - pregnant 1 455.77 469.77
## - age 1 456.25 470.25
## - mass 1 480.44 494.44
## - glucose 1 514.83 528.83
##
## Step: AIC=465.52
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 451.52 465.52
## - pedigree 1 454.48 466.48
## - pressure 1 455.92 467.92
## - pregnant 1 457.08 469.08
## - age 1 457.39 469.39
## - mass 1 480.59 492.59
## - glucose 1 519.42 531.42
## Start: AIC=464.84
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 446.84 462.84
## <none> 446.84 464.84
## - insulin 1 449.12 465.12
## - age 1 449.53 465.53
## - pedigree 1 451.17 467.17
## - pregnant 1 451.85 467.85
## - pressure 1 451.87 467.87
## - mass 1 478.30 494.30
## - glucose 1 522.27 538.27
##
## Step: AIC=462.84
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 446.84 462.84
## - age 1 449.53 463.53
## - insulin 1 449.55 463.55
## - pedigree 1 451.22 465.22
## - pregnant 1 451.85 465.85
## - pressure 1 451.96 465.96
## - mass 1 481.25 495.25
## - glucose 1 523.47 537.47
## Start: AIC=458.99
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 441.00 457.00
## <none> 440.99 458.99
## - insulin 1 444.13 460.13
## - pregnant 1 444.30 460.30
## - pressure 1 444.77 460.77
## - age 1 445.73 461.73
## - pedigree 1 450.28 466.28
## - mass 1 470.94 486.94
## - glucose 1 518.54 534.54
##
## Step: AIC=457
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 441.00 457.00
## - pregnant 1 444.30 458.30
## - pressure 1 444.93 458.93
## - insulin 1 445.11 459.11
## - age 1 445.78 459.78
## - pedigree 1 450.30 464.30
## - mass 1 473.05 487.05
## - glucose 1 519.86 533.86
## Start: AIC=466.77
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 448.96 464.96
## - insulin 1 449.31 465.31
## - age 1 450.62 466.62
## <none> 448.77 466.77
## - pedigree 1 452.47 468.47
## - pressure 1 452.82 468.82
## - pregnant 1 456.59 472.59
## - mass 1 477.27 493.27
## - glucose 1 521.24 537.24
##
## Step: AIC=464.96
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 450.01 464.01
## - age 1 450.88 464.88
## <none> 448.96 464.96
## - pedigree 1 452.53 466.53
## - pressure 1 453.45 467.45
## - pregnant 1 456.79 470.79
## - mass 1 478.77 492.77
## - glucose 1 523.76 537.76
##
## Step: AIC=464.01
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 450.01 464.01
## - age 1 452.09 464.09
## - pedigree 1 453.23 465.23
## - pressure 1 454.69 466.69
## - pregnant 1 458.48 470.48
## - mass 1 478.85 490.85
## - glucose 1 528.77 540.77
## Start: AIC=464.06
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 446.30 462.30
## - insulin 1 447.00 463.00
## <none> 446.06 464.06
## - pressure 1 448.67 464.67
## - pedigree 1 449.28 465.28
## - age 1 449.61 465.61
## - pregnant 1 451.31 467.31
## - mass 1 469.82 485.82
## - glucose 1 520.87 536.87
##
## Step: AIC=462.3
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 447.95 461.95
## <none> 446.30 462.30
## - pressure 1 449.25 463.25
## - pedigree 1 449.40 463.40
## - age 1 450.03 464.03
## - pregnant 1 451.50 465.50
## - mass 1 470.84 484.84
## - glucose 1 522.88 536.88
##
## Step: AIC=461.95
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 447.95 461.95
## - pedigree 1 450.47 462.47
## - pressure 1 451.11 463.11
## - age 1 452.04 464.04
## - pregnant 1 453.59 465.59
## - mass 1 471.28 483.28
## - glucose 1 528.24 540.24
## Start: AIC=464.16
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 446.24 462.24
## - insulin 1 446.96 462.96
## <none> 446.16 464.16
## - pressure 1 449.27 465.27
## - age 1 450.44 466.44
## - pregnant 1 451.59 467.59
## - pedigree 1 453.03 469.03
## - mass 1 471.28 487.28
## - glucose 1 512.77 528.77
##
## Step: AIC=462.24
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 446.97 460.97
## <none> 446.24 462.24
## - pressure 1 449.27 463.27
## - age 1 450.46 464.46
## - pregnant 1 451.66 465.66
## - pedigree 1 453.22 467.22
## - mass 1 474.58 488.58
## - glucose 1 513.64 527.64
##
## Step: AIC=460.97
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 446.97 460.97
## - pressure 1 450.06 462.06
## - age 1 451.44 463.44
## - pregnant 1 452.70 464.70
## - pedigree 1 453.52 465.52
## - mass 1 474.60 486.60
## - glucose 1 519.65 531.65
## Start: AIC=466.39
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 448.88 464.88
## - insulin 1 449.56 465.56
## <none> 448.39 466.39
## - pregnant 1 451.42 467.42
## - age 1 452.77 468.77
## - pressure 1 453.31 469.31
## - pedigree 1 454.52 470.52
## - mass 1 473.05 489.05
## - glucose 1 524.19 540.19
##
## Step: AIC=464.88
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 448.88 464.88
## - insulin 1 451.37 465.37
## - pregnant 1 451.93 465.93
## - age 1 453.33 467.33
## - pressure 1 454.48 468.48
## - pedigree 1 454.80 468.80
## - mass 1 473.55 487.55
## - glucose 1 528.85 542.85
## Start: AIC=480.31
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 462.67 478.67
## - insulin 1 463.27 479.27
## - age 1 464.13 480.13
## - pressure 1 464.25 480.25
## <none> 462.31 480.31
## - pedigree 1 467.63 483.63
## - pregnant 1 468.40 484.40
## - mass 1 486.49 502.49
## - glucose 1 530.25 546.25
##
## Step: AIC=478.67
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 464.46 478.46
## - age 1 464.61 478.61
## <none> 462.67 478.67
## - pressure 1 464.85 478.85
## - pedigree 1 467.81 481.81
## - pregnant 1 468.71 482.71
## - mass 1 487.63 501.63
## - glucose 1 532.97 546.97
##
## Step: AIC=478.46
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 464.46 478.46
## - age 1 466.55 478.55
## - pressure 1 466.69 478.69
## - pedigree 1 468.88 480.88
## - pregnant 1 471.14 483.14
## - mass 1 487.95 499.95
## - glucose 1 536.70 548.70
## Start: AIC=466.93
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 448.96 464.96
## - insulin 1 450.58 466.58
## <none> 448.93 466.93
## - pedigree 1 451.44 467.44
## - age 1 451.82 467.82
## - pressure 1 453.42 469.42
## - pregnant 1 454.24 470.24
## - mass 1 476.70 492.70
## - glucose 1 524.16 540.16
##
## Step: AIC=464.96
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 448.96 464.96
## - insulin 1 451.27 465.27
## - pedigree 1 451.45 465.45
## - age 1 451.93 465.93
## - pressure 1 453.62 467.62
## - pregnant 1 454.27 468.27
## - mass 1 478.98 492.98
## - glucose 1 526.45 540.45
## Start: AIC=461.31
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 443.38 459.38
## <none> 443.31 461.31
## - pressure 1 445.58 461.58
## - pregnant 1 445.71 461.71
## - age 1 448.95 464.95
## - pedigree 1 449.11 465.11
## - insulin 1 449.78 465.78
## - mass 1 466.07 482.07
## - glucose 1 526.99 542.99
##
## Step: AIC=459.38
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 443.38 459.38
## - pressure 1 445.58 459.58
## - pregnant 1 445.83 459.83
## - age 1 448.96 462.96
## - pedigree 1 449.30 463.30
## - insulin 1 450.60 464.60
## - mass 1 469.86 483.86
## - glucose 1 528.34 542.34
## Start: AIC=477.76
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 459.76 475.76
## <none> 459.76 477.76
## - insulin 1 461.88 477.88
## - pressure 1 462.44 478.44
## - age 1 464.20 480.20
## - pedigree 1 464.22 480.22
## - pregnant 1 464.65 480.65
## - mass 1 482.51 498.51
## - glucose 1 529.38 545.38
##
## Step: AIC=475.76
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 459.76 475.76
## - insulin 1 462.51 476.51
## - pressure 1 462.54 476.54
## - pedigree 1 464.22 478.22
## - age 1 464.25 478.25
## - pregnant 1 464.65 478.65
## - mass 1 484.68 498.68
## - glucose 1 531.23 545.23
## Start: AIC=473.74
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 456.05 472.05
## <none> 455.74 473.74
## - age 1 458.18 474.18
## - pressure 1 458.66 474.66
## - insulin 1 460.39 476.39
## - pregnant 1 460.91 476.91
## - pedigree 1 461.08 477.08
## - mass 1 483.26 499.26
## - glucose 1 524.08 540.08
##
## Step: AIC=472.05
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 456.05 472.05
## - age 1 458.45 472.45
## - pressure 1 458.75 472.75
## - insulin 1 460.64 474.64
## - pregnant 1 461.18 475.18
## - pedigree 1 461.53 475.53
## - mass 1 487.12 501.12
## - glucose 1 524.61 538.61
## Start: AIC=479.42
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 461.62 477.62
## - insulin 1 463.07 479.07
## <none> 461.42 479.42
## - age 1 464.64 480.64
## - pressure 1 465.63 481.63
## - pedigree 1 466.39 482.39
## - pregnant 1 468.01 484.01
## - mass 1 489.21 505.21
## - glucose 1 525.28 541.28
##
## Step: AIC=477.62
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 461.62 477.62
## - insulin 1 464.24 478.24
## - age 1 464.98 478.98
## - pressure 1 466.29 480.29
## - pedigree 1 466.45 480.45
## - pregnant 1 468.19 482.19
## - mass 1 490.32 504.32
## - glucose 1 527.65 541.65
## Start: AIC=459.02
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 442.04 458.04
## - insulin 1 442.32 458.32
## <none> 441.02 459.02
## - age 1 443.57 459.57
## - pressure 1 443.68 459.68
## - pregnant 1 445.80 461.80
## - pedigree 1 446.99 462.99
## - mass 1 465.01 481.01
## - glucose 1 523.70 539.70
##
## Step: AIC=458.04
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 442.04 458.04
## - age 1 444.81 458.81
## - insulin 1 445.04 459.04
## - pressure 1 445.34 459.34
## - pregnant 1 446.81 460.81
## - pedigree 1 447.66 461.66
## - mass 1 465.12 479.12
## - glucose 1 528.28 542.28
## Start: AIC=456.36
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 438.57 454.57
## - pressure 1 439.82 455.82
## - insulin 1 440.23 456.23
## <none> 438.36 456.36
## - pregnant 1 441.01 457.01
## - age 1 441.83 457.83
## - pedigree 1 442.10 458.10
## - mass 1 474.65 490.65
## - glucose 1 513.70 529.70
##
## Step: AIC=454.57
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - pressure 1 440.22 454.22
## <none> 438.57 454.57
## - pregnant 1 441.12 455.12
## - insulin 1 441.59 455.59
## - pedigree 1 442.20 456.20
## - age 1 442.23 456.23
## - mass 1 476.75 490.75
## - glucose 1 516.74 530.74
##
## Step: AIC=454.22
## .outcome ~ pregnant + glucose + insulin + mass + pedigree + age
##
## Df Deviance AIC
## <none> 440.22 454.22
## - pregnant 1 442.37 454.37
## - age 1 443.34 455.34
## - insulin 1 443.42 455.42
## - pedigree 1 443.90 455.90
## - mass 1 476.76 488.76
## - glucose 1 518.26 530.26
## Start: AIC=474.75
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 456.75 472.75
## - insulin 1 458.46 474.46
## <none> 456.75 474.75
## - pressure 1 460.13 476.13
## - age 1 460.24 476.24
## - pedigree 1 460.74 476.74
## - pregnant 1 461.83 477.83
## - mass 1 480.92 496.92
## - glucose 1 528.13 544.13
##
## Step: AIC=472.75
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 456.75 472.75
## - insulin 1 458.83 472.83
## - pressure 1 460.22 474.22
## - age 1 460.26 474.26
## - pedigree 1 460.75 474.75
## - pregnant 1 461.83 475.83
## - mass 1 483.03 497.03
## - glucose 1 529.14 543.14
## Start: AIC=467.45
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 449.46 465.46
## <none> 449.45 467.45
## - insulin 1 452.19 468.19
## - pregnant 1 452.74 468.74
## - age 1 453.42 469.42
## - pressure 1 453.70 469.70
## - pedigree 1 455.37 471.37
## - mass 1 474.70 490.70
## - glucose 1 527.74 543.74
##
## Step: AIC=465.46
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 449.46 465.46
## - insulin 1 452.71 466.71
## - pregnant 1 452.76 466.76
## - age 1 453.42 467.42
## - pressure 1 453.73 467.73
## - pedigree 1 455.46 469.46
## - mass 1 477.89 491.89
## - glucose 1 529.40 543.40
## Start: AIC=449.97
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 432.18 448.18
## - insulin 1 432.78 448.78
## <none> 431.97 449.97
## - pressure 1 435.97 451.97
## - pregnant 1 436.77 452.77
## - age 1 437.04 453.04
## - pedigree 1 438.33 454.33
## - mass 1 455.73 471.73
## - glucose 1 513.71 529.71
##
## Step: AIC=448.18
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 433.64 447.64
## <none> 432.18 448.18
## - pressure 1 436.58 450.58
## - pregnant 1 437.01 451.01
## - age 1 437.32 451.32
## - pedigree 1 438.38 452.38
## - mass 1 457.11 471.11
## - glucose 1 516.57 530.57
##
## Step: AIC=447.64
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 433.64 447.64
## - pressure 1 438.11 450.11
## - pregnant 1 438.97 450.97
## - age 1 439.04 451.04
## - pedigree 1 439.11 451.11
## - mass 1 457.57 469.57
## - glucose 1 521.89 533.89
## Start: AIC=453.57
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 435.60 451.60
## - insulin 1 436.05 452.05
## <none> 435.57 453.57
## - pressure 1 439.87 455.87
## - pregnant 1 439.98 455.98
## - pedigree 1 440.14 456.14
## - age 1 440.16 456.16
## - mass 1 457.73 473.73
## - glucose 1 515.14 531.14
##
## Step: AIC=451.6
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 436.08 450.08
## <none> 435.60 451.60
## - pressure 1 439.90 453.90
## - pregnant 1 440.00 454.00
## - age 1 440.17 454.17
## - pedigree 1 440.26 454.26
## - mass 1 460.53 474.53
## - glucose 1 516.42 530.42
##
## Step: AIC=450.08
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 436.08 450.08
## - pedigree 1 440.44 452.44
## - pressure 1 440.46 452.46
## - pregnant 1 440.73 452.73
## - age 1 440.86 452.86
## - mass 1 460.55 472.55
## - glucose 1 523.91 535.91
## Start: AIC=468.4
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 450.40 466.40
## - insulin 1 451.23 467.23
## <none> 450.40 468.40
## - age 1 453.63 469.63
## - pedigree 1 454.81 470.81
## - pregnant 1 456.43 472.43
## - pressure 1 456.84 472.84
## - mass 1 483.48 499.48
## - glucose 1 514.04 530.04
##
## Step: AIC=466.4
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## - insulin 1 451.44 465.44
## <none> 450.40 466.40
## - age 1 453.66 467.66
## - pedigree 1 454.82 468.82
## - pregnant 1 456.43 470.43
## - pressure 1 456.97 470.97
## - mass 1 487.05 501.05
## - glucose 1 514.72 528.72
##
## Step: AIC=465.44
## .outcome ~ pregnant + glucose + pressure + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 451.44 465.44
## - age 1 454.82 466.82
## - pedigree 1 455.35 467.35
## - pregnant 1 457.97 469.97
## - pressure 1 458.02 470.02
## - mass 1 487.12 499.12
## - glucose 1 519.91 531.91
## Start: AIC=517.21
## .outcome ~ pregnant + glucose + pressure + triceps + insulin +
## mass + pedigree + age
##
## Df Deviance AIC
## - triceps 1 499.24 515.24
## - insulin 1 501.00 517.00
## <none> 499.21 517.21
## - pressure 1 503.12 519.12
## - age 1 503.21 519.21
## - pregnant 1 504.49 520.49
## - pedigree 1 504.60 520.60
## - mass 1 528.60 544.60
## - glucose 1 580.54 596.54
##
## Step: AIC=515.24
## .outcome ~ pregnant + glucose + pressure + insulin + mass + pedigree +
## age
##
## Df Deviance AIC
## <none> 499.24 515.24
## - insulin 1 501.71 515.71
## - age 1 503.31 517.31
## - pressure 1 503.36 517.36
## - pregnant 1 504.51 518.51
## - pedigree 1 504.60 518.60
## - mass 1 530.83 544.83
## - glucose 1 582.55 596.55
# Predict using the test data
pred<-predict(my_stepglm,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, plot variable importance
print(varImp(my_stepglm, scale = FALSE))
## ROC curve variable importance
##
## Importance
## glucose 0.8007
## mass 0.6988
## age 0.6981
## pregnant 0.6248
## pressure 0.5995
## pedigree 0.5975
## triceps 0.5580
## insulin 0.5515
plot(varImp(my_stepglm, scale = FALSE), main="Variable Importance using GLMStepAIC")

control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_tunedpls <- train(train[,1:8], train[,9],
method = "pls",
## The default tuning grid evaluates
## components 1... tuneLength
tuneLength = 20,
trControl = control,
preProc = c("center", "scale"))
##
## Attaching package: 'pls'
## The following object is masked from 'package:caret':
##
## R2
## The following object is masked from 'package:stats':
##
## loadings
# Predict using test data
pred<-predict(my_tunedpls,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, plot variable importance
print(varImp(my_tunedpls, scale = FALSE))
## pls variable importance
##
## Overall
## glucose 0.10747
## mass 0.06288
## age 0.05595
## pregnant 0.04523
## insulin 0.03808
## pedigree 0.03186
## pressure 0.02852
## triceps 0.02400
plot(varImp(my_tunedpls, scale = FALSE), main="Variable Importance using PLS")

plot(my_tunedpls)

control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_svm <- train(train[,1:8], train[,9],
method = "svmRadial",
preProc = c("center", "scale"),
tuneLength = 14,
trControl = control)
##
## Attaching package: 'kernlab'
## The following object is masked from 'package:ggplot2':
##
## alpha
# predict using the test data
pred<-predict(my_svm,test)
## Warning in method$predict(modelFit = modelFit, newdata = newdata, submodels
## = param): kernlab class prediction calculations failed; returning NAs
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, plot variable importance
print(varImp(my_svm, scale = FALSE))
## ROC curve variable importance
##
## Importance
## glucose 0.8007
## mass 0.6988
## age 0.6981
## pregnant 0.6248
## pressure 0.5995
## pedigree 0.5975
## triceps 0.5580
## insulin 0.5515
plot(varImp(my_svm, scale = FALSE), main="Variable Importance using SVM")

summary(my_svm)
## Length Class Mode
## 1 ksvm S4
control <- trainControl(method="repeatedcv", number=10, repeats=5)
cp.grid = expand.grid( .cp = (0:10)*0.001)
my_cart <- train(train[,1:8], train[,9],
method = "rpart",
preProc = c("center", "scale"),
tuneGrid = cp.grid,
trControl = control)
# predict using the test data
pred<-predict(my_cart,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, Plot variable importance
print(varImp(my_cart, scale = FALSE))
## rpart variable importance
##
## Overall
## glucose 76.229
## mass 46.290
## age 36.060
## pregnant 16.288
## insulin 15.702
## pedigree 10.644
## pressure 5.597
## triceps 1.671
plot(varImp(my_cart, scale = FALSE),main="Variable Importance using CART")

plot(my_cart)

control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_bagged_cart <- train(train[,1:8], train[,9],
method = "treebag",
preProc = c("center", "scale"),
trControl = control)
pred<-predict(my_bagged_cart,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, Plot variable importance
print(varImp(my_bagged_cart, scale = FALSE))
## treebag variable importance
##
## Overall
## glucose 149.10
## mass 135.07
## age 105.29
## pedigree 86.96
## pressure 80.48
## pregnant 75.04
## insulin 57.93
## triceps 54.02
plot(varImp(my_bagged_cart, scale = FALSE),main="Variable Importance using Bagged CART")

control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_rf <- train(train[,1:8], train[,9],
method = "rf", ntrees = 1000,importance = TRUE,
preProc = c("center", "scale"),
trControl = control)
# Predict using the test data
pred<-predict(my_rf,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, Plot variable importance
print(varImp(my_rf, scale = FALSE))
## rf variable importance
##
## Importance
## glucose 40.311
## mass 17.218
## age 9.229
## pressure 3.869
## pregnant 2.601
## pedigree 2.223
## insulin 1.845
## triceps 1.386
plot(varImp(my_rf, scale = FALSE),main="Variable Importance using RF")

# To tune over interaction depth, number of trees, and shrinkage first define a tuning grid, then train over this grid
start.time <- Sys.time()
gbmGrid <- expand.grid(.interaction.depth = c(2,3),
.n.trees = c(100, 200),
.shrinkage = c(0.01, 0.1),
.n.minobsinnode=c(5,6))
control <- trainControl(method="repeatedcv", number=10, repeats=5)
my_boosting <- train(train[,1:8], train[,9],
method = "gbm",verbose=F,
tuneGrid = gbmGrid,
preProc = c("center", "scale"),
trControl = control)
# Predict using the test data
pred<-predict(my_boosting,test)
my_data=as.data.frame(cbind(predicted=pred,observed=test))
# Print, Plot variable importance
print(varImp(my_boosting, scale = FALSE))
## gbm variable importance
##
## Overall
## glucose 876.280
## mass 272.510
## age 178.512
## pedigree 49.120
## pregnant 15.931
## insulin 11.026
## pressure 9.334
## triceps 0.000
plot(varImp(my_boosting, scale = FALSE),main="Variable Importance using Boosting")

end.time <- Sys.time()
time.taken <- end.time - start.time
cat("Time taken = ",time.taken)
## Time taken = 42.5788
# collect resamples
results <- resamples(list(GLM=my_glm,sGLM=my_stepglm,PLS=my_tunedpls,
boosting=my_boosting, rf=my_rf, SVM=my_svm))
# summarize the distributions
summary(results)
##
## Call:
## summary.resamples(object = results)
##
## Models: GLM, sGLM, PLS, boosting, rf, SVM
## Number of resamples: 50
##
## Accuracy
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## GLM 0.5925926 0.7592593 0.7871355 0.7842824 0.8148148 0.9056604 0
## sGLM 0.6603774 0.7419192 0.7818182 0.7771191 0.8139413 0.8727273 0
## PLS 0.6981132 0.7558526 0.7924528 0.7832533 0.8173401 0.8679245 0
## boosting 0.6603774 0.7603535 0.7962963 0.7941047 0.8325472 0.9444444 0
## rf 0.6481481 0.7358491 0.7777778 0.7691922 0.8111111 0.8727273 0
## SVM 0.5849057 0.6666667 0.7037037 0.7053036 0.7512229 0.8113208 0
##
## Kappa
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## GLM 0.08474576 0.4200789 0.4902297 0.4927930 0.5704964 0.7808106 0
## sGLM 0.16029823 0.4085470 0.4902297 0.4760259 0.5521054 0.7150259 0
## PLS 0.26770294 0.4019231 0.5010288 0.4892946 0.5655608 0.6842553 0
## boosting 0.15124555 0.4377250 0.5039601 0.5106232 0.5962718 0.8732394 0
## rf 0.20588235 0.3592401 0.4859531 0.4730782 0.5545219 0.7076689 0
## SVM 0.02181208 0.1827393 0.2769626 0.2832339 0.4021327 0.5553691 0
# boxplots of results
bwplot(results)

# dot plots of results
dotplot(results)
