contrastModel: Create transformed model matrix for contrast rotation

View source: R/randRot.R

contrastModelR Documentation

Create transformed model matrix for contrast rotation

Description

This function takes a model matrix X and a contrast matrix C and creates a transformed model matrix corresponding to a transformed set of coefficients.

Usage

contrastModel(X, C, coef.h = seq_len(ncol(C)))

Arguments

X

(numeric) model matrix with dimensions samples x coefficients.

C

(numeric) contrast matrix with dimensions coefficients x contrasts. The contrast matrix must have full column rank.

coef.h

column numbers of contrasts (in C) which should be set as coef.h in the transformed model, see initRandrot. All columns are set as coef.h by default.

Details

The last n coefficients of the transformed model matrix correspond to the n contrasts. By default, all contrasts are set as coef.h. See package vignette for examples of data rotations with contrasts.

Value

A transformed model matrix with coef.h set as attribute.

Author(s)

Peter Hettegger

Examples


group <- c("A", "A", "B", "B")
X <- model.matrix(~0+group)
C <- cbind(contrast1 = c(1, -1))
X2 <- contrastModel(X, C)

phettegger/randRotation documentation built on April 10, 2023, 7:25 p.m.