I am using a discriminant function analysis to see which environmental variables best discriminate my study wetlands into those occupied by a species and those not occupied.

I have 23 wetlands and 11 environmental variables and am interested in distinguishing two groups: occupied wetlands vs unoccupied wetlands. I am using R and the MASS package function lda().

Because I am only interested in two groups, only one linear discriminant function is produced. I am therefore interested to know what the appropriate way to graph the data is?

I am able to produce both a scatter plot or a histogram (see below). I would prefer the scatter plot but then this is LD1 plotted against an arbitrary x-axis (essential the x-axis goes from 1 to 23 (my number of sites), the y-axis is the range of the discriminant function values, and then the first site is assigned to x=1 and its discriminant function value is plotted). Is it therefore not appropriate to use a scatter plot in this situation? I assume also in this case then you cannot calculate a 95% confidence interval ellipse...?

#code for my discriminant analysis
hab.lda <- lda(grp ~ ., data=hab_std)

hab.lda.values <- predict(hab.lda, hab_std)
hab.class <- predict(hab.lda)$class

#create a histogram of the discriminant function values
ldahist(data = hab.lda.values$x[,1], g=grp)

#create a scatterplot of the discriminant function values
plot(hab.lda.values$x[,1], type="n", xlim=c(0,30), ylab=c("LDA Axis 1"))
text(hab.lda.values$x[,1], row.names(hab_std),  col=c(as.numeric(hab.class)+10))
abline(v=0, lty="dotted")
abline(h=0, lty="dotted")

I have spent a lot of time searching for an answer online and in the literature but have found no satisfying answer. Thus advice on the correct way to plot the data would be greatly appreciated!

Here are the pictures of the a) scatterplot b) histogram

enter image description here

enter image description here

  • $\begingroup$ It'd be helpful if you could post your plots. $\endgroup$
    – Pete
    Commented Mar 26, 2015 at 16:52
  • $\begingroup$ Okay, they are now added to the post. $\endgroup$
    – tsms
    Commented Mar 27, 2015 at 20:17

1 Answer 1


I think a single density plot with both "occupied" and "unoccupied" and alpha-blending (overlap) would be best. See this question on how to do it. (You might like to give ggplot a try, but there is also an option in base-R.) If you go with a histogram instead of a density plot, I would also use a wider bin-width since you have a lot of single count bins.

The scatterplot can be deceiving because by reordering the data, you can get a very different looking plot.

The confidence interval "ellipse" in the 1-D case is just, well, a 1-D confidence interval.

  • $\begingroup$ That makes a lot of sense, thank-you for the suggestion! One more question, if you have the time: how does the function come up with the frequencies, i.e. why is my y-axis from 0-1? I would think since I have such small bins, only 1 or 2 sites would have a discriminant function value in that range and thus the y-axis run from like 1 to 3. $\endgroup$
    – tsms
    Commented Apr 1, 2015 at 11:45
  • $\begingroup$ Ohhh... wait: is this a correct explanation: geog.ucsb.edu/~joel/g210_w07/lecture_notes/lect04/… $\endgroup$
    – tsms
    Commented Apr 1, 2015 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.