Skip to contents

Computes a principal curve as defined in Delicado and Huerta (2003) doi:10.1007/s001800300145 .

Usage

pcop(x, Ch = 1.5, Cd = 0.3, plot.true = FALSE, ...)

Arguments

x

A finite numeric matrix or data frame of \(n\) points in dimension \(p\). Missing and infinite values are rejected.

Ch

The smoothing parameter \(h\) is \(C_H\) times the value given by the normal reference rule. Default value \(1.5\). Constraints \(0.5 \le C_H \le 1.5\).

Cd

The distance between two consecutive principal oriented points in a PCOP is about \(C_D\) times the value of the smoothing parameter \(h\). Default value \(0.3\). Constraints \(0.25 \le C_D \le 0.5\).

plot.true

If TRUE, produce a two-dimensional plot of the resulting curve. Plotting requires at least two columns in x.

...

Additional parameters passed to lines.

Value

A list with two elements:

pcop.f1

Data frame storing the principal curve of oriented points in the original format, with columns param, dens, span, orth.var, pop1, pop2, ..., pr.dir1, pr.dir2, ...

pcop.f2

List conforming to the format used in princurve; see that package for details.

parameters

List of algorithm parameters used for the fit.

input_names

Input row and column names, if present. Other input attributes are not used by the algorithm and are not propagated.

call

Matched function call.

Examples

n <- 500
p <- 3
x <- matrix(rnorm(n * p), ncol = p) %*% diag(p:1)
pcop(x, plot.true = FALSE)
#> Principal curve of oriented points
#> Dimension: 3 
#> Curve points: 11 
#> Ch: 1.5 Cd: 0.3 

x <- runif(100, -1, 1)
x <- cbind(x, x ^ 2 + rnorm(100, sd = 0.1))
pcop(x, plot.true = FALSE)
#> Principal curve of oriented points
#> Dimension: 2 
#> Curve points: 14 
#> Ch: 1.5 Cd: 0.3 
if (interactive()) {
  pcop(x, plot.true = TRUE, lwd = 4, col = 2)
}