1. Home
  2. RCOMPARISONS procedure

RCOMPARISONS procedure

Calculates comparison contrasts amongst regression means (R.W. Payne).

Options

PRINT = string tokens Controls printed output (aov, contrasts); default aov, cont
COMBINATIONS = string token Factor combinations for which to form the predicted means (full, present, estimable); default esti
ADJUSTMENT = string token Type of adjustment to be made when forming the predicted means (marginal, equal, observed); default marg
PSE = string tokens Types of standard errors to be printed with the contrasts (contrasts, differences, lsd); default cont
WEIGHTS = table Weights classified by some or all of the factors in the model; default *
OFFSET = scalar Value of offset on which to base predictions; default mean of offset variate
METHOD = string token Method of forming margin (mean, total); default mean
ALIASING = string token How to deal with aliased parameters (fault, ignore); default faul
BACKTRANSFORM = string token What back-transformation to apply to the values on the linear scale, before calculating the predicted means (link, none); default link
SCOPE = string token Controls whether the variance of predictions is calculated on the basis of forecasting new observations rather than summarizing the data to which the model has been fitted (data, new); default data
NOMESSAGE = string tokens Which warning messages to suppress (dispersion, nonlinear); default *
DISPERSION = scalar Value of dispersion parameter in calculation of s.e.s; default is as set in the MODEL statement
DMETHOD = string token Basis of estimate of dispersion, if not fixed by DISPERSION option (deviance, Pearson); default is as set in the MODEL statement
NBINOMIAL = scalar Supplies the total number of trials to be used for prediction with a binomial distribution (providing a value n greater than one allows predictions to be made of the number of “successes” out of n, whereas the value one predicts the proportion of successes); default 1
LSDLEVEL = scalar Significance level (%) for least significant differences; default 5
SAVE = identifier Regression save structure for the analysis from which the comparison contrasts are to be calculated

Parameters

FACTOR = factors Factor whose levels are compared
CONTRASTS = matrices Defines the comparisons to be estimated
ORDER = scalars Number of comparisons to estimate; default is the number of rows of the CONTRASTS matrix
GROUPS = factors or pointers Set if comparisons are to be made at different combinations of another factor or factors
ESTIMATES = variates or pointers Saves the estimated contrasts in a variate if GROUPS is unset, or in a pointer to a set of tables
SE = variates or pointers Saves standard errors of the contrasts in a variate if GROUPS is unset, or in a pointer to a set of tables
SED = pointers Pointer to a set of symmetric matrices to save standard errors for differences between the contrasts estimated for different levels of the GROUPS factor(s)
LSD = pointers Pointer to a set of symmetric matrices to save least significant differences for the contrasts estimated for different levels of the GROUPS factor(s)
DEVIANCES = variates Saves sums of squares or deviances of the contrasts
DF = variates Saves degrees of freedom for the contrasts

Description

RCOMPARISONS allows you to make comparisons between predicted means from a linear or generalized linear regression. The model should previously have been fitted by the FIT directive in the usual way. The SAVE option can be used to specify the regression save structure from the analysis for which the comparisons are to be calculated (see the SAVE option of the MODEL directive). If SAVE is not specified, the comparisons are calculated from the most recent regression analysis.

The factor amongst whose levels the comparisons are to be calculated is specified by the FACTOR parameter. The CONTRASTS parameter supplies a matrix to specify the comparisons to be calculated. This works in the same way as the matrix supplied as the third parameter of the COMPARISON function, with a column for each level of the FACTOR, and a row for each comparison. You can set the ORDER parameter to a scalar, n say, to indicate that only the comparisons in the first n rows of the CONTRASTS matrix are to be calculated (otherwise they are all calculated).

By default the comparisons are calculated between the means in the one-way table classified by FACTOR. However, you can set the GROUPS parameter to some other factor to indicate that the comparisons are to be made for each level of that factor, or you can set it to a pointer of factors to make the comparisons for every combination of the levels of those factors.

