# Can I run an ANOVA on multiple slope estimates from different groups?

I have a dataset where there is list of 20 subjects, and each subject has data for 2 variables (X and Y). There are multiple entries of Xs and Ys per subject.

It is believed that there is some meaningful correlation between X and Y within each subject. Due to the heterogeneity of the population, it was requested that I run the regression by subject instead of running the regression across the entire population. As a result, I will have a different slope estimate for each subject. Each slope for each subject is deemed as a clinically useful metric. So far, the subjects in this dataset all came from the same category (say Category 1).

I will need to replicate the same “by-subject” linear regression within each subject for Category 2 and 3.

If there are 20 subjects in each of Category 1, 2 and 3, I would have in front of me 60 different slope estimates. Is there a way for me to compare the 20 slopes from each Category, and check whether these slopes are statistically significantly different based on the Category?

I was thinking of running an one-way ANOVA for the slopes. Would this be a reasonable approach? Normally, I would be more comfortable if the variable of interest is not a statistic itself, but should I really be able to run ANOVA on the 60 slope estimates? If these were something more tangible like Height or Weight, then this would be a textbook example of ANOVA. I'm just not sure whether it applies to slopes estimates.

Let's look at the ANOVA assumptions and whether the slopes $\beta$ satisfy them:

1. Independence: If the subjects are independent, then it is reasonable to assume that the slopes of the subjects are independent too
2. Normality: In a simple linear regression on normal data, $\beta$ is normally distributed too
3. Homoscedasticity: In a simple linear regression, $Var(\hat{\beta})$ is a transformation of the subject variance and would therefore be homoscedastic if the subjects are homoscedastic

So yes it is reasonable to conduct an ANOVA on the slopes.

• No problem @Redman. If you think the answer deserves it, please upvote and/or accept the answer.
– user64106
Feb 13, 2018 at 14:23

## You can do better than a straightforward anova

StatMan's provided some fine considerations regarding the ANOVA assumptions. However, in your case (the slopes being derived information, throwing away info of the residuals in the determination of these slopes) a stronger test can be performed by using a mixed-effects model.

A mixed effects model will incorporate multiple effects of variation in the slopes: both due to

• variations of slopes between different individuals,
• and variations in slope due variations (e.g. measurement errors) within the same individual.

If you look at your observed variance in the slopes of the 20 individuals then this has two sources.

1. One is that the individuals are different.
2. And the other one is that you make errors in the measurement of the x's and y's (where most simple linear models just assume error in the measurement the y).

You can imagine two different cases giving the same observed variance in your slopes within a category. Lots of individual difference with little measurement error, versus little of individual difference with lots of measurement error.

Could we somehow improve the analysis by differentiating between these two cases?

## Improved estimates (closer to the mean)

In a mixed-effects model you incorporate both sources of error by estimating the maximum likelihood incorporating both sources of variation (which is however not simple, no closed solution, and requires some iteration).

The effect is that, using the information of the measurement error in your slopes (whether the residuals are large or small) you can refine your estimates of the spread in the individual differences. The estimates will be closer to the mean of the category (shrinkage).

The effect of using the mixed effects model is that you will estimate the spread of slopes between individuals to be closer to the mean of the category. You are 'filtering out' the two different sources of variation, and this may improve your ideas about a significant effect between different categories/individuals.

## computational examples and equations

To be honest, I wrote the above story based on intuition, and hope to provide some "proof" in a next edit, or either someone passes by and does this for me.