lm-utils: Linear Modelling Utility Functions

lm-utilsR Documentation

Linear Modelling Utility Functions

Description

Utility functions to build linear models using Phylogenetic Eigenvector Maps among their explanatory variables.

Usage

model.data(
  formula,
  data,
  ...,
  na.action = na.pass,
  contrasts = NULL,
  discard.intercept = TRUE
)

Psquare(obs, prd)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model data to be prepared. See ‘Details’ in lm for further information about model specification.

data

An optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called.

...

Additional parameters to be passed to the method.

na.action

A function (of the name of a function) for treating missing values (NAs) (default: na.pass).

contrasts

An optional list. See the contrasts.arg of model.matrix.default. (default: NULL).

discard.intercept

A logical; whether of not to discard the intercept from the model matrix (default: TRUE).

obs

A numeric vector of observations.

prd

A numeric vector of model predictions.

Details

Function model.data is useful to prepare data to be given as response and auxiliary trait(s) to other functions such as evolution.model.PEM. In general, the implicit constant term (intercept) is not useful and can be explicitly discarded.

Value

model.data

A three-member list with member $y (a vector or matrix of response traits), member $x (a matrix auxiliary traits coded as numeric values), and member $terms (A model description).

Psquare

A numeric value.

Functions

  • model.data(): Model Data Preparation

    Transforms data from various types into a list containing the response trait(s) and a strictly numeric auxiliary traits data matrix.

  • Psquare(): Coefficient of Prediction

    Calculates the prediction coefficient between observations and model predictions.

Author(s)

Guillaume Guénard [aut, cre] (<https://orcid.org/0000-0003-0761-3072>), Pierre Legendre [ctb] (<https://orcid.org/0000-0002-3838-3305>) Maintainer: Guillaume Guénard <guillaume.guenard@umontreal.ca>

References

Guénard, G., Legendre, P., and Peres-Neto, P. 2013. Phylogenetic eigenvector maps: a framework to model and predict species traits. Methods in Ecology and Evolution 4: 1120-1131


guenardg/MPSEM documentation built on April 14, 2025, 3:53 p.m.