Learn R Programming

rms (version 7.0-0)

infoMxop: Operate on Information Matrices

Description

Processes three types of information matrices: ones produced by the SparseM package for the orm function in rms version 6.9-0 and earlier, by the Matrix package for version 7.0-0 of rms, or plain matrices. For Matrix, the input information matrix is a list with three elements: a containing in two columns the diagonal and superdiagonal for intercepts, b, a square matrix for the covariates, and ab for intercepts x covariates. If nothing else is specified, the assembled information matrix is returned for Matrix, or the original info otherwise. If p=TRUE, the number of parameters in the model (number of rows and columns in the whole information matrix) is returned. If i is given, the i elements of the inverse of info are returned, using efficient calculation to avoid inverting the whole matrix. Otherwise if invert=TRUE or B is given without i, the efficiently (if Matrix or SparseM) inverted matrix is returned, or the matrix multiplication of the inverse and B. If both i and B are given, what is returned is the i portion of the inverse of the information matrix, matrix multiplied by B. This is done inside solve().

Usage

infoMxop(
  info,
  i,
  invert = !missing(i) || !missing(B),
  B,
  np = FALSE,
  tol = .Machine$double.eps,
  abort = TRUE
)

Value

a single integer or a matrix

Arguments

info

an information matrix object

i

integer vector specifying elements returned from the inverse. You an also specify i='x' to return non-intercepts or i='i' to return intercepts.

invert

set to TRUE to invert info (implied when i or B is given)

B

multiplier matrix

np

set to TRUE to just fetch the total number of parameters (intercepts + betas)

tol

tolerance for matrix inversion singularity

abort

set to FALSE to run the solve calculation through try() without aborting; the user will detect that the operation did not success by examinine inherits(result, 'try-error') for being TRUE.

Author

Frank Harrell

Details

When only variance-covariance matrix elements corresponding to the non-intercepts are desired, specify i='x' or i=(k + 1) : nv where nv is the number of intercepts and slopes combined. infoMxop computes the needed covariance matrix very quickly in this case. When inverting info, if info has a 'scale' attribute with elements mean and sd, the scaling is reversed after inverting info.

Examples

Run this code
if (FALSE) {
f <- orm(y ~ x)
infoMxop(f$info.matrix)   # assembles 3 pieces
infoMxop(v, i=c(2,4))     # returns a submatrix of v inverse
infoMxop(f$info.matrix, i='x')  # sub-covariance matrix for just the betas
}

Run the code above in your browser using DataLab