Next: models Up: MacAnova Help File Previous: min()   Contents


modelinfo([all:T] keyword1:T or F, keyword2:T or F ...[,nomodelok:T]\
  [,missing:missvalue]), missvalue a REAL scalar and the keywords
  are one or more of 'aliased', 'bitmodel', 'coefs', 'colcount',
  'distrib', 'link', 'parameters', 'scale', 'sigmahat' 'strmodel',
  'termnames', 'weights', 'xtxinv', 'xvars', and 'y'

Keywords: glm
modelinfo(keyword1:T, keyword2:T, ... ) computes one or more vectors or
matrices associated the most recent GLM (generalized linear or linear
model) command such as regress(), anova(), poisson(), or glmfit().  This
gives you direct access to such things as the design variables or
X-variables (xvars:T), the estimated coefficients of the X-variables
(coefs:T), and the inverse of the X'X matrix (xtxinv:T).

Permissible keyword names specifying quantities returned are 'aliased',
'bitmodel', 'coefs', 'colcount', 'distrib', 'link', 'parameters',
'scale', 'sigmahat' 'strmodel', 'termnames', 'weights', 'xtxinv',
'xvars', and 'y'.  You can also use 'all:T'; see below.

You can't use modelinfo() after fastanova(), ipf(), or screen().

Any component requested that is not available is set to NULL.  In
particular this happens for components 'coefs' and 'xtxinv' after
anova() when the model is balanced, or after any GLM command with
'coefs:F', and for component parameters after any GLM for which a sample
size or other parameter is specified such as for logistic() and

When more than one of the keywords specifying type of output has value
True, modelinfo() returns a structure with component names the same as
the keywords.  Otherwise it returns a vector or matrix.

modelinfo(xvars:T, ..., missing:missval) returns the matrix of
X-variables associated with the active model with all the values for a
case in which there was missing data set to REAL scalar missval.  The
default value is 0.

modelinfo(all:T) is equivalent to modelinfo(xvars:T,y:T,coefs:T,
termnames:T, scale:T, sigmahat:T,aliased:T).  To suppress any particular
components, say 'strmodel', 'bitmodel', and 'termnames', use
modelinfo(all:T, strmodel:F,bitmodel:F,termnames:F).  Use of all:F is an

Normally, it is an error if there is no active GLM model.  However, if
nomodelok:T is an argument, when there is no active model modelinfo()
returns NULL without printing an error message.  For example, you can
test for the existence of an active model by

  Cmd> if(isnull(modelinfo(strmodel:T,nomodelok:T))){ something...}

You can use 'nomodelok:T' with any of the keywords specifying components
to return.

