NNshapeReg: Estimate the shape by averaging the shape of the nearest...

View source: R/NNshapeReg.r

NNshapeRegR Documentation

Estimate the shape by averaging the shape of the nearest neighbours.

Description

Estimate the shape of one set of landmarks by averaging the shape of the nearest neighbours obtained by a second set of landmarks. Weights are calculated either form Mahalanobis or Procrustes distances. This can be useful for data with missing landmarks.

Usage

NNshapeReg(
  x,
  y = NULL,
  n = 3,
  mahalanobis = FALSE,
  mc.cores = parallel::detectCores()
)

Arguments

x

an array or matrix (one row per specim) with data used for estimating weights.

y

an array or matrix (one row per specim) with landmark data on which the weighted averaging is applied for prediction. If NULL, x will be used for both tasks.

n

amount of nearest neighbours to consider

mahalanobis

logical: use mahalanobis distance

mc.cores

integer: amount of cores used for parallel processing.

Details

This function calculates weights from one set of shape data and then estimates the shape of another (or same) set of landmarks. CAUTION: landmark data has to be registered beforehand.

Value

matrix or array of estimates.

See Also

proc.weight, fixLMtps

Examples


if (require(shapes)) {
proc <- procSym(gorf.dat)
#use the closest 3 specimen based on the first 4 landmarks
#to estimate the shape
estim <- NNshapeReg(proc$rotated[1:4,,],proc$rotated,n=3,mc.cores=1)
#compare estimation and true config
plot(proc$rotated[,,1],asp=1)
points(estim[,,1],col=2)
}


Morpho documentation built on Feb. 16, 2023, 10:51 p.m.