Package 'Rpcop'

Title: Principal Curves of Oriented Points
Description: Principal curves generalize the notion of a first principal component to the case in which it is a nonlinear smooth curve. This package provides a function pcop(X) to compute principal curves with the algorithm defined in Delicado (2001) <doi:10.1006/jmva.2000.1917> from a data matrix X.
Authors: Pedro Delicado [aut] (Original C++ author), Mario Huerta [aut] (Original C++ author), Kevin Michael Frick [trl, aut, cre] (Modern C++ fixes and Rcpp port, with permission from the original authors), Stephen L. Moshier [cph] (Author of eigens() for symmetric matrix eigendecomposition)
Maintainer: Kevin Michael Frick <[email protected]>
License: GPL (>= 2)
Version: 1.2.3
Built: 2026-06-24 18:38:34 UTC
Source: https://github.com/cran/Rpcop

Help Index


Principal Curve of Oriented Points

Description

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 nn points in dimension pp. Missing and infinite values are rejected.

Ch

The smoothing parameter hh is CHC_H times the value given by the normal reference rule. Default value 1.51.5. Constraints 0.5CH1.50.5 \le C_H \le 1.5.

Cd

The distance between two consecutive principal oriented points in a PCOP is about CDC_D times the value of the smoothing parameter hh. Default value 0.30.3. Constraints 0.25CD0.50.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)

x <- runif(100, -1, 1)
x <- cbind(x, x ^ 2 + rnorm(100, sd = 0.1))
pcop(x, plot.true = FALSE)
if (interactive()) {
  pcop(x, plot.true = TRUE, lwd = 4, col = 2)
}

Methods for pcop objects

Description

Print, summary, and plot methods for objects returned by pcop().

Usage

## S3 method for class 'pcop'
print(x, ...)
## S3 method for class 'pcop'
summary(object, ...)
## S3 method for class 'summary.pcop'
print(x, ...)
## S3 method for class 'pcop'
plot(x, ...)

Arguments

x

A pcop or summary.pcop object.

object

A pcop object.

...

Additional arguments passed to methods. For plot.pcop(), arguments are passed to graphics::plot.

Value

print.pcop(), print.summary.pcop(), and plot.pcop() return their input invisibly. summary.pcop() returns a compact summary object.

Examples

set.seed(1)
x <- runif(100, -1, 1)
x <- cbind(x, x ^ 2 + rnorm(100, sd = 0.1))
fit <- pcop(x, plot.true = FALSE)

print(fit)
summary(fit)
if (interactive()) {
  plot(fit)
}