I have run a linear discriminant function analysis using the
lda() function in the
MASS library to determine which of 6 continuous variables contribute to discrimination between 2 groups. I used a training dataset to run the model initially then predicted groups for a second test dataset with the
I would now like to know how my different variables contribute to the discrimination between groups and would like to obtain some form of significance value for the overall discriminant function.
I am able to obtain the standardized coefficients of linear discriminants that are stored as a
$scaling list component in the
lda() output. I have read that the larger the coefficient the greater the contribution of that variable to the discrimination between groups, but I am still unsure about how to interpret the values (the coefficients from my output are shown below). I would like to know whether I should leave all of the variables in the model or whether I should perform some sort of model selection, like would be undertaken with a LM or GLM? I have found a few references to the use of wilks’ lambda as a test for significance.
greedy.wilks() does give me significance values for each variable, but the retained variables strongly depend on the level for the F-test decision used (the
niveau argument) and I am unsure what is appropriate here. I would like to know i) whether a stepwise forward selection with
greedy.wilks() is advisable/good practice for LDAs, and if so how one would determine a suitable ‘niveau’ to use and ii) whether it is possible to get an overall significance value for the discriminant function. Any help with this would be really appreciated. The code that I have used so far is shown below:
#Stepwise model selection using Wilks’ lambda library(klaR) gw_obj = greedy.wilks(grp ~ V1 + V2 + V3 + V4 + V5 + V6, data=train.dat, data= train.dat, niveau= 0.5) gw_obj #LDA on training data train.lda = lda(grp ~ V1 + V2 + V3 + V4 + V5 + V6, data=train.dat, na.action="na.omit") #Standardized coefficients of linear discriminants train.lda$scaling > train.lda$scaling LD1 V1 -0.07289019 V2 -0.06077580 V3 -0.05266728 V4 -0.13991610 V5 0.12551575 V6 -0.93964824 #Applying model fit to test data testhat = predict(train.lda, newdata = test.dat)