Retrieves a symmetric submatrix from a symmetric matrix.
Required Arguments
A — NA by NA symmetric matrix. (Input) Only the upper triangle of A is referenced.
SWEPT — Vector of length NA. (Input) Element A(I, J) is included in submatrix ASUB if and only if SWEPT(I) > 0.0 and SWEPT(J) > 0.0.
NASUB — Order of submatrix ASUB. (Output) NASUB equals the number of elements in SWEPT that are greater than zero.
ASUB — NASUB by NASUB symmetric matrix containing a submatrix of A. (Output) If A is not needed, ASUB and A can share the same storage locations.
Optional Arguments
NA — Order of matrix A. (Input) Default: NA = size (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement of the calling program. (Input) Default: LDA = size (A,1).
LDASUB — Leading dimension of ASUB exactly as specified in the dimension statement of the calling program. (Input) Default: LDASUB = size (ASUB,1).
FORTRAN 90 Interface
Generic: CALLRSUBM (A, SWEPT, NASUB, ASUB[, …])
Specific: The specific interface names are S_RSUBM and D_RSUBM.
FORTRAN 77 Interface
Single: CALLRSUBM (NA, A, LDA, SWEPT, NASUB, ASUB, LDASUB)
Double: The double precision name is DRSUBM.
Description
Routine RSUBM retrieves a symmetric submatrix from a symmetric matrix A. If elements i and j of the input vector SWEPT are greater than zero, then the ij-th element of A is output in the submatrix ASUB. Otherwise, the ij-th element of A will not be included in ASUB. (Here, i = 1, 2, …, NA, and j = 1, 2, …, NA, where NA is the order of A.)
Routine RSUBM can be useful in conjunction with two routines, GSWEP and RSTEP. The routine RSUBM can be used after routine GSWEP in order to retrieve the submatrix of A that corresponds to the rows/columns that have been successfully swept. In this case, the SWEPT vector output from GSWEP can be used as the input for the argument SWEPT in RSUBM. Also, RSUBM can be used after routine RSTEP in order to retrieve the submatrix of COVS that corresponds to the independent variables in the final model. In this case, the HIST vector output from RSTEP can be used as the input for the argument SWEPT in RSUBM.
Comments
1. Workspace may be explicitly provided, if desired, by use of R2UBM/DR2UBM. The reference is:
CALLR2UBM (NA, A, LDA, SWEPT, NASUB, ASUB, LDASUB, IWK)
The additional argument is:
IWK — Vector of length NASUB.
2. Routine RSUBM can be used after invoking routines GSWEP and RSTEP in order to retrieve the submatrix for the variables in the model.
Examples
Example 1
The 2 × 2 symmetric submatrix ASUB is retrieved from rows and columns 1 and 4 of the 4 × 4 symmetric matrix A.
USE RSUBM_INT
USE WRRRN_INT
IMPLICIT NONE
INTEGER LDA, LDASUB, NA
PARAMETER (LDASUB=2, NA=4, LDA=NA)
!
INTEGER NASUB
REAL A(LDA,NA), ASUB(LDASUB,LDASUB), SWEPT(NA)
!
DATA SWEPT/1.0, -1.0, -1.0, 1.0/
DATA A/10.0, 20.0, 40.0, 70.0, 20.0, 30.0, 50.0, 80.0, 40.0,&
50.0, 60.0, 90.0, 70.0, 80.0, 90.0, 100.0/
!
CALL RSUBM (A, SWEPT, NASUB, ASUB)
CALL WRRRN ('ASUB', ASUB)
END
Output
ASUB
1 2
1 10.0 70.0
2 70.0 100.0
Example 2
This example invokes RSUBM after routine RSTEP in order to retrieve the submatrix of COVS that corresponds to the independent variables in the final stepwise model. With this submatrix, routine BLINF (IMSL MATH/LIBRARY) is used to compute the estimated standard deviation for the intercept in the final model.
A data set from Draper and Smith (1981, pages 629‑630) is used. The means and the corrected sum of squares and crossproducts matrix for this data are given in the DATA statements. They can be computed using routine CORVC in Chapter 3, “Correlation”. The first four entries in XMEAN and the first four columns of COV correspond to the independent variables, the last entry in XMEAN and the last column of COV correspond to the dependent variable.
After RSTEP is invoked to obtain a model, the intercept is computed using the formula
where k is the number of independent variables in the final model. The estimated standard deviation of the intercept is computed using the formula
where s2 is the error mean square from the fit (stored in AOV(8)), n is the number of observations, is the subvector of means for the independent variables in the final model (in this case the first mean and the fourth mean), and A is the submatrix (in this case with rows and columns 1 and 4) of the matrix COVS that is output by RSTEP.