fixModelMatrix       package:ffmanova       R Documentation(latin1)

_F_i_x _t_h_e "_f_a_c_t_o_r" _m_a_t_r_i_x _o_f _a _t_e_r_m_s _o_b_j_e_c_t.

_D_e_s_c_r_i_p_t_i_o_n:

     The function takes the factor matrix of the terms object
     corresponding to a model formula and changes it so that model
     hierarchy is preserved also for powers of terms (e.g., 'I(a^2)').

_U_s_a_g_e:

     fixModelMatrix(mOld)

_A_r_g_u_m_e_n_t_s:

    mOld: The factor matrix (i.e. the '"factor"' attribute) of a terms
          object.

_D_e_t_a_i_l_s:

     The ordinary model handling functions in R do not treat powers of
     terms (a^n) as being higher order terms (like interaction terms). 
     'fixModelMatrix' takes the '"factor"' attribute of a terms object
     (usually created from a model formula) and changes it such that
     power terms can be treated hierarchically just like interaction
     terms.

     The factor matrix has one row for each variable and one coloumn
     for each term.  Originally, an entry is 0 if the term does not
     contain the variable.  If it contains the variable, the entry is 1
     if the variable should be coded with contrasts, and 2 if it should
     be coded with dummy variables.  See 'terms.object' for details.

     The changes performed by 'fixModelMatrix' are:


        *  Any 2's are changed to 1.

        *  In any coloumn corresponding to a term that contains
           'I(a^n)', where 'a' is the name of a variable and 'n' is a
           positive integer, the element in the row corresponding to
           'a' is set to n.  For instance, the entry of row 'D' and
           coloumn 'C:I(D^2)' is set to 2.

        *  Rows corresponding to 'I(a^n)' are deleted.

     Note that this changes the semantics of the factor matrix: '2' no
     longer means code via dummy variables.

_V_a_l_u_e:

     A factor matrix.

_A_u_t_h_o_r(_s):

     yvind Langsrud and Bjrn-Helge Mevik

_S_e_e _A_l_s_o:

     'terms', 'terms.object'

_E_x_a_m_p_l_e_s:

     mt <- terms(y ~ a + b + a:b + a:c + I(a^2) + I(a^3) + I(a^2):b)
     print(mOld <- attr(mt, "factor"))
     fixModelMatrix(mOld)

