[R] Linear Discriminant Analysis in R

Liaw, Andy andy_liaw at merck.com
Fri May 28 15:07:19 CEST 2010


cobler_squad needs more basic help than doing lda.  The data input just
doesn't make sense.   

If vowel_feature is a data frame, than G <- vowel_feature[15] creates
another data frame containing the 15th variable in vowel_feature, so "G"
is the name of a data frame, not a variable in a data frame.  The lda()
call makes even less sense.  I wonder if he had tried to go through the
examples in the help file and try to understand how it is used?

Andy

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Joris Meys
> Sent: Friday, May 28, 2010 8:50 AM
> To: cobbler_squad
> Cc: r-help at r-project.org
> Subject: Re: [R] Linear Discriminant Analysis in R
> 
> Could you provide us with data to test the code? use dput 
> (and limit the
> size!!!!!)
> 
> eg:
> dput(vowel_features)
> dput(mask_features)
> 
> Without this information, it's impossible to say what's going 
> wrong. It looks like you're doing something wrong in the 
> selection. What should vowel_features[15] return? Did you 
> check it's actually what you want? Did you use str(G) to 
> check the type?
> 
> Cheers
> Joris
> 
> On Thu, May 27, 2010 at 5:28 PM, cobbler_squad 
> <la.foma at gmail.com> wrote:
> 
> >
> > Joris,
> >
> > You are a life saver. Based on two sample files above, I think lda 
> > should go something like this:
> >
> > vowel_features <- read.table(file = "mappings_for_vowels.txt") 
> > mask_features <- data.frame(as.matrix(read.table(file =
> > "3dmaskdump_ICA_37_Combined.txt")))
> > G <- vowel_features[15]
> >
> > cvc_lda <- lda(G~ vowel_features[15], data=mask_features, 
> > na.action="na.omit", CV=TRUE)
> >
> > ERROR: Error in model.frame.default(formula = G ~ 
> vowel_features[15], 
> > data = mask_features,  :
> >  invalid type (list) for variable 'G'
> >
> > I am clearly doing something wrong declaring G (how should 
> I declare 
> > grouping in R when I need to use one column from 
> vowel_feature file)? 
> > Sorry for stupid questions and thank you for being so helpful!
> >
> > ---------
> > again, sample files that I am working with:
> >
> > mappings_for_vowels.txt:
> >
> >    V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 
> V17 V18 V19 
> > V20
> > V21 V22 V23 V24 V25 V26
> > 1    E  0  0  0  0  0  0  0  0   0   0   0   0   1   1   0  
>  0   0   1   0
> > 0   0   0   0   0   0
> > 2    o  0  0  0  0  0  0  0  0   0   0   0   0   1   0   0  
>  1   0   1   0
> > 1   0   1   0   0   0
> > 3    I  0  0  0  0  0  0  0  0   0   0   0   0   1   1   0  
>  0   1   0   0
> > 0   0   0   0   0   0
> > 4    ^  0  0  0  0  0  0  0  0   0   0   0   0   1   0   1  
>  0   0   1   0
> > 0   0   0   0   0   0
> > 5    @  0  0  0  0  0  0  0  0   0   0   0   0   1   0   0  
>  1   0   0   1
> > 0   0   0   0   0   0
> >
> > and the mask_features file is:
> >
> >              V42          V43          V44          V45          V46
> > V47          V48          V49
> >  [1,]  2.890891625  2.881188521  2.887784444 -2.882606612 
> -2.888877341
> > 2.879834384  2.886483229  2.883815864
> >  [2,]  2.763404707  2.756198683  2.761863881 -2.756827983 
> -2.762268531
> > 2.754305072  2.760017050  2.758399799
> >  [3,]  0.556614506  0.556377530  0.556247414 -0.556300910 
> -0.556098321 
> > 0.557495060  0.557383073  0.556867424  [4,]  0.367065248  
> 0.366962036  
> > 0.366870087 -0.366794442 -0.366644148
> > 0.366613343  0.366537320  0.366953464
> >  [5,]  0.423692393  0.421835623  0.421741829 -0.421897460 
> -0.421659824
> > 0.421567705  0.421465738  0.422407838
> >
> > --
> > View this message in context:
> > 
> http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231
> > 922p2233333.html Sent from the R help mailing list archive at 
> > Nabble.com.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > 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.
> >
> 
> 
> 
> --
> Joris Meys
> Statistical Consultant
> 
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
> 
> Coupure Links 653
> B-9000 Gent
> 
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}



More information about the R-help mailing list