classplot                package:emu                R Documentation

_P_r_o_d_u_c_e _a _c_l_a_s_s_i_f_i_c_a_t_i_o_n _p_l_o_t _f_r_o_m _d_i_s_c_r_i_m_i_n_a_n_t _o_r _S_V_M _m_o_d_e_l_l_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     The function classifies all point specified within the ranges of
     xlim and ylim based on the training model specified in model. It
     then produces a two-dimensional plot colour-coded for
     classifications.

_U_s_a_g_e:

              classplot(model, xlim, ylim, N = 100, pch = 15, col = NULL, legend = TRUE,  position = "topright", bg = "gray90", ...) 
               

_A_r_g_u_m_e_n_t_s:

   model: A two-dimensional training model output from qda(), lda() of
          MASS package , or svm() of e1071 package 

    xlim: A vector of two numeric elements specifying the range on the
          x-axis  (parameter 1) over which classifications should be
          made 

    ylim: A vector of two elements specifying the range on the y-axis
          (parameter 2) over  which classifications should be made 

       N: A vector of one numeric element which specifies the density
          of classification  (greater N gives higher density). The
          default is 100. 

     pch: A single element numeric vector specifying the plotting
          symbol to be used in the classification plot. Defaults to 15.

     col: Either Null in which case the colours for the separate
          classes are col = c(1, 2, ...n) where n is the number of
          classes; or else a vector specifying the desired colours that
          is the same length as there are classes.

  legend: A single element logical vector specifying whether a legend
          should be drawn. Defaults to T

position: A single element vector specifying the position in the figure
          where the legend should be drawn. Defaults to "topright"

      bg: A single element vector specifying the background colour on
          which the legend should be drawn.

     ...: Further arguments to plot.

_A_u_t_h_o_r(_s):

     Jonathan Harrington

_S_e_e _A_l_s_o:

     'qda', 'lda', svm of e1071 package. There is a function plot.svm
     which produces a prettier plot for SVMs.

_E_x_a_m_p_l_e_s:

     library(MASS)
     # Data from female speaker 68
     temp = vowlax.spkr=="68"
     # Quadratic discriminant analysis
     fm.qda = qda(vowlax.fdat.5[temp,1:2], vowlax.l[temp])
     # Linear discriminant analysis
     fm.lda = lda(vowlax.fdat.5[temp,1:2], vowlax.l[temp])

     xlim=c(0,1000)
     ylim=c(0,3000)

     par(mfrow=c(1,2))
     classplot(fm.qda, xlim=xlim, ylim=ylim, main="QDA")
     classplot(fm.lda, xlim=xlim, ylim=ylim, main="LDA")

     # install.packages("e1071")
     # library(e1071)
     # Support vector machine
     ## Not run: fm.svm = svm(vowlax.fdat.5[temp,1:2], factor(vowlax.l[temp]))
     ## Not run: xlim = range(vowlax.fdat.5[temp,1])
     ## Not run: ylim = range(vowlax.fdat.5[temp,2])
     ## Not run: classplot(fm.svm, xlim=xlim, ylim=ylim, xlab="F1", ylab="F2", main="SVM")          

