In R you first need to import datafile "BodyMeasures.txt", define n to represent the sample size, and group your response variables into a set using cbind.
> bodyMeasures <- read.table("/BodyMeasures.txt", header=TRUE, sep=",", na.strings="NA", dec=".")
> bodyMeasures$Ys <- with(bodyMeasures,cbind(Mass,Fore,Bicep,Chest,Neck,Shoulder,Waist,Height,Calf,Thigh,Head))
Make sure you have library MASS installed and perform a Linear Discriminant Analysis. CV=TRUE generates jacknifed (i.e., leave one out) predictions
> library(MASS)
>
fit_LDA <- lda(Sex ~ Ys, data = bodyMeasures, CV=TRUE)
> fit_LDA
>
summary(fit_LDA)
> plot(fit_LDA)
Now assess the accuracy of the prediction by testing for the percent of the cases that are classified correctly, and the total percent correct
> ct <- table(bodyMeasures$Sex, fit_LDA$class)
> diag(prop.table(ct, 1))
> sum(diag(prop.table(ct)))
Display the results of a linear classifications two variables at a time.
> install.packages("klaR")
> library(klaR)
> partimat(Sex ~ Ys, data = bodyMeasures, method="lda")
|