ConstraintMatrix             package:cmm             R Documentation

_C_o_n_s_t_r_a_i_n_t_M_a_t_r_i_x

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

     Returns hierarchical model constraint matrix, i.e., nullspace of
     design matrix

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

     ConstraintMatrix(var, suffconfigs, dim, SubsetCoding = "Automatic")

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

     var: character or numeric vector containing variables

suffconfigs: subvector or list of subvectors of 'var' indicating the
          sufficient configurations or highest order interactions in
          model

     dim: numeric vector indicating the dimension of 'var' (must be
          same length as 'var')

SubsetCoding: allows a (character) type or a matrix to be assigned to
          variables for each element of 'suffconfigs'

     , see examples

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

     The model mu_ij = alpha + beta_i + gamma_j has parametric form and
     can equivalently be described using constraints on the mu_ij, by
     mu_ij - mu_il - mu_kj + mu_kl = 0. Returns the transpose of the
     null space of 'DesignMatrix(var,marg,dim)'. Rows normally sum to
     zero. See 'DesignMatrix' for more details.

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

     matrix

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

     W. P. Bergsma w.p.bergsma@lse.ac.uk

_R_e_f_e_r_e_n_c_e_s:

     Bergsma, W. P. (1997). _Marginal models for categorical data_.
     Tilburg, The Netherlands: Tilburg University Press. <URL:
     http://stats.lse.ac.uk/bergsma/pdf/bergsma_phdthesis.pdf>

     Bergsma, W. P., Croon, M. A., & Hagenaars, J. A. P. (2009).
     Marginal models for dependent, clustered, and longitudunal
     categorical data. Berlin: Springer.

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

     'ConstraintMatrix', 'DesignMatrix', 'DirectSum', 'MarginalMatrix'

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

     # Constraint matrix for independence model
     var <- c("A","B")
     suffconfigs <- list(c("A"),c("B"))
     dim <- c(3, 3)
     ConstraintMatrix(var,suffconfigs,dim)
     # notation in one line
     ConstraintMatrix(c("A","B"),list(c("A"),c("B")),c(3,3))

     # Constraint matrix for saturated model, two short specifications giving same result
     ConstraintMatrix(c("A","B"),c("A","B"),c(3,3))
     ConstraintMatrix(c("A","B"),list(c("A","B")),c(3,3))

     # Constraint matrix for univariate quadratic regression model
     var <- c("A")
     suffconfigs <- c("A")
     dim <- c(5)
     ConstraintMatrix(var,suffconfigs,dim,SubsetCoding=list(c("A"),"Quadratic"))
     # notation in one line
     ConstraintMatrix(c("A"),c("A"),c(5),SubsetCoding=list(c("A"),"Quadratic"))

     # Constraint matrix for linear by nominal model, various methods:
     # simplest method which assumes equidistant centered scores:
     ConstraintMatrix(c("A","B"),c("A","B"),c(3,3),SubsetCoding=list(c("A","B"),list("Linear","Nominal")))
     # alternative specification with same result as above:
     ConstraintMatrix(c("A","B"),c("A","B"),c(3,3),SubsetCoding=list(c("A","B"),list(rbind(c(-1,0,1)),rbind(c(1,0,0),c(0,1,0)))))
     # specifying your own category scores
     scores=c(1,2,5);
     ConstraintMatrix(c("A","B"),c("A","B"),c(3,3),SubsetCoding=list(c("A","B"),list(rbind(scores),"Nominal")))

     # Constraint matrix for nominal by nominal model, equating parameters of last two categories of second variable:
     ConstraintMatrix(c("A","B"),c("A","B"),c(3,3),SubsetCoding=list(c("A","B"),list("Nominal",rbind(c(1,0,0),c(0,1,1)))))

