Learn R Programming

LPCM (version 0.43)

lpc: Local principal curves

Description

This is the main function which computes the actual local principal curve, i.e. a sequence of local centers of mass.

Usage

lpc(X, h, t0 = mean(h),  x0,  mult = 1, way = "two",  scaled = TRUE,
      weights=1, pen = 2, depth = 1, control=lpc.control())

Arguments

X
data matrix with $N$ rows (observations) and $d$ columns (variables).
h
bandwidth. May be either specified as a single number, then the same bandwidth is used in all dimensions, or as a d-dimensional bandwidth vector. The default setting is 10 percent of the range in each direction. If scaled =TRUE then
t0
scalar step length. Default setting is t0=h, if h is a scalar, and t0=mean(h), if h is a vector.
x0
optionally, one can set one or more starting points here. This can be done in form of a matrix, where each row corresponds to a starting point, or in form of a vector, where starting points are read in consecutive order from the entries of th
mult
numerical value which specifies the number of starting points. If the number given here is larger than the number of starting points provided at x0, then the missing points will be set at random. For example, if $d=2$, mu
way
"one": go only in direction of the first local eigenvector, "back": go only in opposite direction, "two": go from starting point in both directions.
scaled
if TRUE, scales each variable by dividing through its range (see also the Notes section below).
weights
a vector of observation weights (can also be used to exclude individual observations from the computation by setting their weight to zero.)
pen
power used for angle penalization (see [1]). If set to 0, the angle penalization is switched off.
depth
maximum depth of branches ($\phi_{max}$ in [2]), restricted to the values 1,2 or 3 (The original LPC branch has depth 1. If, along this curve, a point features a high second local PC, this launches a new starting point, and the resulting br
control
Additional parameters steering particularly the boundary and convergence behavior of the fitted curve. See lpc.control.

Value

  • A list of items:
  • LPCThe coordinates of the local centers of mass of the fitted principal curve.
  • ParametrizationCurve parameters and branch labels for each local center of mass.
  • hThe bandwidth used for the curve estimation.
  • toThe constant $t_0$ used for the curve estimation.
  • starting.pointsThe coordinates of the starting point(s) used.
  • dataThe data frame used for curve estimation.
  • scaledLogical.
  • weightsThe vector of weights used for curve estimation.
  • controlThe settings used in lpc.control()
  • MiscMiscellannea.

References

[1] Einbeck, J., Tutz, G., & Evers, L. (2005). Local principal curves. Statistics and Computing 15, 301-313.

[2] Einbeck, J., Tutz, G., & Evers, L. (2005): Exploring Multivariate Data Structures with Local Principal Curves. In: Weihs, C. and Gaul, W. (Eds.): Classification - The Ubiquitous Challenge. Springer, Heidelberg, pages 256-263.

Examples

Run this code
data(calspeedflow)
lpc1 <- lpc(calspeedflow[,3:4])
plot(lpc1)

data(mussels, package="dr")
lpc2 <- lpc(mussels[,-3], x0=as.numeric(mussels[49,-3]), scaled=FALSE)
pairs(lpc2$LPC, panel="lines", labels= c("H","L","S","W") )

data(gaia)
s <- sample(nrow(gaia),200)
gaia.pc <-  princomp(gaia[s,5:20])
lpc3 <- lpc(gaia.pc$scores[,c(2,1,3)],scaled=FALSE)
plot(lpc3, curvecol=2, type=c("curve","mass"))

# Simulated letter 'E' with branched LPC
ex<- c(rep(0,40), seq(0,1,length=20), seq(0,1,length=20), seq(0,1,length=20))
ey<- c(seq(0,2,length=40), rep(0,20), rep(1,20), rep(2,20))
sex<-rnorm(100,0,0.01); sey<-rnorm(100,0,0.01)
eex<-rnorm(100,0,0.1);  eey<-rnorm(100,0,0.1)
ex1<-ex+sex; ey1<-ey+sey
ex2<-ex+eex; ey2<-ey+eey
e1<-cbind(ex1,ey1); e2<-cbind(ex2,ey2)
lpc.e1 <- lpc(e1, h= c(0.1,0.1),  depth=2, scaled=FALSE)
plot(lpc.e1, type=c("curve","mass", "start"))

Run the code above in your browser using DataLab