0
$\begingroup$

I have a linear model where one dv is predicted by one categorical with 4 levels. I want to check if the intercept differs from the average of the other 3 conditions.

I fit the model

m1 <- lm(DV ~  categorical, data = data)

Then I perform contrast analysis by specifying

K <- matrix(c(3, -1, -1, -1), 1)
t <- glht(m1, linfct = K)

Is my approach correct?

$\endgroup$

1 Answer 1

1
$\begingroup$

I don't think your approach will produce what you want because of the way the model is parameterized. By "intercept" you are probably referring to the overall mean. But in these ANOVA-type models the default parameterization in lm() sets the intercept equal to the first categorical level. So in your model (m1), the intercept is the mean for "categorical" level 1. The other 3 model coefficients are not means but rather the effect size of categorical levels 2, 3, and 4 relative to categorical level 1. So your contrast is testing whether 3 times the mean of categorical level 1 is different from the sum of the effect sizes, relative to categorical level 1, of the other 3 levels.

One way to get what you want is to use sum-to-zero contrasts. This will set the intercept to the overall mean. These only work with factors so you will have to convert the categorical variable to a factor if you haven't already. See ?contrasts and ?contr.sum for more information.

Then you can set up a contrast to test whether the sum of the effect sizes is different from zero. This is equivalent to testing whether the overall mean differs from the average of the other 3 conditions.

data$categorical_factor <- factor(data$categorical))
contrasts(data$categorical_factor) <- contr.sum(4)
m2 <- lm(DV ~ categorical_factor, data = data)
summary(m2)

K2 <- matrix(c(0, -1, -1, -1), 1)
t2 <- multcomp::glht(m2, linfct = K2)
summary(t2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.