4
$\begingroup$

I'm trying to predict weight based of age and height for people under 30 and people 30+

I have the original data set mydata

I have then created two subsets mydatalessthan30 and mydata30plus

Then I have

A = lm(mydatalessthan30$weight ~ mydatalessthan30$age + mydatalessthan30$height)

B = lm(mydata30plus$weight ~ mydata30plus$age + mydata30plus$height)

I then want to check if there is a significant difference between the models, how should I do this?

I have tried Anova(A,B) but this doesn't work

$\endgroup$

2 Answers 2

8
$\begingroup$

I think anova(A, B) is not meaningful here since you are comparing models fitted to different datasets.

It seems to me that you are asking whether weight responds differently in people < 30 year-old vs people > 30 year-old while taking height into account. If so, you want to assess the effect of interaction between height and age, like:

fit <- lm(weight ~ age * height, data=mydata)
summary(fit)

where age is a dichotomous variable with two levels (<30, >30). That is, you are asking: how different is the slope of the regression line of height vs weight in <30 compared to the slope of height vs weight in >30?

As an aside, I wonder whether you actually need to dichotomize age since in doing so you reduce the information contained in the dataset.

$\endgroup$
0
$\begingroup$

Adding to dariober's answer(*), I think it would be better to check if a first order effect of age on weight is present.

fit1 <- lm(weight ~ height, mydata)
fit2 <- lm(weight ~ age + height, mydata)

summary(fit2)
anova(fit1, fit2)

Without 1st order effects, don't try to find 2nd order ones. If any are found, they are spurious findings. But if there are reasons to believe that age has an effect on weight fit a model with the second order, interaction age*height.

fit3 <- lm(weight ~ age * height, mydata)

anova(fit1, fit3)  # redundant
anova(fit2, fit3)  # this is the one you want.

(*) The last sentence alone deserves an extra upvote.

$\endgroup$
3
  • $\begingroup$ "Without 1st order effects, don't try to find 2nd order ones. If any are found, they are spurious findings." Can you substantiate this claim? I have dealt with quite a few real-world datasets where that was simply wrong. For some of them it was even expected from scientific theory that the main effect would be zero and only an interaction would exist. I would certainly start (and stop) with the full model in this specific example based on what is already known about these relationships. $\endgroup$
    – Roland
    Commented Nov 2, 2022 at 5:50
  • $\begingroup$ @Roland Related question. Taller people tend to be heavier, older people tend to gain weight. But if older people do not tend to gain weight, without a main effect, what can an interaction between age and height represent other than a spurious effect? Age is not nested in height. $\endgroup$ Commented Nov 2, 2022 at 8:09
  • $\begingroup$ If you include an interaction, you should include all lower-order effects, yes. (Exceptions exist.) But you are saying something different. I do not agree that you should not include an interaction if a main effect is not significant. $\endgroup$
    – Roland
    Commented Nov 2, 2022 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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