# Questions tagged [contrasts]

In linear models and particularly in ANOVA, a contrast is a linear combination of parameters with coefficients summing up to zero. It is used to test the corresponding null hypothesis. Contrasts are especially often used with categorical predictors (factors) to make comparisons among the groups (categories). [See also tag 'categorical-encoding']

322 questions
Filter by
Sorted by
Tagged with
11 views

### Isn't “contrast coding” just a weird way to write a mixture model?

My background is in CS and ML, so I am quite familiar with hierarchical Bayesian models -- and probabilistic programming. But I do not have much experience with traditional statistical methods. This ...
13 views

### Orthogonal contrasts and the family-wise error rate

I recently read about contrasts and how to code them. Contrasts can be orthogonal which means that they are independent and the statistical tests for them are not correlated. Normally, when doing ...
7 views

### How to create contrast matrix model manually from GAM output

I have run a general additive mixed model and would now like to see if the levels of the two factor variables are statistically different from one another. An example of my data and code for this ...
20 views

### Analysing SPSS two-way ANOVA output: Tests of Within-Subjects Contrasts

I used SPSS to run a two-way within subjects ANOVA (IV1 and IV2). The IV1 * IV2 interaction was not significant but main effects of both IV1 and IV2 were. I would like to know if the trends followed a ...
8 views

### Contr.sums and contr.poly question?

