You are on page 1of 2

data =read.csv("datak.

csv",header=T,sep=",")

summary(data)

library(MASS)

colMeans(data)

#normalitas multivariat

X =as.matrix(data[,1:9]) # membentuk matriks n x p

center=colMeans(X) # titik pusat

n =nrow(X)

p =ncol(X)

cov =cov(X)

d =mahalanobis(X,center,cov) # Menghitung Jarak Mahalanobis

qqplot(qchisq(ppoints(n),df=p),d,main="QQ Plot untuk Data Salmon", ylab="Jarak Mahalanobis")

abline(a=0,b=1)

library(MASS)

fit =lda(Produktivitas ~ X1+X2+X3+X4+X5+X6+X7+X8+X9, data=data,na.action="na.omit")

fit =lda(Produktivitas ~ X1+X2+X3+X4+X5+X6+X7+X8+X9, data=data,na.action="na.omit",CV=T)

ct =table(data$Produktivitas, fit$class)

ct
diag(prop.table(ct, 1))

sum(diag(prop.table(ct)))