npoly: Natural polynomials

Description Usage Arguments Details Value Functions See Also Examples

View source: R/core_npoly.R

Description

Calculates natural polynomial coefficients using stats::lm

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
npoly(
  x,
  degree,
  raw,
  drop_coo,
  from_coo = coo,
  to_coe = {     {         coe     } },
  ...
)

npoly_i(x, nb_pts, from_coe, ...)

Arguments

x

coo_single, coo_list or mom_tbl

degree

polynomial degree for the fit (degree+1) coefficients are returned, see Details)

raw

logical whether to return raw and full results

drop_coo

logical whether to drop coo column (default to TRUE)

from_coo, to_coe

column names

...

for generics. Useless here.

nb_pts

number of points to sample and on which to calculate polynomials

from_coe

column name for inverse method

Details

Curves must be registered on a bookstein baseline, with the first coordinates on (-0.5, 0) and the last on (0.5, 0). Use coo_bookstein

A polynomial of degree n use this fit:

y = a_{0} + a_{1}x^1 + a_{...}x^{...} + a_{n}x^{n}

And thus returns n+1 coefficients. The +1 being $a_0$ ie the intercept.

In retired Momocs, baseline was free and not necessarily Bookstein. Not sure this was really helpful but I'm sure this overcomplicated coding. If your shapes are not registered on Bookstein coordinates, you will be messaged (not for coo_single though)

Value

a list with components when applied on a single shape:

Functions

See Also

Other polynomials: opoly()

Other morphometrics: dfourier(), efourier(), opoly()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
o <- olea %>% pick(5) %>% coo_bookstein()
o %>% pile()
op <- o %>% npoly(degree=3)
op
op %>% class

op %>% npoly_i() %>% draw()

olea %>% dplyr::slice(1:3) %>%
  npoly(drop=FALSE) %>% npoly_i

MomX/Momocs2 documentation built on May 13, 2020, 4:28 a.m.