fit.morph: Fit Morphometric Model

View source: R/model.R

fit.morphR Documentation

Fit Morphometric Model

Description

Fits the model described by Stevenson, Smit, and Setyawan (2026) to morphometric data.

Usage

fit.morph(
  data,
  log.transform = FALSE,
  method = "REML",
  control = list(maxIter = 1e+05, msMaxIter = 1e+05)
)

Arguments

data

A data frame containing the morphometric data. See the section below on the correct formatting of this argument.

log.transform

Logical. If TRUE, the data are log-transformed prior to model fitting.

method

A character string indicating the objective function used to fit the model. Either "ML" for maximum likelihood or "REML" for restricted maximum likelihood.

control

A list of control values for the estimation algorithm to replace the default values returned by the function nlme::lmeControl().

Details

This is a special case of a linear mixed-effects model, and is fitted via a call to nlme::lme(). Some arguments of fit.morph() are directly passed to nlme::lme().

Value

An object of classes lme.morph (specific to this package) and lme (inherited from nlme::lme()). The object is the list returned by nlme::lme() with a couple of additional components.

Rather than inspecting the object directly, the best way to extract understandable output from the object is using the S3 methods summary.lme.morph(), plot.lme.morph(), and predict.lme.morph() via the generic functions summary(), plot(), and predict(). Other S3 methods for the lme class are availble via nlme, such as nlme::coef.lme().

Log transformations

To fit a model to log-transformed measurement data, provide the untransformed measurements in the data argument and specify log.transform = TRUE. This will allow the S3 method plot.lme.morph() to plot the original data with back-transformed estimates, and the S3 method summary.lme.morph() to carry out the correct test for isometric growth.

The data argument

The manta object is an example of a correctly formatted data argument. It must be a data frame with the following columns:

animal.id

An individual identification number. Rows with the same animal.id correspond to measurements of the saime individual manta ray.

photo.id

A photo identification number. Rows with the same photo.id correspond to measurements taken from the same image.

photo.id

An integer indicating the dimension the measurement is for.

measurement

The corresponding measurement.

References

Stevenson, B. C., Smit, E., and Setyawan, E. (2026) Measurement error models for morphometric data. Annals of Applied Statistics, 20: 945–962.

Examples

## Fitting model to manta ray data.
fit <- fit.morph(manta)
## Using maximum likelihood instead of REML.
fit <- fit.morph(manta, method = "ML")


morphErr documentation built on Aug. 30, 2026, 5:06 p.m.