set.seed(12)
df <- read.csv("diabetes.csv")
head(df)
sample.data<-sample.int(nrow(df), floor(.50*nrow(df)), replace = F)
train<-df[sample.data, ]
test<-df[-sample.data, ]

Try to predict glucose from the other columns

## Warning: Removed 7 rows containing missing values (`geom_point()`).

## Warning: Removed 3 rows containing missing values (`geom_point()`).

## Warning: Removed 3 rows containing missing values (`geom_point()`).

Make a new column to determine diabetes or not and then do boxplots

train$diabetes<-ifelse(train$glyhb>6.5, 1, 0)
train$diabetes<-as.factor(train$diabetes)
df1<-train[!is.na(train$glyhb),]
ggplot2::ggplot(df1, aes(x=diabetes, y=chol))+geom_boxplot()

  labs(x="diabetes", y="chol")
## $x
## [1] "diabetes"
## 
## $y
## [1] "chol"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=stab.glu))+geom_boxplot()

  labs(x="diabetes", y="stab.glu")
## $x
## [1] "diabetes"
## 
## $y
## [1] "stab.glu"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=hdl))+geom_boxplot()

  labs(x="diabetes", y="hdl")
## $x
## [1] "diabetes"
## 
## $y
## [1] "hdl"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=ratio))+geom_boxplot()

  labs(x="diabetes", y="ratio")
## $x
## [1] "diabetes"
## 
## $y
## [1] "ratio"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=height))+geom_boxplot()
## Warning: Removed 2 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="height")
## $x
## [1] "diabetes"
## 
## $y
## [1] "height"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=weight))+geom_boxplot()

  labs(x="diabetes", y="weight")
## $x
## [1] "diabetes"
## 
## $y
## [1] "weight"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=bp.1s))+geom_boxplot()
## Warning: Removed 3 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="bp.1s")
## $x
## [1] "diabetes"
## 
## $y
## [1] "bp.1s"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=bp.1d))+geom_boxplot()
## Warning: Removed 3 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="bp.1d")
## $x
## [1] "diabetes"
## 
## $y
## [1] "bp.1d"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=bp.2s))+geom_boxplot()
## Warning: Removed 122 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="bp.2s")
## $x
## [1] "diabetes"
## 
## $y
## [1] "bp.2s"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=bp.2d))+geom_boxplot()
## Warning: Removed 122 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="bp.2d")
## $x
## [1] "diabetes"
## 
## $y
## [1] "bp.2d"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=waist))+geom_boxplot()
## Warning: Removed 1 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="waist")
## $x
## [1] "diabetes"
## 
## $y
## [1] "waist"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=hip))+geom_boxplot()
## Warning: Removed 1 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="hip")
## $x
## [1] "diabetes"
## 
## $y
## [1] "hip"
## 
## attr(,"class")
## [1] "labels"
ggplot2::ggplot(df1, aes(x=diabetes, y=time.ppn))+geom_boxplot()
## Warning: Removed 1 rows containing non-finite values (`stat_boxplot()`).

  labs(x="diabetes", y="time.ppn")
## $x
## [1] "diabetes"
## 
## $y
## [1] "time.ppn"
## 
## attr(,"class")
## [1] "labels"
library(MASS) ##for lda function
library(klaR) ##for partimat function to produce 2-D partition plots
library(ICS) ##for multivariate normality tests
## Loading required package: mvtnorm
set.seed(12)
## Carry out LDA on training data
lda.dia <- MASS::lda(diabetes ~ ., data=train)
## Obtain ouput from LDA
lda.dia
## Call:
## lda(diabetes ~ ., data = train)
## 
## Prior probabilities of groups:
##         0         1 
## 0.8169014 0.1830986 
## 
## Group means:
##         id     chol  stab.glu      hdl    ratio     glyhb locationLouisa
## 0 18956.03 211.0000  94.51724 52.77586 4.360345  4.698793      0.6379310
## 1 14739.62 269.9231 194.53846 44.07692 6.669231 10.166154      0.4615385
##        age gendermale   height   weight framelarge framemedium framesmall
## 0 47.48276  0.4827586 65.82759 182.3621  0.1896552   0.5517241  0.2068966
## 1 61.84615  0.4615385 66.69231 190.6923  0.3846154   0.5384615  0.0000000
##      bp.1s    bp.1d    bp.2s    bp.2d    waist      hip time.ppn
## 0 156.6034 96.18966 154.0517 93.84483 38.72414 43.62069 249.1379
## 1 163.5385 92.07692 158.3846 91.07692 41.15385 44.76923 310.3846
## 
## Coefficients of linear discriminants:
##                          LD1
## id             -0.0000131922
## chol            0.0062459949
## stab.glu       -0.0102640134
## hdl            -0.0311011385
## ratio          -0.3959947686
## glyhb           1.0892613534
## locationLouisa  0.4820219485
## age             0.0029934818
## gendermale     -0.3476056436
## height          0.0553756283
## weight         -0.0098487545
## framelarge     -0.7259419598
## framemedium    -1.5583054564
## framesmall     -1.5330626179
## bp.1s           0.0049969093
## bp.1d           0.0149080103
## bp.2s          -0.0030227078
## bp.2d          -0.0146735252
## waist           0.0478996942
## hip             0.0028482749
## time.ppn        0.0007788277