Learn R Programming

analogue (version 0.14-0)

scores.prcurve: scores method for principal curve objects of class "prcurve".

Description

A scores method to extract the position on the curve to which each observation projects (display = "curve") or the coordinates of the curve in the dimensions of the input data (display = "dimensions").

Usage

## S3 method for class 'prcurve':
scores(x, display = c("curve", "dimensions"), ...)

Arguments

x
an object of class "prcurve", usually from a call to prcurve.
display
character; which type of scores to extract. display = "curve" returns the position along the curve onto which each observation projects; this can be used like a PCA axis score. display = "dimensions" returns the coord
...
Arguments passed to other methods. Not used.

Value

  • If display = "curve" a 1-column matrix is returned with a row for each observation in the input data. If display = "dimensions", a matrix of coordinates for the principal curve is returned. The dimensions of this matrix relate to the dimensions of the input data; if there were $n$ samples (rows) and $m$ variables {columns} then the matrix returned by scores.prcurve will have $n$ rows and $m$ columns.

See Also

prcurve for fitting principal curves to data.

Examples

Run this code
## Load the Abernethy Forest data set
data(abernethy)

## Remove the Depth and Age variables
abernethy2 <- abernethy[, -(37:38)]

## Fit the principal curve using varying complexity of smoothers
## for each species
aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE,
                   vary = TRUE, penalty = 1.4)

## Extract position on the curve
pos <- scores(aber.pc, display = "curve")
head(pos)

## Extract the coordinates of the curve
coord <- scores(aber.pc, display = "dimensions")
dim(coord)
all.equal(dim(coord), dim(abernethy2))

Run the code above in your browser using DataLab