Principal Curves of Oriented Points

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) from a data matrix X.


Principal Curves of Oriented Points

R-CMD-check pkgcheck Codecov test coverage

This repository provides an implementation of principal curves on oriented points that can be compiled on modern systems, using Rcpp.

The original implementation, of which this repository is an adaptation, is provided here by the authors.

Principal curves on oriented points are introduced in Delicado and Huerta (2003).

Installation

Install the development version from GitHub with:

install.packages("remotes")
remotes::install_github("kmfrick/Rpcop")

Usage

library(Rpcop)

set.seed(1)
n <- 120
t <- runif(n, -1, 1)
x <- cbind(t, t^2 + rnorm(n, sd = 0.08))

fit <- pcop(x, Ch = 1.5, Cd = 0.3, plot.true = FALSE)
names(fit)
summary(fit)

pcop() accepts a finite numeric matrix or numeric data frame. Ch must be a single number between 0.5 and 1.5, and Cd must be a single number between 0.25 and 0.5. Missing, infinite, and non-numeric values are rejected before native code is called.

PCOP is distance-based, so coordinate scaling can affect the fitted curve. The wrapper first runs the native backend on the submitted scale. If that backend fails, it retries on internally standardized coordinates and maps the returned curve coordinates back to the submitted scale.

The returned object keeps the original pcop.f1 and pcop.f2 elements and also supports print(), summary(), and plot() methods.

Lifecycle and Prior Art

Rpcop is a maintained Rcpp port of the original PCOP C++ implementation published by Delicado and Huerta. Development is focused on keeping the original algorithm buildable on modern R toolchains, adding targeted validation, and documenting package behavior for review rather than extending the method.

Tests

Use these commands from repository root:

# Build the source tarball, then run a CRAN-style check outside the repo tree
rv sync
pkgdir=$PWD
libdir=$(rv library)
mkdir -p /private/tmp/rpcop-check
cd /private/tmp/rpcop-check
R_LIBS_USER="$libdir" R CMD build --no-manual "$pkgdir"
R_LIBS_USER="$libdir" R CMD check --as-cran --no-manual --output=/private/tmp/rpcop-check Rpcop_1.2.2.tar.gz
# Run Linux ASAN/UBSAN diagnostics
vagrant up --provision

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("Rpcop")

1.2.3 by Kevin Michael Frick, 3 months ago


https://github.com/kmfrick/Rpcop


Report a bug at https://github.com/kmfrick/Rpcop/issues


Browse source code at https://github.com/cran/Rpcop


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)


Documentation:   PDF Manual  


GPL (>= 2) license


Imports Rcpp, princurve

Suggests knitr, rmarkdown, testthat

Linking to Rcpp


See at CRAN