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']

Filter by
Sorted by
Tagged with
0 votes
1 answer
53 views

Sum of squares in linear contrast

$$SS(\text{Contrast}) = \frac{(\sum_{i=1}^{k} c_i\bar{X}_i)^2}{\sum_{i=1}^{k} c_i^2/n_i}$$ This is a formula from Howell's Statistical Methods for Psychology. The author claims that one of the major ...
Jonathan deGrom's user avatar
0 votes
0 answers
7 views

Equivalent of `aov` with `split` argument for contrasts in GLM in R

In case of linear models (LM) it is possible to get ANOVA with planned contrasts by using a contrast matrix and aov. Is there any equivalent of the same for analysis of deviance in case of ...
Crops's user avatar
  • 477
0 votes
1 answer
15 views

Comparison between contrasts in emmeans

Let's say I have these estimated marginal means: ...
Alex Il's user avatar
  • 45
0 votes
0 answers
34 views

R: emtrends pairwise contrast results change when testing slopes against 0 or 1

When performing post-hoc simple slope analysis on my linear mixed effect model in R using emtrends(), I noticed that pairwise slope comparisons showed differences in the significance when I tested all ...
Malin's user avatar
  • 1
3 votes
1 answer
60 views

Two-way ANOVA with interaction term / orthogonal design

