

qda(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(formula, data, prior = proportions, subset,
                        na.action = na.fail, method, CV = FALSE, nu)
     qda(x,   grouping, prior = proportions, subset,
                        na.action = na.fail, method, CV = FALSE, nu)

_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 `for-
          mula' are preferentially to be taken.

       x: (required if no formula is given as the principal
          argument.)  a matrix or data frame or Matrix con-
          taining 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 train-
          ing 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 argu-
          ment 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 propor-
          tions in the whole dataset are used.

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

_D_e_t_a_i_l_s_:

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

_V_a_l_u_e_:

     an object of class qda containing the following compo-
     nents:

   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 disper-
          sion matrix.

     lev: the levels of the grouping factor.

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

    call: the (matched) function call.

   class: The MAP classification (a factor)

posterior: posterior probabilities for the classes

_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