RCOMPARISONS calculates the means using the PREDICT directive. The first step (A) of the calculation forms the full table of predictions, classified by every factor in the model. The second step (B) averages the full table over the factors that do not occur in the table of means. The COMBINATIONS option specifies which cells of the full table are to be formed in Step A. The default setting, estimable, fills in all the cells other than those that involve parameters that cannot be estimated, for example because of aliasing. Alternatively, setting COMBINATIONS=present excludes the cells for factor combinations that do not occur in the data, or COMBINATIONS=full uses all the cells. The ADJUSTMENT option then defines how the averaging is done in Step B. The default setting, marginal, forms a table of marginal weights for each factor, containing the proportion of observations with each of its levels; the full table of weights is then formed from the product of the marginal tables. The setting equal weights all the combinations equally. Finally, the setting observed uses the WEIGHTS option of PREDICT to weight each factor combination according to its own individual replication in the data. Alternatively, you can supply your own table of weights, using the WEIGHTS option. There are also options OFFSET, METHOD, ALIASING, BACKTRANSFORM, SCOPE, NOMESSAGE, DISPERSION, DMETHOD and NBINOMIAL to control further aspects of the calculations; these operate exactly as in the PREDICT directive.

The PRINT option controls printed output, with settings:

    aov to print an analysis of variance (for an ordinary linear regression) or an analysis of deviance (for a generalized linear model), giving the sums of squares (or deviances) and so on for the comparisons;
    contrasts to print the contrasts.

By default these are both printed. The PSE option controls the types of standard errors that are produced to accompany the contrasts, with settings:

    contrasts for standard errors of the contrasts;
    differences for standard errors for differences between pairs of contrasts calculated for the different GROUPS;
    lsd for least significant differences for contrasts calculated for the GROUPS.

The default is contrasts. The LSDLEVEL option sets the significance level (as a percentage) for the least significant differences.

The ESTIMATES parameter allows you to save the estimated contrasts. These are in a variate if GROUPS is unset, or in a pointer containing a table classified by GROUPS for each comparison otherwise. The SE parameter saves the standard errors of the contrasts, in a variate or pointer similarly to ESTIMATES. If GROUPS is set, you can also save standard errors for differences between the contrasts estimated for different levels of the GROUPS factor(s). This is again a pointer, with a symmetric matrix for each comparison. Finally, the DF parameter can save a variate containing the degrees of freedom of the contrasts, and the DEVIANCES parameter can save a variate with their deviances (for a generalized linear model) or sums of squares (for an ordinary linear regression).

Options: PRINT, COMBINATIONS, ADJUSTMENT, PSE, WEIGHTS, OFFSET, METHOD, ALIASING, BACKTRANSFORM, SCOPE, NOMESSAGE, DISPERSION, DMETHOD, NBINOMIAL, LSDLEVEL, SAVE.

Parameters: FACTOR, CONTRASTS, ORDER, GROUPS, ESTIMATES, SE, SED, LSD, DEVIANCES, DF.

Method

The predicted means and their variances and covariances are calculated using the PREDICT directive. The comparisons, their standard errors and sums of squares are then calculated using Genstat’s table and matrix calculation facilities.

See also

Directive: PREDICT.

Procedures: FCONTRASTS, RTCOMPARISONS, VTCOMPARISONS.

Commands for: Regression analysis.

Example

CAPTION      'RCOMPARISONS example',\
             !t('3x2 factorial experiment (Snedecor & Cochran, 1980,',\
             'Statistical Methods, seventh edition, p. 305).');\
             STYLE=meta,plain
FACTOR       [NVALUES=60; LABELS=!T(high,low); VALUES=3(1,2)10] Amount
&            [LABELS=!T(beef,cereal,pork); VALUES=(1...3)20] Source
VARIATE      [NVALUE=60] Gain
READ         Gain
 73  98  94  90 107  49
102  74  79  76  95  82
118  56  96  90  97  73
104 111  98  64  80  86
 81  95 102  86  98  81
107  88 102  51  74  97
100  82 108  72  74 106
 87  77  91  90  67  70
117  86 120  95  89  61
111  92 105  78  58  82 :
MODEL        Gain
FIT          Source*Amount
MATRIX       [ROWS=!T('animal vs cereal','beef vs pork'); COLUMNS=3;\ 
             VALUES=0.5,-1,0.5,1,0,-1] Compare
RCOMPARISONS Source; CONTRASTS=Compare
&            [PSE=contrasts,differences,lsd]\
             Source; CONTRASTS=Compare; GROUPS=Amount
Updated on June 18, 2019

Was this article helpful?