Contrasts in analysis of variance ---------------------------------
^contrast^ yvar fac1 [term2 term3 ...] [^if^ exp] [^in^ range] ^,^ ^coef^fs^(^coefflist^)^|^tr^end [ ^le^vel^(^#^)^ ^ad^just anova_options > ]
^contrast^ nvar meanvar sdvar [^if^ exp] [^in^ range] ^, me^ans ^coef^fs^(^coefflist|cvar^)^|^tr^end [ ^le^vel^(^#^)^ ]
^contrasi^ n1 mean1 sd1 [coeff1] ^\^ n2 mean2 sd2 [coeff2] [^\^ n3 mean3 sd3 [coeff3] ... ] [^, tr^end ^le^vel^(^#^)^ ]
^contrast^ calculates contrasts between factor levels or groups of continuous data. The command has two forms.
^contrasi^ is an "immediate" contrasts command; see [U] 25 Immediate commands.
See Remarks for a detailed description.
^level(^#^)^ defines the confidence interval coverage. Default: $S_level.
^trend^ makes the contrast coefficients equally spaced with spacing 1 (i.e. 1, 2, 3, ..., also known, confusingly, as a linear contrast) and then standardizes them. See Remarks for further details.
^adjust^ first calculates fitted values according to the full ANOVA model, then calculates means of these fitted values over the levels of fac1.
anova_options are any of Stata's standard @anova@ options.
Note that the first form of ^contrast^ permits arbitrarily complex analysis of variance or analysis of covariance models, whereas the second form and ^contrasi^ only support one-way analysis of variance models.
In all cases the contrast coefficients are `standardized' inside the program by subtraction of their mean, so as to add up to zero. These standardized coefficients are displayed as ^__a^ in the output.
A factor level or group may be omitted from a contrast (but NOT from the analysis of variance) by specifying the corresponding coefficient as missing (^.^). Note that a zero coefficient omits the corresponding level or group ONLY if all the coefficients you supply add up to zero, as otherwise the standardization changes the zero to a non-zero value of ^__a^ internally.
The output includes a confidence interval for L, a significance test for the hypothesis L = 0, an overall analysis of variance F-test that the group (or fac1) means are equal and the residual standard deviation from the analysis of variance.
First form ----------
The first form of ^contrast^ calculates the standardized contrast, L, for coeff > - icients in coefflist over the means of yvar defined by the levels (unique values) of fac1. That is, ^contrast^ calculates
L = (a1 * mean1) + (a2 * mean2) + (a3 * mean3) + ...
where mean1 is the mean of yvar at the lowest level of fac1 and a1 is the corresponding standardized coefficient in coeffvar, and so on.
If term2, term3, ... are given, the residual SD is calculated from an analysis of variance which includes fac1 and the other terms. Terms can be factors or continuous predictors; the latter are specified by using the @anova@ option ^continuous(^varlist^)^ (see help for @anova@).
Second form -----------
To use the second form of ^contrast^, you MUST specify the ^means^ option. The contrast (L) is calculated directly from frequencies, means and SDs stored in the variables nvar, meanvar and sdvar. The coefficients may be determined by specifying ^trend^, or entered directly in coefflist, or stored in a variable (coeffvar) whose rows contain the coefficients in the same order as the means of meanvar.
^contrasi^ carries out the same analysis as the second form of ^contrast^, but using frequencies, means, SDs and coefficients that you enter directly in n1, mean1, sd1, coeff1, etc. Omitting the coefficients (coeff1, coeff2, etc) is equivalent to specifying ^trend^.
. ^contrast price rep78, coeffs(1 2 3 4 5)^ . ^contrast price rep78 foreign, coeffs(1 1 2 2 .)^ . ^contrast price rep78 foreign mpg, coeffs(1 2 3 4 5) cont(mpg) adjust^
. ^contrast n ymean sd, means coeffs(c)^ . ^contrast n ymean sd, means coeffs(-1 1 2)^ . ^contrast n ymean sd, means trend level(90)^
. ^contrasi 25 12.2 4.3 -2 \ 44 17.3 6.2 1 \ 21 21.9 7.4 1^ . ^contrasi 25 12.2 4.3 \ 44 17.3 6.2 \ 21 21.9 7.4, trend^ . ^contrasi 25 12.2 4.3 \ 44 17.3 6.2 \ 21 21.9 7.4^ (same as previous)
^$S_1^ number of observations in analysis of variance ^$S_2^ number of groups in analysis of variance ^$S_3^ value of standardized contrast, L ^$S_4^ standard error of L ^$S_5^ lower confidence limit for L ^$S_6^ upper confidence limit for L ^$S_7^ t value for test of L = 0 ^$S_8^ P value for test of L = 0
Also see --------
Manual: [R] anova, oneway On-line: help for @anova@, @oneway@