Compute the model matrix for a hierarchical log-linear model. This is
an internal routine and is not normally called directly by users.
USAGE:
Loglin.get.x(data, margins)
REQUIRED ARGUMENTS:
data
a data frame or matrix containing the raw data. When
a data frame is input, the table is specified by the
levels of the factor variables. When the input object
is a matrix, it is assumed that the levels of each variable (column)
form a sequence
of integers from one to the maximum value of the variable.
OPTIONAL ARGUMENTS:
margins
a formula or a list of vectors containing the marginal totals to be
fit. A margin is described by the factors not summed over. Thus
list(1:2, 3:4) would indicate fitting the 1,2 margin (summing over
variables 3 and 4) and the 3,4 margin in a four-way table. This same
model can be specified using the names of the variables (e.g.,
list(c("V1", "V2"), c("V3", "V4"))), or using formula notation, as in
margins = ~V1:V2 + V3:V4. When formula notation is used, the
argument
frequency can be included as the dependent variable (as in
margins = frequency~V1:V2 + V3:V4). If
margins is not specified, a
saturated models (a single interaction term containing all table
variables) is fit. When a matrix is input, every column in the matrix
is used to define the table. When a data frame is
input, the table is defined by the factor variables in the
data frame.
VALUE:
a list containing:
x
the model matrix.
levs
the number of levels in each column in
x.
iy
the column number of the frequency variable argument in argument
data.
nmarg
a vector containing a listing of the margins to be fitted.
saturated.model
TRUE if the model is saturated, and FALSE otherwise
slevs
a list containing the names associated with each of the levels in each
column of the design matrix.
DETAILS:
This is an internal routine and is not usually called directly by users.