Implementation of R’s rules for design matrix creation
Create a new ANCOVA formula by concatenating a sequence of ANCOVA formulae.
Note: this is not commutatitive because the order in which the (expr, [factors]) appear in the initiating sequence changes the resulting formula.
>>> x = Term('x'); f = Factor('f', range(3)); h = Factor('h', range(4))
>>> a1 = ANCOVA((x,f))
>>> a2 = ANCOVA((x,h))
>>> concat(a1,a2).formula
Formula([1, f_0*x, f_1*x, f_2*x, h_1*x, h_2*x, h_3*x])
>>> concat(a2,a1).formula
Formula([1, f_1*x, f_2*x, h_0*x, h_1*x, h_2*x, h_3*x])
Determine which columns a subset of factors
Given a sequence of subsets of factors, determine which will be coded with all their degrees of freedom (“indicator”) and which will be coded as contrasts (“contrast”).
Is obj an ANCOVA?
Return an ANCOVA formula with only the maximal elements for each expression.
Produce an ANCOVA table from a given ANCOVA formula with type I sums of squares where the order is based on the order of terms in the contrast_names of ancova.
Produce an ANCOVA table from a given ANCOVA formula with type II sums of squares.
Produce an ANCOVA table with type III sum of squares from a given ANCOVA formula.