The two-way ANOVA model with interaction for some continuous variable $y$ can be expressed as $$y = X\mu + \varepsilon,$$ where $X$ is the design matrix (the first column of $X$ contains the constant, ...
Syd Amerikaner's user avatar
0 votes
1 answer
18 views

Access to the interaction of two three level factors on a mixed model

Using a mixed model (either frequentist lmer or bayesian brms) I have an issue regarding an interaction in my model. I have two factor variable of three level : condition (0-1-2) and Tps_real (0-300-...
Guillaume Pech's user avatar
0 votes
0 answers
23 views

Posthoc pairwise test on the output of a linear mixed-model (MATLAB or R/Python)

I have observations from three groups of participants (A, B, C), that each represent ratings on three different measures (measure 1, 2, and 3). I would like to know if it is the case that, regardless ...
z8080's user avatar
  • 2,120
1 vote
0 answers
41 views

Posthoc (planned) comparisons as contrasts between different levels of a regressor, in fitlme (Matlab)

I have participant data for 5 different rating dimensions (A to E), and I have fitted linear mixed-effects models, separately for each rating, with several fixed- and random-effects predictors: ...
z8080's user avatar
  • 2,120
3 votes
2 answers
52 views

How to construct the full interaction term for a 3-way ANOVA?

Say for the sake of the argument I have a 2x2x2 ANOVA on factors A, B, and C with levels (A1, A2), (B1, B2), and (C1, C2). Also, the design is fully balanced. I have the following 8 groupings as a ...
Matthew Graham's user avatar
2 votes
0 answers
28 views

R, lme4, glmer function: How to calculate significance values for Helmert contrasts? [closed]

I am running a GLMM using the glmer function from the lme4 package in R. I would like to use a Helmert contrast to test a specific difference for the factor condition. If I run that in the glmer ...
Frank Leoné's user avatar
2 votes
1 answer
61 views

Contrasts for relative change in proportions #emmeans

I have data indicating quality of life (QOL) as a percentage score from questionnaire data. The data is longitudinal (collected at baseline, 3, 6, 9 and 12 months) and there are other covariates such ...
user167591's user avatar
1 vote
1 answer
50 views

ANOVA: contrast to ratio of adjusted geometric means

Could you, please, help me with the following problem? Suppose we have a one-way ANOVA with a single 2-level factor. The dependent variable is a logarithmized value: $y_i = log(Y_i)$. $y_{iz} = \mu + ...
dfgh19283's user avatar
0 votes
0 answers
12 views

Running the same mixed model with different contrasts to explore different hypotheses

I'm running the following mixed model to explore the relationship between Condition (3 levels; Predicted, ...
Chantal's user avatar
  • 75
2 votes
1 answer
73 views

Interpretation of lme4 output with different contrasts for variables

I have data assessing reaction time (RT) with 2 variables: Variable 1: 'HighLow', with 2 levels ('High' and 'Low') Variable 2: 'Condition', with 3 levels ('Predicted', 'Implausible', 'Plaus/Unpred') I ...
Chantal's user avatar
  • 75
1 vote
0 answers
29 views

How to perform non-orthogonal planned contrasts (and a-priori power-analysis for this)?

I have four treatment groups (A, B, C, D) and measure three dependent variables (X, Y, Z). My hypotheses are that each dependent variable is strongest in one of the treatment groups, compared to all ...
Annette M's user avatar
0 votes
0 answers
82 views

Inconsistency in ANCOVA results between rstatix and car

I am trying to run an ANCOVA in R with a binary treatment variable, a continuous covariate, and their interaction (response ~ cont*bin). My understanding has always been that AN(C)OVA and regression ...
JonathanHenshaw's user avatar
0 votes
1 answer
48 views

Three-level variable in LME analysis - output

I am currently unsure about a three-level variable in an linear mixed effects analysis in R (lme4) - I should add that I am new to LMEs and would very much appreciate some very basic advice! I am ...
Jane's user avatar
  • 3
0 votes
1 answer
80 views

Why is the last level not reported in R's `summary()`, if its coefficient is not 0? [closed]

In section 4.7.7 of Introduction to Statistical Learning (version 2), the authors code regression contrasts where the last level of a predictor sums to the remaining levels. My question is, why doesn'...
its.me.adam's user avatar
0 votes
0 answers
20 views

Serial Mediation: Pairwise comparison standard error using delta method

I have three serial mediations in my model and I want to be able to compare their specific indirect effects. Based on the normal theory approach/delta method, I am interested in knowing what the ...
Sazid Ahmad's user avatar
2 votes
1 answer
34 views

How to deal with potentially too few levels of the random effect

I built a linear mixed effect model with nlme with Body length, Habitat and Sex as fixed effects. Body length is added for body size correction while the other two both have two levels. In the random ...
Anna's user avatar
  • 21
2 votes
2 answers
164 views

Comparing emmeans values multinom model

I am performing quite some binomial/multinomial models for my thesis. After doing the emmeans statement, I used the contrast statement to compare the emmeans of the different groups. But, I ...
S_vdp's user avatar
  • 41
0 votes
1 answer
99 views

What are the option for a post-hoc test after running a multinomial model?

Currently, I am trying to run the multinomial model Age = Gender to investigate the effect of Gender on the probability that my study animal belongs to a particular age class. I am not necessarily ...
S_vdp's user avatar
  • 41
0 votes
0 answers
14 views

Why does model.matrix not remove one level? [duplicate]

I used the model.matrix function to get dummy variables from a set of factor variables. That part worked just fine. However, for the first factor variable in the ...
Pseudo Pseudonym's user avatar
0 votes
0 answers
34 views

How to test H0 that two coefficients associated with dummy variables of same categorical variable are equal?

I have a variable $X$ which I predict with a nominal categorical variable $Y$ with category labels $\{0,1,\dots,m \}$ using a linear model. I use standard dummy coding which gives me the regression ...
jmb's user avatar
  • 695
0 votes
0 answers
30 views

Automatic selection of contrasts for categorical variables in R

I am taking a course in predictive modeling for which the professor does all demoes in JMP. I am more comfortable in R and am working on replicating everything I can there. So far so good except ...
dubhousing's user avatar
0 votes
0 answers
79 views

Calculating Sample Sizes for Tukey and Scheffe Pairwise Contrasts

$\newcommand{\x}[1]{\text{#1}}\newcommand{\op}[1]{\operatorname{#1}}$ This is Exercise 4.9 of Design and Analysis of Experiments, 2nd Ed., by Dean, Voss, and Draguljic. Problem Statement: Suppose the ...
Adrian Keister's user avatar
1 vote
0 answers
325 views

linear regression in R: contr.treatment vs contr.sum

Following are two linear regression models with the same predictors and response variable, but with different contrast coding methods. In the first model, the contrast coding method is "contr....
Ed9012's user avatar
  • 41
1 vote
1 answer
457 views

emmeans: interaction contrast with continuous variable - same se, t- and p-values?

I am analysing my own data with a linear mixed model and estimated marginal means and have made a strange observation. I have run an experimental study with three treatment groups, measuring a ...
Fabi's user avatar
  • 65
0 votes
0 answers
19 views

Controlling for within-subject variance in planned contrasts (lm model)

Somebody asked me about doing planned contrasts with repeated measures (within-subject design). I normally use contrasts with the lm function in R and have no ...
rempsyc's user avatar
  • 251
1 vote
0 answers
160 views

Differences between ANOVA post-hoc tests and planned contrasts?

The source below seems to suggest that ANOVA post-hoc tests are simple t-tests (or "pretty much so") and therefore that planned contrasts are more powerful. This was also my understanding ...
rempsyc's user avatar
  • 251
2 votes
1 answer
61 views

How to interpret R contrasts when given continuous and categorical explanatory variables?

Let's say I have run a linear regression model that models the sugar content in a Jelly Bean as a function of its colour and weight: lm(sugar ~ color + weight) ...
user20953676's user avatar
0 votes
1 answer
47 views

How to interpret R contrasts when given continuous and categorical explanatory variables?

Let's say I have run a linear regression model that models the sugar content in a Jelly Bean as a function of its colour and weight: lm(sugar ~ color + weight) The ...
user20953676's user avatar
0 votes
1 answer
115 views

Understanding the process of tweaking contrasts in linear model fitting to show all levels

The accepted answer to this question on SO accomplishes exactly what I need: Comparing all factor levels to the grand mean: can I tweak contrasts in linear model fitting to show all levels? However, I ...
Adam_G's user avatar
  • 351
0 votes
0 answers
174 views

Logistic regression : contrast vs. changing reference group

I have a dataset with a dependent binary variable and one independent variable (with five categories). When applying logistic regression I have a model that calculates the coefficients of each of ...
Anas116's user avatar
  • 243
1 vote
1 answer
315 views

Three treatment groups vs one control group - only interested in comparing each treatment group separately to control - best test/follow-up test? [duplicate]

I have an analysis in which I have three treatment groups each assigned to a (different) experimental condition, and one group assigned to a control condition. I am interested in whether any/each of ...
Breathofthewold's user avatar
0 votes
0 answers
73 views

GLM contrast for multiple explanatory variables

I have created two GLMs that show that a continuous variable, Y, is positively correlated with continuous variable "A" and is negatively correlated with continuous variable "B". I ...
user20896087's user avatar
1 vote
1 answer
643 views

How do I calculate p-value for trend across categories in R?

I am using R to make a table describing my dataset. My goal is to estimate the adjusted mean of a continuous variable across different groups (e.g. age groups, BMI categories) and calculate a p-value ...
SparkleUnicornCupcake's user avatar
0 votes
1 answer
105 views

How do you conduct contrasts (pairwise comparisons) for a lmer() when your IV is continuous?

I am using lmer() to run an analysis with one categorical variable with 2 levels (task) and one continuous variable (farFC). Below is the model: ...
john connor's user avatar
1 vote
1 answer
234 views

Interpret main effects in sum contrast coding vs. type III ANOVA

Consider I have a linear model fitted in R as: model<-lm(y~x*fac) where x is a continuous variable and ...
Jmmer's user avatar
  • 79
1 vote
0 answers
19 views

Custom contrasts in lmer to a "no-change" condition

I'm using lmer to look at the interaction between continuous variable baseline and grouping factor condition (8 levels) on ...
peaceofcake's user avatar
3 votes
3 answers
782 views

Multivariable Logistic in R, without the "reference" level in a categorical predictor

I am dealing with the following problem: I have to do a multivariable logistic in R, using the command glm with the argument ...
autu_mn's user avatar
  • 33
2 votes
1 answer
63 views

How to test for specific effects in a linear regression with two categorical covariates and their interaction?

I have a data set with a continuous response variable and two categorical covariates. Let's imagine that I worked at an e-commerce company and was trying to regress the revenue we get from each user ...
Adrià Luz's user avatar
2 votes
1 answer
227 views

Continuous by categorical interaction: find p values for slopes at different category levels and compare slopes across category levels

In the following model, I have a linear model with a categorical by continuous interaction: ...
veko's user avatar
  • 23
0 votes
1 answer
535 views

Contrast of contrasts emmeans how to properly represent interaction effect

I've tried to custom code contrasts in emmeans to understand the effect of a combined treatment variable (combination of factors, Dose_Climate). I am not sure the contrast of contrasts I've coded is ...
Gab's user avatar
  • 1
0 votes
0 answers
11 views

Sum Contrasts and effect strengths

This post is a follow-up from this question I am using sum contrasts for a factor that has 15 levels with no clear reference group (i.e., a control group or something like that) and would like to test ...
Gmichael's user avatar
  • 101
0 votes
0 answers
29 views

How to find k in contrasts, where comparing one group against multiple groups in a sample

I am having trouble understanding how to conduct contrasts when comparing the mean of one group to the average mean of multiple groups. My understanding so far is that the Contrast (C) = $\mu_1- (\...
Pterific's user avatar
1 vote
1 answer
113 views

Correction for multiple comparisons using sum contrasts with linear regression

I am computing the following model using the lme4 package in R: ...
Pearson's user avatar
  • 71
1 vote
1 answer
26 views

Why same t-score for contrast pairs involve continuous x continuous interaction (emtrends)?

I want to calculate the difference in simple slope estimates for two-way interactions that involve two continuous variables. But I found the t-score is all the same for the contrast-pair results when ...
zjppdozen's user avatar
0 votes
1 answer
113 views

Is it possible to do a contrast in a 2x2 (or more) contingency table or am I completely missing the point?

I have the following 2x2 contingency table of observed frequencies: ...
pdeli's user avatar
  • 101
0 votes
1 answer
193 views

Problems with emmeans if RE-adjustment and backtransformation from logit

In an experiment (4 sessions, 2 groups), subjects try to remember words. We want to test H1: the overall (marginal) main effect of group H2: the specific interaction contrast of group and sesson1 _ 2 ...
Swarley's user avatar
  • 11

1
2 3 4 5
9