# 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

1 2 |

### Arguments

`X` |
data matrix with |

`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 |

`t0` |
scalar step length. Default setting is |

`x0` |
specifies the choice of starting points. The default
choice |

`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 ( |

`control` |
Additional parameters steering particularly the starting-, boundary-, and convergence
behavior of the fitted curve. See |

### Value

A list of items:

`LPC` |
The coordinates of the local centers of mass of the fitted principal curve. |

`Parametrization` |
Curve parameters and branch labels for each local center of mass. |

`h` |
The bandwidth used for the curve estimation. |

`to` |
The constant |

`starting.points` |
The coordinates of the starting point(s) used. |

`data` |
The data frame used for curve estimation. |

`scaled` |
Logical. |

`weights` |
The vector of weights used for curve estimation. |

`control` |
The settings used in |

`Misc` |
Miscellannea. |

### Note

All values provided in the output refer to the scaled data, if
`scaled=TRUE`

. Use `unscale`

to convert the
results back to the original data scale.

The option `scaled=TRUE`

scales the data by dividing each variable through their
range. This differs from the usual scaling through
the standard deviation as common for PCA, but we found the
algorithm and the default bandwidth selection to work more reliably
this way. If you wish to scale by the standard deviation, please do that
by feeding the scaled data directly into the `lpc`

function, i.e.

`lpc(sweep(data, 2,sd(data), "/"),h, t0, ..., scaled=FALSE, ...)`

.

### Author(s)

J. Einbeck and L. Evers. See `LPCM-package`

for further acknowledgements.

### 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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
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)
plot(lpc2, curvecol=2)
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"))
``` |