File: pc1.Rd

package info (click to toggle)
hmisc 4.2-0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,332 kB
  • sloc: asm: 27,116; fortran: 606; ansic: 411; xml: 160; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
\name{pc1}
\alias{pc1}
\title{First Principal Component}
\description{
Given a numeric matrix which may or may not contain \code{NA}s,
\code{pc1} standardizes the columns to have mean 0 and variance 1 and
computes the first principal component using \code{\link{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.
}
\usage{
pc1(x, hi)
}
\arguments{
  \item{x}{numeric matrix}
  \item{hi}{if specified, the first PC is scaled so that its maximum
	value is \code{hi} and its minimum value is zero}
}
\value{
  The vector of observations with the first PC.  An attribute
  \code{"coef"} is attached to this vector.  \code{"coef"} contains the
  raw-variable coefficients.
  }
\author{Frank Harrell}
\seealso{\code{\link{prcomp}}}
\examples{
set.seed(1)
x1 <- rnorm(100)
x2 <- x1 + rnorm(100)
w <- pc1(cbind(x1,x2))
attr(w,'coef')
}
\keyword{multivariate}