predict.lda               package:MASS               R Documentation

_C_l_a_s_s_i_f_y _M_u_l_t_i_v_a_r_i_a_t_e _O_b_s_e_r_v_a_t_i_o_n_s _b_y _L_i_n_e_a_r _D_i_s_c_r_i_m_i_n_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Classify multivariate observations in conjunction with 'lda', and
     also project data onto the linear discriminants.

_U_s_a_g_e:

     ## S3 method for class 'lda':
     predict(object, newdata, prior = object$prior, dimen,
             method = c("plug-in", "predictive", "debiased"), ...)

_A_r_g_u_m_e_n_t_s:

  object: object  of class '"lda"' 

 newdata: data frame of cases to be classified or, if 'object' has a
          formula, a data frame with columns of the same names as the
          variables used.  A vector will be interpreted as a row
          vector.  If newdata is missing, an attempt will be made to
          retrieve the data used to fit the 'lda' object. 

   prior: The prior probabilities of the classes, by default the
          proportions in the training set or what was set in the call
          to 'lda'. 

   dimen: the dimension of the space to be used. If this is less than
          'min(p, ng-1)', only the first 'dimen' discriminant
          components are used (except for 'method="predictive"'), and
          only those dimensions are returned in 'x'. 

  method: This determines how the parameter estimation is handled. With
          '"plug-in"' (the default) the usual unbiased parameter
          estimates are used and assumed to be correct. With
          '"debiased"' an unbiased estimator of the log posterior
          probabilities is used, and with '"predictive"' the parameter
          estimates are integrated out using a vague prior. 

     ...: arguments based from or to other methods 

_D_e_t_a_i_l_s:

     This function is a method for the generic function 'predict()' for
     class '"lda"'.  It can be invoked by calling 'predict(x)' for an
     object 'x' of the appropriate class, or directly by calling
     'predict.lda(x)' regardless of the class of the object.

     Missing values in 'newdata' are handled by returning 'NA' if the
     linear discriminants cannot be evaluated. If 'newdata' is omitted
     and the 'na.action' of the fit omitted cases, these will be
     omitted on the prediction.

     This version centres the linear discriminants so that the weighted
     mean (weighted by 'prior') of the group centroids is at the
     origin.

_V_a_l_u_e:

     a list with components

   class: The MAP classification (a factor) 

posterior: posterior probabilities for the classes 

       x: the scores of test cases on up to 'dimen' discriminant
          variables 

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

     'lda', 'qda', 'predict.qda'

_E_x_a_m_p_l_e_s:

     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 <- lda(train, cl)
     predict(z, test)$class

