pc1                  package:Hmisc                  R Documentation

_F_i_r_s_t _P_r_i_n_c_i_p_a_l _C_o_m_p_o_n_e_n_t

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

     Given a numeric matrix which may or may not contain 'NA's, 'pc1'
     standardizes the columns to have mean 0 and variance 1 and
     computes the first principal component using 'prcomp'.  The
     proportion of variance explained by this component is printed, and
     so are the coefficients of the original (not scaled) variables. 
     These coefficients may be applied to the raw data to obtain the
     first PC.

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

     pc1(x, hi)

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

       x: numeric matrix

      hi: if specified, the first PC is scaled so that its maximum
          value is 'hi' and its minimum value is zero

_V_a_l_u_e:

     The vector of observations with the first PC.  An attribute
     '"coef"' is attached to this vector.  '"coef"' contains the
     raw-variable coefficients.

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

     Frank Harrell

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

     'prcomp'

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

     set.seed(1)
     x1 <- rnorm(100)
     x2 <- x1 + rnorm(100)
     w <- pc1(cbind(x1,x2))
     attr(w,'coef')

