1. Home
  2. FCONTRASTS procedure

FCONTRASTS procedure

Modifies a model formula to contain contrasts of factors (R.W. Payne).

Options

FORMULA = formula Formula to modify to contain contrasts
NEWFORMULA = formula structure Modified formula; if unset, the modified formula replaces FORMULA
FACTORIAL = scalar Limit on the number of variates or factors in terms generated from FORMULA; default 3

Parameters

FACTOR = factors Factors over which to define contrasts
CONTRASTTYPE = string tokens Type of contrast (polynomial, regression); default poly
ORDER = scalars Number of contrasts to define for each FACTOR
XCONTRASTS = variates or matrices X-values defining the contrasts for each FACTOR
DEVIATIONS = string tokens Whether to include deviations (yes, no); default no
ORTHOGONALIZE = string tokens Whether to orthogonalize the contrasts (yes, no); default no
SAVECONTRASTS = pointers Pointer to save the contrast variates defined for each FACTOR

Description

FCONTRASTS provides a way of fitting contrasts amongst the levels of factors in analyses such as REML that currently do not allow the use of the Genstat contrast functions like POL and REG. To fit contrasts here, you need to fit x-variates that represent the contrasts explicitly during the analysis. So, if you wanted to fit linear and quadratic contrasts of a factor N, you would need to calculate variates Nlin and Nquad, representing the linear and quadratic contrasts of N, and fit those in the analysis instead of N: i.e. instead of setting option

FIXED=POL(N; 2)

in the VCOMPONENTS directive, you need to calculate Nlin and Nquad by

CALCULATE Nlin = N

& Nquad = Nlin * Nlin

and then set

FIXED=Nlin+Nquad

FCONTRASTS allows you to form the contrast variates and include them in a formula automatically. The formula to be modified is specified, as a formula data structure, by the FORMULA option. The new formula is saved by the NEWFORMULA option. If this is not set, the new formula replaces the original formula specified by the FORMULA option. The formula needs to be expanded into its individual model terms in order to make the modification. The FACTORIAL option sets a limit on the number of factors or variates in the terms that are formed.

The FACTOR parameter specifies the factors that are to be replaced in the formula by contrasts. The CONTRASTTYPE parameter specified the type of contrast and the ORDER parameter specifies the number of contrasts to be generated for each factor. For polynomial contrasts, the XCONTRASTS parameter can specify the x-value to be used for each level of the factor; if this is not set, the factor’s existing levels are used.

The DEVIATIONS parameter can be set to yes to include contrasts to represent the deviations from the fitted contrasts that are required to explain all the effects of the factor. These are orthogonalized to the other contrasts and so, if only the main effect of the factor is fitted, the estimates other contrasts will be unaffected by the fitting of the deviations. This orthogonalization may not work for interactions between the factor and other factors. So, if you find that the deviations are not needed in the model, you should then refit the model without the deviations in order to get the estimates of the contrasts themselves. (Of course, if you find that the deviations are needed, then the contrasts are not really of any interest.) You can set the parameter ORTHOGONALIZE=yes to orthogonalize the contrasts themselves. Again, this orthogonalization may work only for the main effect of the factor, and not for interactions with other factors.

The contrasts variates are defined with extra texts, using the EXTRA parameter of the VARIATE directive, which give the name of the factor and of the individual contrast (e.g. lin or quad). The IPRINT option is set to extra at the same time so that these texts are used to label the contrasts in the analysis. If you want to use the contrast variates in any other way, you need to save them a pointer, which can be supplied by the SAVECONTRASTS parameter.

Options: FORMULA, NEWFORMULA, FACTORIAL.

Parameters: FACTOR, CONTRASTTYPE, ORDER, XCONTRASTS, DEVIATIONS, ORTHOGONALIZE, SAVECONTRASTS.

Action with RESTRICT

FCONTRASTS takes account of any restrictions on the factors or variates in the FORMULA.

See also

Directives: TERMS, TREATMENTSTRUCTURE, VCOMPONENTS.

Procedures: RCOMPARISONS, RTCOMPARISONS, VTCOMPARISONS.

Functions: COMPARISON, POL, POLND, REG, REGND.

Commands for: Regression analysis, Analysis of variance, REML analysis of linear mixed models.

Example

CAPTION     'FCONTRASTS example',\
            'Split-plot example from Guide Part 2, Section 4.5';\
            STYLE=meta,plain
FACTOR      [NVALUES=72; LEVELS=6] Blocks
&           [LEVELS=3] Wplots
&           [LEVELS=4] Subplots
GENERATE    Blocks,Wplots,Subplots
FACTOR      [LABELS=!T('0 cwt','0.2 cwt','0.4 cwt','0.6 cwt')] Nitrogen
&           [LABELS=!T(Victory,'Golden rain',Marvellous)] Variety
VARIATE     [NVALUES=72] Yield
READ        [SERIAL=yes] Nitrogen,Variety,Yield
 4 3 2 1 1 2 4 3 1 2 3 4 3 1 2 4 4 1 2 3 2 1 3 4
 2 3 4 1 4 2 3 1 1 4 2 3 3 4 1 2 1 3 4 2 2 3 4 1
 4 1 3 2 3 4 1 2 3 4 2 1 3 1 4 2 4 3 1 2 1 2 3 4 :
 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 1 1 1 1 2 2 2 2
 2 2 2 2 3 3 3 3 1 1 1 1 3 3 3 3 2 2 2 2 1 1 1 1
 2 2 2 2 1 1 1 1 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 :
156 118 140 105 111 130 174 157 117 114 161 141
104  70  89 117 122  74  89  81 103  64 132 133
108 126 149  70 144 124 121  96  61 100  91  97
109  99  63  70  80  94 126  82  90 100 116  62
 96  60  89 102 112  86  68  64 132 124 129  89
118  53 113  74 104  86  89  82  97  99 119 121 :
VARIATE     [VALUES=0,0.2,0.4,0.6] Nitlev
FCONTRASTS  [FORMULA=Nitrogen * Variety; NEWFORMULA=fpol]\
            Nitrogen; ORDER=2; XCONTRASTS=Nitlev; ORTHOGONALIZE=yes;\
            DEVIATIONS=yes
VCOMPONENTS [FIXED=#fpol] Blocks/Wplots/Subplots
REML        [PRINT=model,components,Wald] Yield
" compare with ANOVA "
BLOCK       Blocks/Wplots/Subplots
TREATMENTS  POL(Nitrogen;2;Nitlev) * Variety
ANOVA       [PRINT=aov,stratum] Yield
Updated on June 19, 2019

Was this article helpful?