R/contr.FFbHelmert.R
, R/contr.FFbPoly.R
contr.FFbased.Rd
Full-factorial-based real-valued contrasts for s^el levels
Full-factorial-based polynomial contrasts for s^el levels
contr.FFbHelmert(n, s, contrasts = TRUE, slowfirst = TRUE)
contr.FFbPoly(n, s, contrasts = TRUE, slowfirst = TRUE)
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
.
positive integer, at least 2
logical; must be TRUE
logical; default TRUE
contr.FFbHelmert
and contr.FFbPoly
yield a matrix
of real-valued contrasts.
That matrix can be used in function model.matrix
or in any statistical modeling functions.
The functions implement real-valued full-factorial-based contrasts
in the sense of Groemping (2023b) that can be used
instead of the complex-valued contrasts from
Tian and Xu (2022), as implemented in function
contr.TianXu
. Their main use is the calculation of the
stratification pattern (also called space-filling pattern).
Function Spattern
uses function contr.FFbHelmert
for this purpose, the internal function Spattern_Poly
uses
contr.FFbPoly
.
Groemping (2023b) Tian and Xu (2022)
## the same n can yield different contrasts for different s
## Helmert variant
contr.FFbHelmert(16, 2)
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#> 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1
#> 2 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1
#> 3 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1
#> 4 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1
#> 5 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1
#> 6 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1
#> 7 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1
#> 8 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1
#> 9 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1
#> 10 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1
#> 11 1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1
#> 12 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1
#> 13 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1
#> 14 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1
#> 15 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1
#> 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
round(contr.FFbHelmert(16, 4), 4)
#> 1 2 3 4 5 6 7 8 9 10
#> 1 -1.4142 -0.8165 -0.5774 -1.4142 2 1.1547 0.8165 -0.8165 1.1547 0.6667
#> 2 -1.4142 -0.8165 -0.5774 1.4142 -2 -1.1547 -0.8165 -0.8165 1.1547 0.6667
#> 3 -1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 1.6330 -2.3094 -1.3333
#> 4 -1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 5 1.4142 -0.8165 -0.5774 -1.4142 -2 1.1547 0.8165 -0.8165 -1.1547 0.6667
#> 6 1.4142 -0.8165 -0.5774 1.4142 2 -1.1547 -0.8165 -0.8165 -1.1547 0.6667
#> 7 1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 1.6330 2.3094 -1.3333
#> 8 1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 9 0.0000 1.6330 -0.5774 -1.4142 0 -2.3094 0.8165 -0.8165 0.0000 -1.3333
#> 10 0.0000 1.6330 -0.5774 1.4142 0 2.3094 -0.8165 -0.8165 0.0000 -1.3333
#> 11 0.0000 1.6330 -0.5774 0.0000 0 0.0000 0.0000 1.6330 0.0000 2.6667
#> 12 0.0000 1.6330 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 13 0.0000 0.0000 1.7321 -1.4142 0 0.0000 -2.4495 -0.8165 0.0000 0.0000
#> 14 0.0000 0.0000 1.7321 1.4142 0 0.0000 2.4495 -0.8165 0.0000 0.0000
#> 15 0.0000 0.0000 1.7321 0.0000 0 0.0000 0.0000 1.6330 0.0000 0.0000
#> 16 0.0000 0.0000 1.7321 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 11 12 13 14 15
#> 1 0.4714 -0.5774 0.8165 0.4714 0.3333
#> 2 0.4714 -0.5774 0.8165 0.4714 0.3333
#> 3 -0.9428 -0.5774 0.8165 0.4714 0.3333
#> 4 0.0000 1.7321 -2.4495 -1.4142 -1.0000
#> 5 0.4714 -0.5774 -0.8165 0.4714 0.3333
#> 6 0.4714 -0.5774 -0.8165 0.4714 0.3333
#> 7 -0.9428 -0.5774 -0.8165 0.4714 0.3333
#> 8 0.0000 1.7321 2.4495 -1.4142 -1.0000
#> 9 0.4714 -0.5774 0.0000 -0.9428 0.3333
#> 10 0.4714 -0.5774 0.0000 -0.9428 0.3333
#> 11 -0.9428 -0.5774 0.0000 -0.9428 0.3333
#> 12 0.0000 1.7321 0.0000 2.8284 -1.0000
#> 13 -1.4142 -0.5774 0.0000 0.0000 -1.0000
#> 14 -1.4142 -0.5774 0.0000 0.0000 -1.0000
#> 15 2.8284 -0.5774 0.0000 0.0000 -1.0000
#> 16 0.0000 1.7321 0.0000 0.0000 3.0000
round(contr.FFbHelmert(16, 16), 4)
#> 1 2 3 4 5 6 7 8 9
#> 1 -2.8284 -1.633 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 2 2.8284 -1.633 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 3 0.0000 3.266 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 4 0.0000 0.000 3.4641 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 5 0.0000 0.000 0.0000 3.5777 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 6 0.0000 0.000 0.0000 0.0000 3.6515 -0.6172 -0.5345 -0.4714 -0.4216
#> 7 0.0000 0.000 0.0000 0.0000 0.0000 3.7033 -0.5345 -0.4714 -0.4216
#> 8 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 3.7417 -0.4714 -0.4216
#> 9 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 3.7712 -0.4216
#> 10 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 3.7947
#> 11 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 12 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 13 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 14 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 15 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 16 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 10 11 12 13 14 15
#> 1 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 2 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 3 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 4 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 5 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 6 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 7 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 8 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 9 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 10 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 11 3.8139 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 12 0.0000 3.8297 -0.3203 -0.2965 -0.2760 -0.2582
#> 13 0.0000 0.0000 3.8431 -0.2965 -0.2760 -0.2582
#> 14 0.0000 0.0000 0.0000 3.8545 -0.2760 -0.2582
#> 15 0.0000 0.0000 0.0000 0.0000 3.8644 -0.2582
#> 16 0.0000 0.0000 0.0000 0.0000 0.0000 3.8730
## Poly variant
contr.FFbHelmert(16, 2)
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#> 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1
#> 2 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1
#> 3 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1
#> 4 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1
#> 5 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1
#> 6 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1
#> 7 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1
#> 8 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1
#> 9 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1
#> 10 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1
#> 11 1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1
#> 12 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1
#> 13 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1
#> 14 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1
#> 15 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1
#> 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
round(contr.FFbHelmert(16, 4), 4)
#> 1 2 3 4 5 6 7 8 9 10
#> 1 -1.4142 -0.8165 -0.5774 -1.4142 2 1.1547 0.8165 -0.8165 1.1547 0.6667
#> 2 -1.4142 -0.8165 -0.5774 1.4142 -2 -1.1547 -0.8165 -0.8165 1.1547 0.6667
#> 3 -1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 1.6330 -2.3094 -1.3333
#> 4 -1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 5 1.4142 -0.8165 -0.5774 -1.4142 -2 1.1547 0.8165 -0.8165 -1.1547 0.6667
#> 6 1.4142 -0.8165 -0.5774 1.4142 2 -1.1547 -0.8165 -0.8165 -1.1547 0.6667
#> 7 1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 1.6330 2.3094 -1.3333
#> 8 1.4142 -0.8165 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 9 0.0000 1.6330 -0.5774 -1.4142 0 -2.3094 0.8165 -0.8165 0.0000 -1.3333
#> 10 0.0000 1.6330 -0.5774 1.4142 0 2.3094 -0.8165 -0.8165 0.0000 -1.3333
#> 11 0.0000 1.6330 -0.5774 0.0000 0 0.0000 0.0000 1.6330 0.0000 2.6667
#> 12 0.0000 1.6330 -0.5774 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 13 0.0000 0.0000 1.7321 -1.4142 0 0.0000 -2.4495 -0.8165 0.0000 0.0000
#> 14 0.0000 0.0000 1.7321 1.4142 0 0.0000 2.4495 -0.8165 0.0000 0.0000
#> 15 0.0000 0.0000 1.7321 0.0000 0 0.0000 0.0000 1.6330 0.0000 0.0000
#> 16 0.0000 0.0000 1.7321 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000
#> 11 12 13 14 15
#> 1 0.4714 -0.5774 0.8165 0.4714 0.3333
#> 2 0.4714 -0.5774 0.8165 0.4714 0.3333
#> 3 -0.9428 -0.5774 0.8165 0.4714 0.3333
#> 4 0.0000 1.7321 -2.4495 -1.4142 -1.0000
#> 5 0.4714 -0.5774 -0.8165 0.4714 0.3333
#> 6 0.4714 -0.5774 -0.8165 0.4714 0.3333
#> 7 -0.9428 -0.5774 -0.8165 0.4714 0.3333
#> 8 0.0000 1.7321 2.4495 -1.4142 -1.0000
#> 9 0.4714 -0.5774 0.0000 -0.9428 0.3333
#> 10 0.4714 -0.5774 0.0000 -0.9428 0.3333
#> 11 -0.9428 -0.5774 0.0000 -0.9428 0.3333
#> 12 0.0000 1.7321 0.0000 2.8284 -1.0000
#> 13 -1.4142 -0.5774 0.0000 0.0000 -1.0000
#> 14 -1.4142 -0.5774 0.0000 0.0000 -1.0000
#> 15 2.8284 -0.5774 0.0000 0.0000 -1.0000
#> 16 0.0000 1.7321 0.0000 0.0000 3.0000
round(contr.FFbHelmert(16, 16), 4)
#> 1 2 3 4 5 6 7 8 9
#> 1 -2.8284 -1.633 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 2 2.8284 -1.633 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 3 0.0000 3.266 -1.1547 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 4 0.0000 0.000 3.4641 -0.8944 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 5 0.0000 0.000 0.0000 3.5777 -0.7303 -0.6172 -0.5345 -0.4714 -0.4216
#> 6 0.0000 0.000 0.0000 0.0000 3.6515 -0.6172 -0.5345 -0.4714 -0.4216
#> 7 0.0000 0.000 0.0000 0.0000 0.0000 3.7033 -0.5345 -0.4714 -0.4216
#> 8 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 3.7417 -0.4714 -0.4216
#> 9 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 3.7712 -0.4216
#> 10 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 3.7947
#> 11 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 12 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 13 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 14 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 15 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 16 0.0000 0.000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
#> 10 11 12 13 14 15
#> 1 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 2 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 3 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 4 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 5 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 6 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 7 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 8 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 9 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 10 -0.3814 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 11 3.8139 -0.3482 -0.3203 -0.2965 -0.2760 -0.2582
#> 12 0.0000 3.8297 -0.3203 -0.2965 -0.2760 -0.2582
#> 13 0.0000 0.0000 3.8431 -0.2965 -0.2760 -0.2582
#> 14 0.0000 0.0000 0.0000 3.8545 -0.2760 -0.2582
#> 15 0.0000 0.0000 0.0000 0.0000 3.8644 -0.2582
#> 16 0.0000 0.0000 0.0000 0.0000 0.0000 3.8730