0

I was trying to run the Mixture Discrimination Analysis with the "mda" package in R. However, when I followed the manual and ran the following script. I realized that the result was not unique:

library(mda) data(iris) irisfit <- mda(Species ~ ., data = iris) irisfit

The result sometimes look like this:

Call: mda(formula = Species ~ ., data = iris)

Dimension: 4

Percent Between-Group Variance Explained: v1 v2 v3 v4 95.06 97.78 99.59 100.00

Degrees of Freedom (per dimension): 5

Training Misclassification Error: 0.01333 ( N = 150 )

Deviance: 13.302

And sometimes like this:

Call: mda(formula = Species ~ ., data = iris)

Dimension: 5

Percent Between-Group Variance Explained: v1 v2 v3 v4 v5 96.14 98.47 99.89 100.00 100.00

Degrees of Freedom (per dimension): 5

Training Misclassification Error: 0.02 ( N = 150 )

Deviance: 15.249

I have tried it on different workstations and different R versions, but the situation stayed the same. So it should not be the system's problem.

As far as I understood, how the MDA was been performed should lead to a unique result. Do anyone might have an idea on how could this happened?

Cheng
  • 1
  • 1
  • 1
    using `set.seed(12345)` in your code should fix the problem. Here is a much better explaination than I could give you: https://stackoverflow.com/questions/13605271/reasons-for-using-the-set-seed-function ` – heck1 Mar 05 '19 at 10:14
  • As far as I know MDA is not deterministic, which means it's expected to have different results with each run (except of course if you use `set.seed` as indicated in the comment by @heck1 – DS_UNI Mar 05 '19 at 10:32
  • I have tried the `set.seed` function. However, the situation stayed the same, that the result is still not unique. According to how MDA was calculated, it fit the data into the Gaussian distribution, and there was no random number/random noise been generated/added, so I don't really understand that why the result is not unique...? – Cheng Mar 05 '19 at 14:42

0 Answers0