Learn R Programming

Momocs (version 1.0.0)

calibrate_harmonicpower: Quantitative calibration, through harmonic power, for Out and Opn objects

Description

Estimates the number of harmonics required for the four Fourier methods implemented in Momocs: elliptical Fourier analysis (see efourier), radii variation analysis (see rfourier) and tangent angle analysis (see tfourier) and discrete Fourier transform (see dfourier). It returns and can plot cumulated harmonic power whether dropping the first harmonic or not, and based and the maximum possible number of harmonics on the Coo object.

Usage

calibrate_harmonicpower(x, method, id, nb.h, drop, thresh, plot, verbose)

Arguments

x
a Coo of Opn object
method
any method from c('efourier', 'rfourier', 'tfourier') for Outs and dfourier for Outs.
id
the shapes on which to perform calibrate_harmonicpower. All of them by default
nb.h
numeric the maximum number of harmonic, on which to base the cumsum
drop
numeric the number of harmonics to drop for the cumulative sum
thresh
vector of numeric for drawing horizontal lines, and also used for minh below
plot
logical whether to plot the result or simply return the matrix
verbose
whether to print results

Value

returns a list with component:
  • gg a ggplot object, q the quantile matrix
  • minh a quick summary that returns the number of harmonics required to achieve a certain proportion of the total harmonic power.

Details

The power of a given harmonic $n$ is calculated as follows for elliptical Fourier analysis and the n-th harmonic: $HarmonicPower_n \frac{A^2_n+B^2_n+C^2_n+D^2_n}{2}$ and as follows for radii variation and tangent angle: $HarmonicPower_n= \frac{A^2_n+B^2_n+C^2_n+D^2_n}{2}$

See Also

Other calibration: calibrate_deviations, calibrate_r2, calibrate_reconstructions

Examples

Run this code
data(bot)
cal <- calibrate_harmonicpower(bot)
## Not run: 
# # for Opn objects
# data(olea)
# calibrate_harmonicpower(olea, "dfourier")
# 
# # let customize the ggplot
# library(ggplot2)
# cal$gg + theme_minimal() +
# coord_cartesian(xlim=c(3.5, 12.5), ylim=c(90, 100)) +
# ggtitle("Harmonic power calibration")
# ## End(Not run)
# if you want to do efourier with 99% calibrate_harmonicpower in one step
# efourier(bot, nb.h=calibrate_harmonicpower(bot, "efourier", plot=FALSE)$minh["99%"])

Run the code above in your browser using DataLab