Songer, Katherine B - DNR
2011-May-16 20:07 UTC
[R] Linear Discriminant Analysis error: "Variables appear constant"
Hi R experts, I'm attempting to run Linear Discriminant Analysis using the lda function in the MASS package. I've got around 50 predictor variables and one response variable. My response variable has 5 numeric categories that represent different clusters of fish abundance data (clusters were developed using Bray-Curtis and NMDS), and my predictor variables are environmental variables that might influence the fish data. These data all came from 68 sampling locations. I'm getting an error message:>DALogFish<-lda(Cluster~DrainArea+Flow+StrmWidth+Gradient+NatComm+FishIBIUsed+QHEI+QHEIsub+QHEImwh_h+QHEIcov+QHEIchan+QHEIrip+QHEIpool+QHEIrif+QHEIgrads+ QHEIgradv+QHEImwh+QHEIcovtype+QHEIwwh+QHab+QHabBuff+QHabEros+QhabPool+ QHabWDRatio+QHabRif+QHabFines+QHabCov+QHabRating+QHabSize+TP+TKN+NH3+NH3Min +NO3NO2N+BOD+TSS+TSSMax+TDS+SSC+SSCMax+Chloride+Sulfate+Ecoli+ChlA+DOper+ DOperMin+DOperMin1_5+DOmgL+DOmgLMean+DOmgLMax+Cond+pH+pHMax+Trans+Temp+ TempMin+Temp4+Crop100+Crop500+CropSub+Dev100+Dev500+DevSub+For100+For500+ ForSub+Pas100+Pas500+PasSub+Wat100+Wat500+WatSub+Wet100+Wet500+WetSub+ Undev100+Undev500+UndevTotal+Undev100NoPas+Undev500NoPas+UndevTotNoPas, data=AllData1, na.action="na.omit", CV=TRUE) Error in lda.default(x, grouping, ...) : variables 10 38 42 appear to be constant within groups When I look at the variables listed, they don't appear "constant within the groups" to me. I'm new to LDA and am wondering what this error means... Are my data somehow not in the right format? Should I remove colinear variables? (All variables have been normalized.) Thanks very much! Katie [[alternative HTML version deleted]]
Uwe Ligges
2011-May-17 09:24 UTC
[R] Linear Discriminant Analysis error: "Variables appear constant"
On 16.05.2011 22:07, Songer, Katherine B - DNR wrote:> Hi R experts, > > I'm attempting to run Linear Discriminant Analysis using the lda function in the MASS package. I've got around 50 predictor variables and one response variable. My response variable has 5 numeric categories that represent different clusters of fish abundance data (clusters were developed using Bray-Curtis and NMDS), and my predictor variables are environmental variables that might influence the fish data. These data all came from 68 sampling locations. > > I'm getting an error message: > >> DALogFish<-lda(Cluster~DrainArea+Flow+StrmWidth+Gradient+NatComm+FishIBIUsed > +QHEI+QHEIsub+QHEImwh_h+QHEIcov+QHEIchan+QHEIrip+QHEIpool+QHEIrif+QHEIgrads+ > QHEIgradv+QHEImwh+QHEIcovtype+QHEIwwh+QHab+QHabBuff+QHabEros+QhabPool+ > QHabWDRatio+QHabRif+QHabFines+QHabCov+QHabRating+QHabSize+TP+TKN+NH3+NH3Min > +NO3NO2N+BOD+TSS+TSSMax+TDS+SSC+SSCMax+Chloride+Sulfate+Ecoli+ChlA+DOper+ > DOperMin+DOperMin1_5+DOmgL+DOmgLMean+DOmgLMax+Cond+pH+pHMax+Trans+Temp+ > TempMin+Temp4+Crop100+Crop500+CropSub+Dev100+Dev500+DevSub+For100+For500+ > ForSub+Pas100+Pas500+PasSub+Wat100+Wat500+WatSub+Wet100+Wet500+WetSub+ > Undev100+Undev500+UndevTotal+Undev100NoPas+Undev500NoPas+UndevTotNoPas, > data=AllData1, na.action="na.omit", CV=TRUE) > > Error in lda.default(x, grouping, ...) : > variables 10 38 42 appear to be constant within groups > > When I look at the variables listed, they don't appear "constant within the groups" to me.We do not know, since we do not have the data.>I'm new to LDA and am wondering what this error means... Are my data somehow not in the right format? Should I remove colinear variables? (All variables have been normalized.)Yes, colinear variables should be removed. Note als, that you have roughly as many (or even more) variables in the model than observations. This won't work either. I think you should read some textbook on the mechanisms behind an LDA. Uwe Ligges> > Thanks very much! > Katie > > > > [[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.