Learn R Programming

Morpho (version 2.1)

proc.weight: calculate weights inverse to the distances from the specified observation.

Description

for calculation of a shape model by averaging the observations neighbouring the configuration in question, it is necessary to calculate weights by similarity.

Usage

proc.weight(data, number, ref, report = TRUE, reg = 0, log = FALSE,
  mahalanobis = FALSE)

Arguments

data
array containing landmark configurations
number
integer: how many of the neighbours are to be involved.
ref
integer: position in the array that is used as reference.
report
logical: require report about name of the reference.
reg
numeric: regularise mahalanobis distance by adding reg to the diagonal of eigenvalues of the covariance matrix.
log
logical: use the logarithm of the distances.
mahalanobis
logical: use mahalanobis distance.

Value

  • datadataframe containing id, procrustes/mahalanobis distance and weight according to the reference
  • referencereturns observations' names if available
  • rho.alldataframe containing distances to references of all observations

Details

distances of zero will get a weight of 1e12 (this is scaled to all weights summing to one), thus weights for observations further away are converging to zero.

Examples

Run this code
library(shapes)
proc <- procSym(gorf.dat)
##get weights for the the four specimen closest to the first observation.
weights <- proc.weight(proc$rotated,4,1)

##estimate the first specimen by weighted neighbour shapes.
estim <- proc$mshape*0;
for (i in 1:4)
{estim <-estim+proc$rotated[,,weights$data$nr[i]]*weights$data$weight[i]}

### visualise
plot(estim,asp=1)## show estimation
points(proc$rotated[,,1],col=3)##show original

Run the code above in your browser using DataLab