[R] Picking Best Discriminant Function Variables

David L Carlson dcarlson at tamu.edu
Mon Feb 16 16:27:49 CET 2015


Look at the function stepclass() in package klaR.

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of David Moskowitz
Sent: Sunday, February 15, 2015 11:34 AM
To: n omranian via R-help
Subject: [R] Picking Best Discriminant Function Variables

Is there a way to have the LDA function give me the best 3 (or 4)  predictor variables.  When I put in all the variables, LDA uses all the variables, but I would like to know what would be the 3 (or 4) best to use out all the available variables and the coefficients for those.




Here is the code I am using for Linear Discriminant Function

library("MASS") 



results <- lda(data$V1 ~ data$V2 + data$V3 + data$V4 + data$V5 + data$V6 + data$V7 + data$V8 + data$V9 + data$V10 + data$V11 + data$V12 + data$V13 + data$V14)



Output:

Coefficients of linear discriminants:
                    LD1                   LD2
data$V2 -0.403399781    0.8717930699
data$V3 0.165254596     0.3053797325
data$V4 -0.369075256    2.3458497486
data$V5 0.154797889     -0.1463807654
data$V6 -0.002163496    -0.0004627565
data$V7 0.618052068     -0.0322128171
data$V8 -1.661191235   -0.4919980543
data$V9 -1.495818440   -1.6309537953
data$V10 0.134092628   -0.3070875776
data$V11 0.355055710    0.2532306865
data$V12 -0.818036073    -1.5156344987
data$V13 -1.157559376    0.0511839665
data$V14 -0.002691206    0.0028529846




So in the above example, I would like the LDA to return to me the 3 best predictors out of the 13 available.


Thank you
	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list