qda                   package:MASS                   R Documentation

_Q_u_a_d_r_a_t_i_c _D_i_s_c_r_i_m_i_n_a_n_t _A_n_a_l_y_s_i_s

_D_e_s_c_r_i_p_t_i_o_n:

     Quadratic discriminant analysis.

_U_s_a_g_e:

     qda(x, ...)

     ## S3 method for class 'formula':
     qda(formula, data, ..., subset, na.action)

     ## Default S3 method:
     qda(x, grouping, prior = proportions,
         method, CV = FALSE, nu, ...)

     ## S3 method for class 'data.frame':
     qda(x, ...)

     ## S3 method for class 'matrix':
     qda(x, grouping, ..., subset, na.action)

_A_r_g_u_m_e_n_t_s:

 formula: A formula of the form 'groups ~ x1 + x2 + ...'  That is, the
          response is the grouping factor and the right hand side
          specifies the (non-factor) discriminators. 

    data: Data frame from which variables specified in 'formula' are
          preferentially to be taken. 

       x: (required if no formula is given as the principal argument.)
          a matrix or data frame or Matrix containing the explanatory
          variables. 

grouping: (required if no formula principal argument is given.) a
          factor specifying the class for each observation. 

   prior: the prior probabilities of class membership.  If unspecified,
          the class proportions for the training set are used.  If
          specified, the probabilities should be specified in the order
          of the factor levels. 

  subset: An index vector specifying the cases to be used in the
          training sample.  (NOTE: If given, this argument must be
          named.) 

na.action: A function to specify the action to be taken if 'NA's are
          found. The default action is for the procedure to fail.  An
          alternative is na.omit, which leads to rejection of cases
          with missing values on any required variable.  (NOTE: If
          given, this argument must be named.) 

  method: '"moment"' for standard estimators of the mean and variance,
          '"mle"' for MLEs, '"mve"' to use 'cov.mve', or '"t"' for
          robust estimates based on a t distribution. 

      CV: If true, returns results (classes and posterior
          probabilities) for leave-out-out cross-validation. Note that
          if the prior is estimated, the proportions in the whole
          dataset are used. 

      nu: degrees of freedom for 'method = "t"'. 

     ...: arguments passed to or from other methods. 

_D_e_t_a_i_l_s:

     Uses a QR decomposition which will give an error message if the
     within-group variance is singular for any group.

_V_a_l_u_e:

     an object of class '"qda"' containing the following components:

   prior: the prior probabilities used. 

   means: the group means. 

 scaling: for each group 'i', 'scaling[,,i]' is an array which
          transforms observations so that within-groups covariance
          matrix is spherical. 

    ldet: a vector of half log determinants of the dispersion matrix. 

     lev: the levels of the grouping factor. 

   terms: (if formula is a formula) an object of mode expression and
          class term summarizing the  formula. 

    call: the (matched) function call. 

   class: The MAP classification (a factor) 

posterior: posterior probabilities for the classes 

_R_e_f_e_r_e_n_c_e_s:

     Venables, W. N. and Ripley, B. D. (2002) _Modern Applied
     Statistics with S._ Fourth edition.  Springer.

     Ripley, B. D. (1996) _Pattern Recognition and Neural Networks_.
     Cambridge University Press.

_S_e_e _A_l_s_o:

     'predict.qda', 'lda'

_E_x_a_m_p_l_e_s:

     data(iris3)
     tr <- sample(1:50, 25)
     train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3])
     test <- rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3])
     cl <- factor(c(rep("s",25), rep("c",25), rep("v",25)))
     z <- qda(train, cl)
     predict(z,test)$class

