Thursday, 15 April 2010

How can I plot a biplot for LDA in r? -


I have done a linear discrimination analysis using the package code lda () I will try to plot a Baplot in the ADE4 package (LLA). Do you know how I can do this?

If I try to use the biplot () function, then it does not work. For example, if I use Iris data and creates an LDA:

  dis2 < - lda (as.matrix (iris [, 1: 4]), iris $ species   

then I can plot it using the function plot () But if I use the function biplot () then it does not work:

  error in biplot (dis2) nrow (y): no default Logic "y" is unavailable with   

How can I plot the arrow arrow?

I wrote the following function to do this:

  lda.arrows & lt; -function (x, myscale = 1, tex = 0.75, option = C (1,2), ...) {# # 'BipLot' arrows for an LDA Adds the principal of the discriminating work values; - Coff (x) arrows (x0 = 0, y0 = 0, x1 = myscale * head [, option [1]], y1 = myscale * head [, option [2]] , .. For your example:  
  dis2 <- lda ( As.matrix (Iris [, 1: 4]), Iris $ species) Plot (D2, ASP = 1) lda.arrows (dis2, col = 2, myscale = 2)   

Length of arrows in the LDA plot Tabik arbitrary (but of course, not to each other!). If you want long or short arrows, change the value of myscale accordingly. By default, this plot arrow for the first and second axes. If you want to plot other axes, change options to change it.

No comments:

Post a Comment