CTRST
Computes contrast estimates and sums of squares.
Required Arguments
NI — Vector of length NGROUP containing the number of responses for each of the NGROUP groups. (Input)
YMEANS — Vector of length NGROUP containing the sample mean for each group or each level of a classification variable. (Input)
C — NGROUP by NCTRST matrix containing in each column the coefficients for a particular contrast. (Input)
EST — Vector of length NCTRST containing the contrast estimates. (Output)
SS — Vector of length NCTRST containing the sum of squares associated with each contrast. (Output)
Optional Arguments
NGROUP — Number of groups or number of sample means involved in the
contrasts. (Input)
Default: NGROUP = size (NI,1).
NCTRST — Number of contrasts. (Input)
Default: NCTRST = size (C,2).
LDC — Leading dimension of C exactly as specified in the dimension statement in the calling program. (Input)
Default: LDC = size (C,1).
FORTRAN 90 Interface
Generic: CALL CTRST (NI, YMEANS, C, EST, SS [, …])
Specific: The specific interface names are S_CTRST and D_CTRST.
FORTRAN 77 Interface
Single: CALL CTRST (NGROUP, NI, YMEANS, NCTRST, C, LDC, EST, SS)
Double: The double precision name is DCTRST.
Description
Routine CTRST computes an estimate of a linear combination of means using the sample means input in YMEANS. The sum of squares associated with each estimate is also computed.
Contrasts (linear combinations of means whose coefficients sum to zero) are customarily of interest. Orthogonal contrasts (Neter and Wasserman 1974, pages 470‑471) are often used to partition the among-groups sum of squares from a one-way analysis of variance. The following discussion uses the term “contrast”, however, the term “linear combination of means,” which places no restriction on the coefficients, is equally valid.
Let
be the k(= NGROUP) sample means, and let μ1, μ2, …, μk be the associated population means. Let c1j, c2j, …, ckj be the contrast coefficients for contrast j (stored in column j of the matrix C). The estimate of
is
(stored as the j-th element of EST) computed by
The associated sum of squares Qj (stored as the j-th element of SS) is computed by
Comments
Informational Error
Type |
Code |
Description |
1 |
1 |
A column of C does not sum to zero within the computed tolerance. Customarily, contrasts (linear combinations of means whose coefficients sum to zero) are of interest. |
Example
The following example is taken from Neter and Wasserman (1974, Table 13.1, page 432, Table 14.3, page 463, pages 470-471). Three orthogonal contrasts are defined that partition the among-group sum of squares (258.0) from a one-way analysis of variance. The first contrast compares groups 1 and 2, the second contrast compares groups 3 and 4, the third contrast compares a weighted average of groups 1 and 2 with a weighted average of groups 3 and 4.
USE CTRST_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER NGROUP, LDC, NCTRST, I
PARAMETER (NGROUP=4, LDC=NGROUP, NCTRST=3)
INTEGER NI(NGROUP), J, NOUT
REAL EST(NCTRST), SS(NCTRST), C(LDC,NCTRST), YMEANS(NGROUP)
!
DATA YMEANS/15.0, 13.0, 19.0, 27.0/
DATA NI/2, 3, 3, 2/
DATA (C(I,1),I=1,NGROUP)/1.0, -1.0, 0.0, 0.0/
DATA (C(I,2),I=1,NGROUP)/0.0, 0.0, 1.0, -1.0/
DATA (C(I,3),I=1,NGROUP)/0.4, 0.6, -0.6, -0.4/
!
CALL CTRST (NI, YMEANS, C, EST, SS)
CALL UMACH (2, NOUT)
WRITE (NOUT,*) 'Contrast Estimate Sum of Squares'
DO 10 J=1, NCTRST
WRITE (NOUT,'(1X,I4,5X,F7.1,3X,F10.1)') J, EST(J), SS(J)
10 CONTINUE
END
Output
Contrast Estimate Sum of Squares
1 2.0 4.8
2 -8.0 76.8
3 -8.4 176.4