Rpcop computes principal curves of oriented points (PCOP) following Delicado
(2001) and Delicado and Huerta (2003). The package wraps the original C++
implementation with an R interface and returns both the original PCOP table and
a princurve-style projected curve.
The main function is pcop(). It accepts a finite numeric matrix or numeric
data frame, where rows are observations and columns are coordinates.
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) head(fit$pcop.f1) summary(fit)
pcop.f1 stores the PCOP output in the original tabular format. pcop.f2
stores the projected curve in the format returned by princurve, including the
curve coordinates in fit$pcop.f2$s.
str(fit$pcop.f2, max.level = 1)
The Ch argument controls the smoothing bandwidth relative to the normal
reference rule. The Cd argument controls the approximate spacing between
consecutive principal oriented points relative to that bandwidth. The accepted
ranges are documented in ?pcop.
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 submitted data are not modified.
The wrapper rejects missing, infinite, and non-numeric inputs before calling the native backend. Plotting is available for two-dimensional inputs:
pcop(x, plot.true = TRUE, lwd = 2, col = 2)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.