I have three classes with mean
mu1 <- matrix(c(3, 1), nrow=2)
mu2 <- matrix(c(4, 3), nrow=2)
mu3 <- matrix(c(8, 2), nrow=2)
and covariance
cov <- matrix(c(.5, .3, .3, .5), nrow=2, ncol=2)
I would like to simulate about 100 observations from each class and perform LDA. first, I made three matrix with 100 observations.
x1 <- matrix(c(rmvnorm(100, mean=mu1, sigma=cov), matrix("x1", ncol=1, nrow=100)), ncol=3)
x2 <-matrix(c(rmvnorm(100, mean=mu2, sigma=cov), matrix("x2", ncol=1, nrow=100)), ncol=3)
x3 <- matrix(c(rmvnorm(100, mean=mu3, sigma=cov), matrix("x3", ncol=1, nrow=100)), ncol=3)
and made those to data frame and bind it together.
d1 <- data.frame(x1)
d2 <- data.frame(x2)
d3 <- data.frame(x3)
alld <- rbind(d1, d2, d3)
now I would like to perform lda with code of
lda.x1 <- lda(alld[,3]~alld[,1]+alld[,2], data=alld)
here... I got warning message and weird result. please help me out Thank you