See isnull().

                      Permissible Keyword Phrases
     A LOGICAL vector whose length is the number of X-variables in the
     model.  The i-th variable is True if and only if the i-th
     X-variables as returned by xvars:T is aliased with previous
     X-variables.  If there was no aliasing every element should be

     A REAL vector or matrix with as many rows as there are terms in the
     model, including the CONSTANT term, if any, but excluding the final
     error term.  This encodes the model in a special form.  See below
     for details.

     The vector of coefficients of the X-variables in the fitted model.
     Coefficients corresponding to aliased X-variables (those that are
     apparently linearly dependent on previous X-variables) are set to
     zero.  After manova() with a p-dimensional response matrix, the
     coefficients form a matrix with p columns.  Note: If there are
     factors in the model, some of the coefficients computed will differ
     from the coefficients computed by coefs() and secoefs().

     A REAL vector containing the numbers of X-variables assocated with
     each term in the active model.  The numbers of the first column
     associated with each term can be obtained by autoreg(1,
     modelinfo(colcount:T)).  If no X-variables are aliased with earlier
     X-variables, these values are the degrees of freedom associated
     with each term.

     A REAL vector containing the sample sizes or other distribution
     parameters after logistic() or probit(), or after glmfit() with
     keywords n or parameters.

     A REAL factor or factors to multiply the square roots of the
     diagonals of the inverse of the X'X matrix so as to obtain
     estimated standard errors for the estimated coefficients.  After
     logistic(), poisson(), probit(), or glmfit(), scale will be the
     default value, unless changed by keyword 'scale' on the GLM
     command.  After other GLM commands, including robust(), scale will
     be sqrt(SSerror/DFerror), where DFerror and SSerror come from the
     final line of the ANOVA table.  After manova(), scale will be the
     vector consisting of the square roots of diagonal elements of
     SSerror/DFerror, where SSerror is the error matrix.

     The robust estimate of sigma printed after the robust() ANOVA
     table.  It is not usable after any other GLM command.  Note that
     this is not a suitable value to use in computing standard errors.

     A CHARACTER variable containing the current model taken from

     A CHARACTER vector of the terms in the model taken from TERMNAMES.
     This includes the name (usually "ERROR1") of the final error term,
     and thus the length of the result is 1 greater than the number of
     rows in modelinfo(bitmodel:T).

     A REAL vector containing the weights associated with each case.  If
     there are no missing data and no weights were specified, either
     explicitly or implicitly, this is a vector of 1's.  Otherwise it
     contains either the weights specified by keyword 'weights' or 'wts'
     in anova(), manova() or regress() or the implicit weights from the
     final iteration of poisson(), logistic(), or robust().  The weight
     for any case with MISSING data is always zero.

     The inverse of the X'X matrix computed from the X-variables.  The
     row and column corresponding to any aliased X-variable is set to
     zero.  If the previous GLM command specified weights either
     explicitly (keyword 'weights' or 'wts' on anova(), regress(),
     manova()) or implicitly (poisson() or logistic()) the matrix
     computed is the inverse of X'WX, where W is the diagonal matrix of
     the weights.  After robust(), the matrix computed is the inverse of
     X'X, ignoring the implicit weights.  The weights may be obtained by
     keyword phrase weights:T (see above).

     The matrix of X-variables associated with the active model.  If
     there is no active model, but STRMODEL is defined and there are no
     other keywords, it works identically to xvariables().

     When 'missing:missValue' is an argument, where missValue is a REAL
     scalar, the X-variable values for a case with any missing data will
     be set to missValue.  In particular, you can used 'missing:?' to
     set the X-variables for a case with MISSING data to MISSING.  The
     default value is 0.  See xvariables() for more information.

     The dependent variable in the model as a vector or matrix.
     modelinfo(y:T) is thus equivalent to modelvars(0).

Each row of modelinfo(bitmodel:T) corresponds to a term in the model and
consists of one or more integers between 0 and 4294967295 = 2^32 - 1,
the bits of whose binary representation encode the variates and/or
factors in that term.  If there are 33 to 64 or 65 to 95 variates and
factors, the result is a matrix with 2 or 3 columns.  Thus each row of
the output has room for Nvar bits, where Nvar is the number of variates
and/or factors in the model.

The bits of each row should be considered to be numbered from 1 to Nvar.
Bit 1 is the least significant and bit 32 is the most significant bit of
the first element; bit 33 is the least significant and bit 64 is the
most significant bit of the second element, if any; and bit 65 is the
least significant and bit 96 is the most significant bit of the third
element, if any.  Bit i of row j of the result is 1 if and only if the
i-th variable or factor is in the j-th term of the model, following the
order in which variables and factors first appear in the model.  All the
elements in a row corresponding to the CONSTANT term (usually row 1) are

See topics 'bit_ops' and nbits() for information on how to extract
information from the result of modelinfo(bitmodel:T).

See also topics varnames(), modelvars(), xvariables(), coefs(),
secoefs(), glmpred(), glmtable(), regpred(), predtable(), popmodel(),
pushmodel(), 'models'.

Gary Oehlert 2003-01-15