princomp                 package:mva                 R Documentation

_P_r_i_n_c_i_p_a_l _C_o_m_p_o_n_e_n_t_s _A_n_a_l_y_s_i_s

_D_e_s_c_r_i_p_t_i_o_n:

     `princomp' performs a principal components analysis on the given
     data matrix and returns the results as an object of class
     `princomp'.

     `loadings' extracts the loadings.

     `screeplot' plots the variances against the number of the
     principal component. This is also the `plot' method.

_U_s_a_g_e:

     princomp(x, cor = FALSE, scores = TRUE, covmat = NULL,
              subset = rep(TRUE, nrow(as.matrix(x))))
     loadings(x)

     screeplot(x, npcs = min(10, length(x$sdev)),
               type = c("barplot", "lines"), main = deparse(substitute(x)), ...)
     plot(x, ...)
     print(x, ...)  summary(object)  predict(object, ...)

_A_r_g_u_m_e_n_t_s:

       x: a matrix (or data frame) which provides the data for the
          principal components analysis.

     cor: a logical value indicating whether the calculation should use
          the correlation matrix or the covariance matrix.

  scores: a logical value indicating whether the score on each
          principal component should be calculated.

  covmat: a covariance matrix, or a covariance list as returned by
          `cov.wt', `cov.mve' or `cov.mcd'. If supplied, this is used
          rather than the covariance matrix of `x'.

  subset: a vector used to select rows (observations) of the data
          matrix `x'.

x, object: an object of class `"princomp"', as from `princomp()'.

    npcs: the number of principal components to be plotted.

    type: the type of plot.

     ...: graphics parameters.

_D_e_t_a_i_l_s:

     The calculation is done using `eigen' on the correlation or
     covariance matrix, as determined by `cor'.  This is done for
     compatibility with the S-PLUS result.  A preferred method of
     calculation is to use svd on `x', as is done in `prcomp'.

     Note that the default calculation uses divisor `N' for the
     covariance matrix.

     The `print' method for the these objects prints the results in a
     nice format and the `plot' method produces a scree plot.

_V_a_l_u_e:

     `princomp' returns a list with class `"princomp"' containing the
     following components: 

    sdev: the standard deviations of the principal components.

loadings: the matrix of variable loadings (i.e., a matrix whose columns
          contain the eigenvectors).

  center: the means that were subtracted.

   scale: the scalings applied to each variable.

   n.obs: the number of observations.

  scores: if `scores = TRUE', the scores of the supplied data on the
          principal components.

    call: the matched call.

_R_e_f_e_r_e_n_c_e_s:

     Mardia, K. V., J. T. Kent and J. M. Bibby (1979). Multivariate
     Analysis, London: Academic Press.

     Venables, W. N. and B. D. Ripley (1997, 9). Modern Applied
     Statistics with S-PLUS, Springer-Verlag.

_S_e_e _A_l_s_o:

     `prcomp', `cor', `cov', `eigen'.

_E_x_a_m_p_l_e_s:

     ## The variances of the variables in the
     ## USArrests data vary by orders of magnitude, so scaling is appropriate
     data(USArrests)
     (pc.cr <- princomp(USArrests))  # inappropriate
     princomp(USArrests, cor = TRUE) # =^= prcomp(USArrests, scale=TRUE)
     ## Similar, but different:
     ## The standard deviations differ by a factor of sqrt(49/50)

     summary(pc.cr <- princomp(USArrests, cor=TRUE))
     loadings(pc.cr)
     plot(pc.cr) # does a screeplot.
     biplot(pc.cr)

