View source: R/contr.helmert.unweighted.R
contr.helmert.unweighted | R Documentation |
Returns a matrix of Helmert contrasts, scaled so that the resulting contrast estimates (in an ANOVA or regression model) correspond to the difference between the levels (categories) being compared. The contrasts may be computed either based on a numerical number of levels or a vector of data.
contr.helmert.unweighted( x, reference.levels = my.levels[-length(my.levels)], n = NULL )
x |
a factor variable (or variable that can be coerced to a factor) for which contrasts should be calculated. |
reference.levels |
vector specifying, in order, the category treated as the reference level (i.e., assigned the next negative value) in each successive contrast. |
n |
a vector of levels for a factor, or the number of levels, which can
be provided instead of |
Helmert contrasts compare the second level with the first, the third with the average of the first two, and so on. As with other contrasts, they are orthogonal to each other and to the intercept.
When the levels differ in frequency, unweighted coding is appropriate if the differences in frequency in the sample are merely incidental (e.g., both conditions were intended to be presented equally frequently, but by chance there are more observations from one condition than another). (If the differences in frequency instead represent genuine differences in the population, weighted coding may be more appropriate.)
If all of the factor levels are equally common, there is no difference between unweighted and weighted coding.
A matrix with n
rows and k
columns, where n
is
the number of levels and k=n-1
.
Cohen, J., Cohen, P., West, S.G., & Aiken, L.S. (2002). Categorical or nominal independent variables. In Applied multiple regression/ correlation analysis for the behavioral sciences (3rd ed., pp. 302-353). Mahwah, NJ: Lawrence Erlbaum Associates.
contr.helmert.weighted
for weighted Helmert
contrasts, and contrasts
and contr.helmert
.
contr.helmert.unweighted(n=4) contr.helmert.unweighted(n=c('Active','Passive'), reference.levels=1) cuedata <- as.factor(c('ValidCue', 'ValidCue', 'InvalidCue', 'NoCue', 'InvalidCue', 'NoCue')) contr.helmert.unweighted(x=cuedata) contr.helmert.unweighted(x=cuedata, reference.levels=c('ValidCue','InvalidCue'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.