npoly {Momocs}R Documentation

Calculate natural polynomial fits on open outlines

Description

Calculates natural polynomial coefficients, through a linear model fit (see lm), from a matrix of (x; y) coordinates or an Opn object

Usage

npoly(x, ...)

## Default S3 method:
npoly(x, degree, ...)

## S3 method for class 'Opn'
npoly(
  x,
  degree,
  baseline1 = c(-0.5, 0),
  baseline2 = c(0.5, 0),
  nb.pts = 120,
  ...
)

## S3 method for class 'list'
npoly(x, ...)

Arguments

x

a matrix (or a list) of (x; y) coordinates or an Opn object

...

useless here

degree

polynomial degree for the fit (the Intercept is also returned)

baseline1

numeric the (x; y) coordinates of the first baseline by default (x= -0.5; y=0)

baseline2

numeric the (x; y) coordinates of the second baseline by default (x= 0.5; y=0)

nb.pts

number of points to sample and on which to calculate polynomials

Value

when applied on a single shape, a list with components:

otherwise, an OpnCoe object.

See Also

Other polynomials: opoly_i(), opoly()

Examples

data(olea)
o <- olea[1]
op <- opoly(o, degree=4)
op
# shape reconstruction
opi <- opoly_i(op)
coo_plot(o)
coo_draw(opi, border="red")
# R2 for degree 1 to 10
r <- numeric()
for (i in 1:10) { r[i] <- npoly(o, degree=i)$r2 }
plot(2:10, r[2:10], type='b', pch=20, col='red', main='R2 / degree')

[Package Momocs version 1.4.1 Index]