principal.curve {princurve} | R Documentation |
Fits a principal curve which describes a
smooth curve that passes through the middle
of the data x
in
an orthogonal sense. This curve is a nonparametric generalization of a
linear principal component. If a closed curve is fit (using
smoother = "periodic.lowess"
) then the starting curve defaults to
a circle, and each fit is followed by a bias correction suggested by
J. Banfield.
principal.curve(x, start=NULL, thresh=0.001, plot.true=FALSE, maxit=10, stretch=2, smoother="smooth.spline", trace=FALSE, ...)
x |
a matrix of points in arbitrary dimension |
start |
either a previously fit principal curve, or else a matrix
of points that in row order define a starting curve. If missing, then
the first principal component is used. If the smoother is
"periodic.lowess" , then a circle is used as the start. |
thresh |
convergence threshold on shortest distances to the curve. |
plot.true |
If TRUE the iterations are plotted. |
maxit |
maximum number of iterations. |
stretch |
a factor by which the curve can be extrapolated when
points are projected. Default is 2 (times the last segment
length). The default is 0 for smoother equal to
"periodic.lowess" . |
smoother |
choice of smoother. The default is
"smooth.spline" , and other choices are "lowess" and
"periodic.lowess" . The latter allows one to fit closed curves.
Beware, you may want to use iter = 0 with lowess() . |
trace |
If TRUE , the iteration information is printed |
... |
additional arguments to the smoothers |
An object of class "principal.curve"
is returned. For this object
the following generic methods a currently available: plot, points,
lines
.
It has components:
s |
a matrix corresponding to x , giving their projections
onto the curve. |
tag |
an index, such that s[tag, ] is smooth. |
lambda |
for each point, its arc-length from the beginning of the
curve. The curve is parametrized approximately by arc-length, and
hence is unit-speed . |
dist |
the sum-of-squared distances from the points to their projections. |
call |
the call that created this object; allows it to be
updated() . |
``Principal Curves'' by Hastie, T. and Stuetzle, W. 1989, JASA. See also Banfield and Raftery (JASA, 1992).
x <- runif(100,-1,1); x <- cbind(x, x^2+rnorm(100,sd=0.1)) fit1 <- principal.curve(x, plot = TRUE) fit2 <- principal.curve(x, plot = TRUE, smooth = "lowess", iter=0) lines(fit1); points(fit1) plot(fit1); whiskers(x, fit1$s)