Computes the matrix of sums of squares and crossproducts for the multivariate general linear hypothesis HBU = G given the coefficient estimates
and the R matrix.
Required Arguments
H — NH by NCOEF matrix H with each row corresponding to a row in the hypothesis and containing the constants that specify an estimable linear combination of the regression coefficients. (Input)
B — NCOEF by NDEP matrix
containing a least-squares solution for the regression coefficients. (Input)
G — Matrix containing the null hypothesis values. (Input) If NU = 0, then G is NH by NDEP; otherwise, G is NH by NU.
R — NCOEF by NCOEF upper triangular matrix containing the R matrix. (Input) The R matrix can come from a regression fit based on a QR decomposition of the matrix of regressors or based on a Cholesky factorization RTR of the matrix of sums of squares and crossproducts of the regressors. Elements to the right of a diagonal element of R that is zero must also be zero. A zero row indicates a nonfull rank model. For an R matrix that comes from a regression fit with linear equality restrictions on the parameters, each row of R corresponding to a restriction must have a corresponding diagonal element that is negative. The remaining rows of R must have positive diagonal elements. Only the upper triangle of R is referenced.
SCPH — Matrix containing sums of squares and crossproducts attributable to the hypothesis. (Output) If NU = 0, SCPH is a NDEP by NDEP matrix, otherwise, SCPH is a NU by NU matrix.
Optional Arguments
NH — Number of rows in the hypothesis. (Input) Default: NH = size (H,1).
NCOEF — Number of regression coefficients in the model. (Input) Default: NCOEF = size (H,2).
LDH — Leading dimension of H exactly as specified in the dimension statement of the calling program. (Input) Default: LDH = size (H,1).
NDEP — Number of dependent (response) variables. (Input) Default: NDEP = size (B,2).
LDB — Leading dimension of B exactly as specified in the dimension statement in the calling program. (Input) Default: LDB = size (B,1).
NU — U matrix option. (Input) For positive NU, NU is the number of linear combinations of the dependent variables to be considered. If NU = 0, the hypothesis is HB = G, i.e., U is automatically taken to be the identity. NU must be less than or equal to NDEP. Default: NU = 0.
U — NDEP by NU matrix U in test HBU = G. (Input, if NU is positive) If NU = 0, U is not referenced and can be a 1 x 1 array. Default: U is a 1x 1 array.
LDU — Leading dimension of U exactly as specified in the dimension statement in the calling program. (Input) Default: LDU = size (U, 1,).
LDG — Leading dimension of G exactly as specified in the dimension statement in the calling program. (Input) Default: LDG = size (G,1).
LDR — Leading dimension of R exactly as specified in the dimension statement in the calling program. (Input) Default: LDR = size (R,1).
DFH — Degrees of freedom for SCPH. (Output) DFH equals the rank of H.
LDSCPH — Leading dimension of SCPH exactly as specified in the dimension statement in the calling program. (Input) Default: LDSCPH = size (SCPH,1).
FORTRAN 90 Interface
Generic: CALLRHPSS (H, B, G, R, SCPH[, …])
Specific: The specific interface names are S_RHPSS and D_RHPSS.
Routine RHPSS computes the matrix of sums of squares and crossproducts for the general linear hypothesis HBU = G for the multivariate general linear model Y = XB + E with possible linear equality restrictions AB = Z. (See the chapter introduction for a description of the Multivariate General Linear Model.) Routines RGLM, RGIVN, RLEQU, and RCOV can be used to compute the fit of the general linear model prior to invoking RHPSS. The R matrix and from any of those routines are required for input to RHPSS.
The rows of H must be linear combinations of the rows of R, i.e., HB = G must be completely testable. If the hypothesis is not completely testable, Routine CESTI can be used to construct an equivalent completely testable hypothesis.
Computations are based on an algorithm discussed by Kennedy and Gentle (1980, page 317) that is extended by Sallas and Lionti (1988) for multivariate nonfull rank models with possible linear equality restrictions. The algorithm is as follows:
1. Form
2. Find C as the solution of RTC = HT using routine GIRTS (IMSL MATH/LIBRARY). If the equations are declared inconsistent within a computed tolerance, an error message with code 1 is issued that the hypothesis is not completely testable.
3. For all rows of R corresponding to restrictions, i.e., containing negative diagonal elements from a restricted least-squares fit using RLEQU, zero out the corresponding rows of C, i.e., form DC.
4. Decompose DC using Householder transformations and column pivoting to yield a square, upper triangular matrix T with diagonal elements of nonincreasing magnitude and permutation matrix P such that
where Q is an orthogonal matrix.
5. Determine the rank of T, say r. If t11 = 0, then r = 0. Otherwise, the rank of T is r if
where ɛ = 10.0 * AMACH(4). Then, zero out all rows of T below row r. Set the degrees of freedom for the hypothesis, output in DFH, to r.
6. Find V as a solution to TTV = PTW using routine GIRTS. If the equations are inconsistent, an error message with code 2 is issued that the hypothesis is inconsistent within a computed tolerance, i.e., the linear system
H BU = G
AB=Z
does not have a solution for B.
7. Form VTV, which is the required matrix of sum of squares and crossproducts output in SCPH.
In general, the two errors with code 1 and 2 are serious user errors that require the user to correct the hypothesis before any meaningful sums of squares from this routine can be computed. However, in some cases, the user may know the hypothesis is consistent and completely testable, but the checks in RHPSS are too tight. For this reason, RHPSS continues with the computations.
Routine RHPSS gives a matrix of sums of squares and crossproducts that could also be obtained from separate fittings of the two models
Y* = XB* + E*
AB* = Z*
(1)
HB* = G
and
Y* = XB* + E*
AB* = Z*
(2)
where Y* = YU, B* = BU, E* = EU, and Z* = ZU. The error sum of squares and crossproduct matrix for (1) minus that for (2) is the matrix of sum of squares and crossproducts output in SCPH. Note that this approach avoids entirely the question of testability.
Comments
1. Workspace may be explicitly provided, if desired, by use of R2PSS/DR2PSS. The reference is:
WK — Work vector of length NH* (NDEP + NCOEF + max(NCOEF, NH) + 3) + NU*NDEP‑ 1.
2. Informational errors
Type
Code
Description
3
1
The hypothesis is not completely testable. Each row of H must be in the space spanned by the rows of R.
3
2
The hypothesis is inconsistent. The linear system HBU = G combined with any restrictions from a regression fit with linear equality restrictions must have a solution for B.
3. where (CTDC)− is a generalized inverse of CTDC, C is a solution to RTC = HT, and D is a diagonal matrix with
Examples
Example 1
A two-way analysis-of-variance model is fitted to balanced data discussed by Snedecor and Cochran (1967, Table 12.5.1, page 347). The responses are the weight gains (in grams) of rats fed diets varying in two components-level of protein and source of protein. The model is
WRITE (NOUT,*) ' Freedom Squares F-statistic Larger F'
WRITE (NOUT,99999) DFH, SCPH(1,1), F, PVALUE
99999 FORMAT (F8.1, 3X, 1F10.3, F11.3, 2X, F10.4)
END
Output
Degrees of Sum of Prob. of
Freedom Squares F-statistic Larger F
2.0 1178.135 2.746 0.0732
Example 2
The data for the second example are taken from Maindonald (1984, pages 203‑204). The data are saved in the matrix X. A multivariate regression model containing two dependent variables and three independent variables is fit using routine RGIVN. The sum of squares and crossproducts matrix is computed for the third independent variable in the model.