R/contr.TianXu.R
contr.TianXu.Rd
A complex-valued contrast function for s^el levels based on powers of the s-th root of the unity
contr.TianXu(n, s = 2, contrasts = 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
contr.TianXu
yields a matrix of complex-valued contrasts.
It can therefore NOT be used in function model.matrix
or in statistical modeling functions.
The function implements the complex-valued contrasts from
Tian and Xu (2022). Its sole use is the calculation of the
stratification pattern (also called space-filling pattern).
However, note that it is not used in function Spattern
,
but only in the internal function Spattern_TianXu
,
which yields exactly the same results as function Spattern
.
The contrasts
argument has been kept in order to be
prepared in case the model.matrix
function gains the
ability to handle complex-valued contrasts.
The Tian and Xu contrasts are full-factorial-based contrasts
in the sense of Groemping (2023b). Function Spattern
uses a different type of full-factorial-based contrasts,
the full-factorial-based Helmert contrasts provided in function
contr.FFbHelmert
.
Groemping (2023b) Tian and Xu (2022)
## the same n can yield different contrasts for different s
contr.TianXu(16, 2)
#> 1 2 3 4 5 6 7 8 9 10 11 12
#> 1 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i
#> 2 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i 1+0i -1+0i -1+0i -1+0i -1+0i -1+0i
#> 3 1+0i 1+0i 1+0i -1+0i -1+0i -1+0i -1+0i 1+0i 1+0i 1+0i 1+0i -1+0i
#> 4 1+0i 1+0i 1+0i -1+0i -1+0i -1+0i -1+0i -1+0i -1+0i -1+0i -1+0i 1+0i
#> 5 1+0i -1+0i -1+0i 1+0i 1+0i -1+0i -1+0i 1+0i 1+0i -1+0i -1+0i 1+0i
#> 6 1+0i -1+0i -1+0i 1+0i 1+0i -1+0i -1+0i -1+0i -1+0i 1+0i 1+0i -1+0i
#> 7 1+0i -1+0i -1+0i -1+0i -1+0i 1+0i 1+0i 1+0i 1+0i -1+0i -1+0i -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
#> 2 0-1i 0-1i 0-1i
#> 3 -1+0i -1+0i -1+0i
#> 4 0+1i 0+1i 0+1i
#> 5 0+1i -1+0i 0-1i
#> 6 1+0i 0+1i -1+0i
#> 7 0-1i 1+0i 0+1i
#> 8 -1+0i 0-1i 1+0i
#> 9 -1+0i 1+0i -1+0i
#> 10 0+1i 0-1i 0+1i
#> 11 1+0i -1+0i 1+0i
#> 12 0-1i 0+1i 0-1i
#> 13 0-1i -1+0i 0+1i
#> 14 -1+0i 0+1i 1+0i
#> 15 0+1i 1+0i 0-1i
#> 16 1+0i 0-1i -1+0i
round(contr.TianXu(16, 16), 4)
#> 1 2 3 4 5
#> 1 1.0000+0.0000i 1.0000+0.0000i 1.0000+0.0000i 1+0i 1.0000+0.0000i
#> 2 0.9239+0.3827i 0.7071+0.7071i 0.3827+0.9239i 0+1i -0.3827+0.9239i
#> 3 0.7071+0.7071i 0.0000+1.0000i -0.7071+0.7071i -1+0i -0.7071-0.7071i
#> 4 0.3827+0.9239i -0.7071+0.7071i -0.9239-0.3827i 0-1i 0.9239-0.3827i
#> 5 0.0000+1.0000i -1.0000+0.0000i 0.0000-1.0000i 1+0i 0.0000+1.0000i
#> 6 -0.3827+0.9239i -0.7071-0.7071i 0.9239-0.3827i 0+1i -0.9239-0.3827i
#> 7 -0.7071+0.7071i 0.0000-1.0000i 0.7071+0.7071i -1+0i 0.7071-0.7071i
#> 8 -0.9239+0.3827i 0.7071-0.7071i -0.3827+0.9239i 0-1i 0.3827+0.9239i
#> 9 -1.0000+0.0000i 1.0000+0.0000i -1.0000+0.0000i 1+0i -1.0000+0.0000i
#> 10 -0.9239-0.3827i 0.7071+0.7071i -0.3827-0.9239i 0+1i 0.3827-0.9239i
#> 11 -0.7071-0.7071i 0.0000+1.0000i 0.7071-0.7071i -1+0i 0.7071+0.7071i
#> 12 -0.3827-0.9239i -0.7071+0.7071i 0.9239+0.3827i 0-1i -0.9239+0.3827i
#> 13 0.0000-1.0000i -1.0000+0.0000i 0.0000+1.0000i 1+0i 0.0000-1.0000i
#> 14 0.3827-0.9239i -0.7071-0.7071i -0.9239+0.3827i 0+1i 0.9239+0.3827i
#> 15 0.7071-0.7071i 0.0000-1.0000i -0.7071-0.7071i -1+0i -0.7071+0.7071i
#> 16 0.9239-0.3827i 0.7071-0.7071i 0.3827-0.9239i 0-1i -0.3827-0.9239i
#> 6 7 8 9 10
#> 1 1.0000+0.0000i 1.0000+0.0000i 1+0i 1.0000+0.0000i 1.0000+0.0000i
#> 2 -0.7071+0.7071i -0.9239+0.3827i -1+0i -0.9239-0.3827i -0.7071-0.7071i
#> 3 0.0000-1.0000i 0.7071-0.7071i 1+0i 0.7071+0.7071i 0.0000+1.0000i
#> 4 0.7071+0.7071i -0.3827+0.9239i -1+0i -0.3827-0.9239i 0.7071-0.7071i
#> 5 -1.0000+0.0000i 0.0000-1.0000i 1+0i 0.0000+1.0000i -1.0000+0.0000i
#> 6 0.7071-0.7071i 0.3827+0.9239i -1+0i 0.3827-0.9239i 0.7071+0.7071i
#> 7 0.0000+1.0000i -0.7071-0.7071i 1+0i -0.7071+0.7071i 0.0000-1.0000i
#> 8 -0.7071-0.7071i 0.9239+0.3827i -1+0i 0.9239-0.3827i -0.7071+0.7071i
#> 9 1.0000+0.0000i -1.0000+0.0000i 1+0i -1.0000+0.0000i 1.0000+0.0000i
#> 10 -0.7071+0.7071i 0.9239-0.3827i -1+0i 0.9239+0.3827i -0.7071-0.7071i
#> 11 0.0000-1.0000i -0.7071+0.7071i 1+0i -0.7071-0.7071i 0.0000+1.0000i
#> 12 0.7071+0.7071i 0.3827-0.9239i -1+0i 0.3827+0.9239i 0.7071-0.7071i
#> 13 -1.0000+0.0000i 0.0000+1.0000i 1+0i 0.0000-1.0000i -1.0000+0.0000i
#> 14 0.7071-0.7071i -0.3827-0.9239i -1+0i -0.3827+0.9239i 0.7071+0.7071i
#> 15 0.0000+1.0000i 0.7071+0.7071i 1+0i 0.7071-0.7071i 0.0000-1.0000i
#> 16 -0.7071-0.7071i -0.9239-0.3827i -1+0i -0.9239+0.3827i -0.7071+0.7071i
#> 11 12 13 14 15
#> 1 1.0000+0.0000i 1+0i 1.0000+0.0000i 1.0000+0.0000i 1.0000+0.0000i
#> 2 -0.3827-0.9239i 0-1i 0.3827-0.9239i 0.7071-0.7071i 0.9239-0.3827i
#> 3 -0.7071+0.7071i -1+0i -0.7071-0.7071i 0.0000-1.0000i 0.7071-0.7071i
#> 4 0.9239+0.3827i 0+1i -0.9239+0.3827i -0.7071-0.7071i 0.3827-0.9239i
#> 5 0.0000-1.0000i 1+0i 0.0000+1.0000i -1.0000+0.0000i 0.0000-1.0000i
#> 6 -0.9239+0.3827i 0-1i 0.9239+0.3827i -0.7071+0.7071i -0.3827-0.9239i
#> 7 0.7071+0.7071i -1+0i 0.7071-0.7071i 0.0000+1.0000i -0.7071-0.7071i
#> 8 0.3827-0.9239i 0+1i -0.3827-0.9239i 0.7071+0.7071i -0.9239-0.3827i
#> 9 -1.0000+0.0000i 1+0i -1.0000+0.0000i 1.0000+0.0000i -1.0000+0.0000i
#> 10 0.3827+0.9239i 0-1i -0.3827+0.9239i 0.7071-0.7071i -0.9239+0.3827i
#> 11 0.7071-0.7071i -1+0i 0.7071+0.7071i 0.0000-1.0000i -0.7071+0.7071i
#> 12 -0.9239-0.3827i 0+1i 0.9239-0.3827i -0.7071-0.7071i -0.3827+0.9239i
#> 13 0.0000+1.0000i 1+0i 0.0000-1.0000i -1.0000+0.0000i 0.0000+1.0000i
#> 14 0.9239-0.3827i 0-1i -0.9239-0.3827i -0.7071+0.7071i 0.3827+0.9239i
#> 15 -0.7071-0.7071i -1+0i -0.7071+0.7071i 0.0000+1.0000i 0.7071+0.7071i
#> 16 -0.3827+0.9239i 0+1i 0.3827+0.9239i 0.7071+0.7071i 0.9239+0.3827i