mahala_design: Mahalanobis distance from designed experiments

Description Usage Arguments Value Author(s) Examples

View source: R/mahala_design.R

Description

[Stable]

Compute the Mahalanobis distance using data from an experiment conducted in a randomized complete block design or completely randomized design.

Usage

1
2
3
4
5
6
7
8
9
mahala_design(
  .data,
  gen,
  rep,
  resp,
  design = "RCBD",
  by = NULL,
  return = "distance"
)

Arguments

.data

The dataset containing the columns related to Genotypes, replication/block and response variables, possible with grouped data passed from dplyr::group_by().

gen

The name of the column that contains the levels of the genotypes.

rep

The name of the column that contains the levels of the replications/blocks.

resp

The response variables. For example resp = c(var1, var2, var3).

design

The experimental design. Must be RCBD or CRD.

by

One variable (factor) to compute the function by. It is a shortcut to dplyr::group_by(). To compute the statistics by more than one grouping variable use that function.

return

What the function return? Default is 'distance', i.e., the Mahalanobis distance. Alternatively, it is possible to return the matrix of means return = 'means', or the variance-covariance matrix of residuals return = 'covmat'.

Value

A symmetric matrix with the Mahalanobis' distance. If .data is a grouped data passed from dplyr::group_by() then the results will be returned into a list-column of data frames.

Author(s)

Tiago Olivoto tiagoolivoto@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(metan)
maha <- mahala_design(data_g,
                      gen = GEN,
                      rep = REP,
                      resp = everything(),
                      return = "covmat")

# Compute one distance for each environment (all numeric variables)
maha_group <- mahala_design(data_ge,
                           gen = GEN,
                           rep = REP,
                           resp = everything(),
                           by = ENV)

# Return the variance-covariance matrix of residuals
cov_mat <- mahala_design(data_ge,
                        gen = GEN,
                        rep = REP,
                        resp = c(GY, HM),
                        return = 'covmat')

metan documentation built on Nov. 10, 2021, 9:11 a.m.