I know that contr.poly creates orthogonal polynomials of degree 1, 2, etc. so that you can determine if there is a particularly mathematical pattern (e.g., linear, ...
49 views

### Contrasts Coding - Using contr.sum on many variables in regression - interpretation of variables in R

In short, my understanding of using contr.sum on categorial variables in regression allows one to specify the reference level of the estimate (coefficient) to the grand mean of all other levels in the ...
385 views

### Statistics Help: Difference between Differences?

I don't know that this is really the right forum to be asking this, but I'm hoping for some statistics help. I have 4 conditions: A, B, C, D. I'm looking to determine whether the difference between A ...
60 views

### Controlling for baseline in pre-post between design: using $\Delta(T_2-T_1)$ or controlling for T1 in the regression model (or both)? [duplicate]

I have a mixed between-within design, with three groups and Pre (T1) and Post (T2) measurements. I'm hesitating on the right statistical analyses to do, but I would like to compare each group to the ...
30 views

### How do I approach a linear mixed effects model with a 2-level group?

My data looks something like this: ...
26 views

### Is the “mvt” (using the multivariate t distribution) accepted way of adjusting for multiple comparisons when reporting to journals?

I use the awesome package multcomp and emmeans in R. These are the places I heard about the "mvt" method for the first time. And, however, it is what it's actually done in the Dunnett or ...
22 views

### Why do contrasts influence singular fits with mixed models?

I've fit a linear mixed effects model to some data in R with afex::mixed. I'm interested in the fixed effect and have no expectations for the random effects ...
28 views

### Contrasts for distributional parameters in a shifted log normal distrbution

I’m playing around with shifted log normal distributions in brms (for reaction time data), trying to get my head around the parameter estimates and also how to do contrasts with them using the emmeans ...
10 views

### Difference in Difference Contrasts for Experiments : Application in R

Note this is different (pun intended) from differences in differences models for observational data. I have the following setting . I have two categories.Say Male and Female. Each category can be ...
40 views

### Unfamiliar with 'contrast' function

Stata has a 'contrast' function after using a regression on a categorical variable. What this essentially does is compare each level of the categorical variable to the mean of the dependent variable. ...
16 views

### Transforming contrast estimates to mean differences - how do SEs and 95%CIs change?

When we use Helmert contrasts (or any contrasts) in R, we get an output like this: ...
21 views

### Interpreting differences in categorical parameter estimates bayesian model

I've built a model using brms to describe ln-transformed gut length in fishes as predicted by diet, ln-transformed body length, the method used to measure the gut, and a couple of random variables (...
14 views

### Can I use Helmert coding for two level categorical variables?

When I use Helmert contrast in R for two level categorical variables it codes the levels as -1 and 1. This is fine with me but I was not sure if I am doing this wrong because generally Helmert coding ...
36 views

### Effect size for contrasts in mixed model

I was wondering on how to compute effect sizes for planned contrasts in (generalized) linear mixed effects models. First, I set up multiple models with main effects and interactions and compared them ...
14 views

### LRT signficiant but not planned contrasts (mixed model)

I set up multiple models (each model adding a main effect and an interaction) with glmerfrom the R package lme4. Conducting a ...
38 views

### Can contrasts and interaction contrasts be identical in linear mixed model?

I have a doubt with respect to the estimated marginal means of a linear mixed model. I performed a mixed model like the one in the example below: ...
65 views

### Why Helmert coding in R divides subsequent differences

This question is about a weird behavior of Helmert coding in R as implemented in the standard contr.helmert function. First of ...
18 views

### How contrast coefficients are computed in linear trend analysis

I am teaching myself trend analysis. I mostly learned from the following two sources. (1) The book "Designing experiments and analyzing data" by Harold D. Delaney and Scott E. Maxwell. I ...
12 views

### Set up and analyse planned contrasts in lmer() from lme4

I would like to analyse planned contrasts in my lmer() model from the lme4package. I have three factors: group (levels: trt, ...
4 views

### ANOVA with Treatment Constrasts when utilizing Parsnip

I have a minimal example below: ...
10 views

### Pairing conditions to run lmer

I have six conditions and would like to create three pairs of conditions, so that when I run lmer it compares conditions 1 & 4, 2 & 3, and 5 & 6. Here's what I have at the moment: ...
77 views

### Generating a full rank model matrix in R

For a particular tool I need a model matrix which allows me to build desired contrasts and which is a full rank, i.e. no columns are linear combinations of other columns. The experimental design ...
12 views

### Validity of setting Singular=1 in proc GLM Contrast statement (SAS)

I am running a proc GLM in SAS with specific contrasts, one of which is included in the code below. With the following code, all my contrasts are always unestimable: ...
48 views

### Why do my results regression results change when I change my contrasts?

I have the following dataset ...
10 views

### Which SPSS method should I use to conduct my analysis?

I am new statistics and I need to describe a study and then do some analyses using SPSS. I have two groups and I want to ask a dichotomous categorical question, then provide further information and ...
20 views

### Estimability of Pararmeteric Functions and Elementary Contrasts

Why do we say that a linear parametric function is estimable when it is in form of an elementary contrasts? I understand that a parametric function is estimable when E(l'Y)= c'β where l=(l1,l2...ln)' ...
32 views

### Sum contrast model intercept for multiple factors

How is the intercept calculated for a linear model with multiple factors using contr.sum. From what I've read the intercept is equal to the "grand mean", which as ...
20 views

36 views

### contr.Sum and standard error in R

I want to fit a linear model in R with a categorical variable that takes 3 possible levels. My goal is to check the effect of each level against a global mean, therefore I use contr.sum as contrasts. ...
35 views

### R: Why does type III ANOVA require contrasts that sum to zero?

The explanation offered here is "over parameterization" of the multi-way ANOVA model, but I don't understand this statement. In my own fiddling with 2-way, binary factor ANOVA, I can see that the ...
25 views

### design a contrast matrix (R) for comparing each levels with the rest

Based on the discussion in this post I wanted to implement a contrast matrix where I am able to compare each level of a factor variable with the average of all others. If I have 3 levels (I am ...
320 views

### In emmeans package, how to exclude certain uninteresting contrasts from pairwise comparisons

Let's say I run the following contrast: ...
132 views

### Address unequal variance between groups before applying contrasts for a linear model? (r)

My Goal: I have an ordinal factor variable (5 levels) to which I would like to apply contrasts to test for a linear trend. However, the factor groups have heterogeneity of variance. What I've done: ...
47 views

### Multiple logistic regression using Helmert contrast in R

I hope someone of you will be able to help me with my multiple logistic regression analysis. So I have a dataset, from which I would like to predict the probability for choosing a certain car based ...
We're given that Contrast 1 is $ψ_1 = τ_1 - τ_2$ $ψ_2 = τ_1 + τ_2 - τ_3 - τ_4$ We're suppose to find contrast $ψ_3$ such that its mutually orthogonal to $ψ_1$ & $ψ_2$ given that our ...