-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.Rmd
61 lines (47 loc) · 2.12 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
output:
github_document:
html_preview: true
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup1, include=FALSE}
knitr::opts_chunk$set(fig.path = "man/figures/README_", warning = FALSE, message = FALSE, error = FALSE, echo = TRUE)
set.seed(1)
library(tidyverse)
```
# princurve
<!-- badges: start -->
[![CRAN Status](https://www.r-pkg.org/badges/version/princurve)](https://cran.r-project.org/package=princurve)
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/princurve)](https://cran.r-project.org/package=princurve)
[![DOI](https://zenodo.org/badge/125849601.svg)](https://zenodo.org/badge/latestdoi/125849601)
[![R-CMD-check](https://github.com/rcannood/princurve/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rcannood/princurve/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
Fitting a principal curve to a data matrix in arbitrary dimensions.
A principal curve is a smooth curve passing through the middle of a multidimensional dataset.
This package is an R/C++ reimplementation of the S/Fortran code provided by Trevor Hastie,
with multiple performance tweaks.
## Example
Usage of princurve is demonstrated with a toy dataset.
```{r example}
t <- runif(100, -1, 1)
x <- cbind(t, t ^ 2) + rnorm(200, sd = 0.05)
colnames(x) <- c("dim1", "dim2")
plot(x)
```
A principal curve can be fit to the data as follows:
```{r princurve}
library(princurve)
fit <- principal_curve(x)
plot(fit); whiskers(x, fit$s, col = "gray")
```
See `?principal_curve` for more information on how to use the `princurve` package.
## Latest changes
Check out `news(package = "princurve")` or [NEWS.md](NEWS.md) for a full list of changes.
<!-- This section gets automatically generated from NEWS.md -->
```{r news, results='asis', echo=FALSE}
cat(dynutils::recent_news())
```
## References
Hastie, T. and Stuetzle, W., [Principal Curves](https://www.jstor.org/stable/2289936), JASA, Vol. 84, No. 406 (Jun., 1989), pp. 502-516, DOI: [10.2307/2289936](https://doi.org/10.2307/2289936) ([PDF](https://web.stanford.edu/~hastie/Papers/principalcurves.pdf))