Quantcast
Viewing all articles
Browse latest Browse all 186

Sorting logic and generation of letter sequence

In the context of experimental designs, it is common to generate the various treatment names to build the factorial design table.

The table of the 2^2 design reads :

Image may be NSFW.
Clik here to view.
2^2 Design table

For the 2^3, the table reads :

Image may be NSFW.
Clik here to view.
2^3 Design table

And for 2^4 :

Image may be NSFW.
Clik here to view.
2^4 Design table

I would like to generate such table for the general case 2^k. Here is what I've done so far :

FactorialDesign[k_] := Module[{D, Factor, combinations, Treatments},   D = Reverse[Tuples[{-1, 1}, k], 2];   Factor = Table[FromLetterNumber[i], {i, 1, k}];   combinations = Subsets[Factor];   Treatments =    Table[StringJoin[combination], {combination, combinations}];   Treatments[[1]] = "(1)";   Join[Transpose@{Treatments}, D, 2]]

In the case of the 2^3 design, the function yields :

FactorialDesign[3](*{{"(1)", -1, -1, -1}, {"a", 1, -1, -1}, {"b", -1, 1, -1}, {"c", 1, 1, -1}, {"ab", -1, -1, 1}, {"ac", 1, -1, 1}, {"bc", -1, 1, 1}, {"abc", 1, 1, 1}}*)

As you will see, the (-1) and (1) matrix matches with the examples I've provided, but not the treatments. They follow an other order {a,b,ab,c,ac,bc,abc} for the ^3 case.

Firstly, I'd be interested in understanding the mathematical logic (if any) behind the way the treatments are ordered in these examples. And then to be able to correct my code to generate arrays for 2^k-case


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>