hyp_matrix: Compute the Hypothesis Matrix for MANOVA testing.

View source: R/hyp_matrix.R

hyp_matrixR Documentation

Compute the Hypothesis Matrix for MANOVA testing.

Description

Given the summarized data provided, this function compute the hypothesis matrices used in several multivaraite statistics.

Usage

hyp_matrix(
  obj,
  par.mat = NULL,
  cov.mat = NULL,
  sample.size = NULL,
  groups = NULL
)

Arguments

obj

A list of ANOVA R objects or linear/non-linear model objects. If "obj" is not given, then the parmeters 'par.mat', 'cov.mat', and 'sample.size' must be given.

par.mat

A matrix where each column contains the model parameters of each curve.

cov.mat

List of parameter variance-covariance matrices.

sample.size

Vector with the sample sizes used to estimate each models.

groups

list of sets of indices that identify models from a same group.

Details

To perform the comparison of a model under different parameter values (different curve fits with the same model), the covariance matrices and means from each set of model parameters can be used in place of the covariance matrices and means for the variables inside of each group.

Value

A list carrying the following matrices and numerical data is returned:

  • "Pooled" sums of squares and cross product (SSCP) matrix: 'E'

  • Degree of freedom for matrix E: 'df.e'

  • The hypothesis SSCP matrix: 'H'

  • Degree of freedom for matrix H: 'df.h'

  • 'H + E': 'HpE.inv'

  • Error covariance matrix: 'Se'

  • Inverse of Se: Se.inv

  • Sum of mean of Squares: 'W'

  • Inverse of W: 'W.inv'

  • Variance-covariance matrix from each model: 'Cov'

  • Parameter matrix for the groups: 'par'

  • Number of variables or model parameters: 'p'

  • Total sample size: 'N'

  • Number of models/groups: 'n'

  • Sample size: 'm'

Author(s)

Robersy Sanchez (https://genomaths.com).

See Also

MANOVA.

Examples

## Generate a dataset
set.seed(1230)
x1 <- rnorm(1e3, mean = 2.5, sd = 1)
x2 <- rnorm(1e3, mean = 2.5, sd = 1)

line_1 <- 2.5 * x1 + 3 + runif(length(x1))/10
line_2 <- 2.5 * x2 + 3 + runif(length(x1))/10

## Fitting the linear models
lm_1 <- lm(line_1 ~ x1)
lm_2 <- lm(line_2 ~ x2)
res <- hyp_matrix(obj = list(model1 = lm_1, model2 = lm_2))

genomaths/usefr documentation built on July 28, 2022, 12:31 p.m.