contr.Power: A contrast function based on regular factorials for number of...

contr.PowerR Documentation

A contrast function based on regular factorials for number of levels a prime or prime power

Description

A contrast function based on regular factorials for number of levels a prime or prime power

Usage

contr.Power(n, s = 2, contrasts = TRUE)

Arguments

n

integer or vector; either an integer number of levels of the factor for which contrasts are created, which must be a a power of s; or a factor whose number of levels is a power of s; or a vector of levels whose number of elements is a power of s.

s

integer; prime or prime power

contrasts

logical; must be TRUE

Details

The function is a generalization (with slowest first instead of fastest first) of function contr.FrF2 from package DoE.base. It is in this package because it needs Galois field functionality from package lhs for non-prime s. Its purpose is (was) the calculation of the stratification (or space-filling) pattern by Tian and Xu (2022), see also Groemping (2022). The package now calculates the pattern with function contr.TianXu.

Value

contr.Power yields a matrix of contrasts. It can be used in function model.matrix or anywhere where factors with the number of levels a power of $s$ are used with contrasts. The exponent for s is determined from the number of levels.

References

Groemping (2022) Tian and Xu (2022)

Examples

## the same n can yield different contrasts for different s
contr.Power(16, 2)
contr.Power(16, 4)


SOAs documentation built on Aug. 11, 2023, 1:09 a.m.