I have multiple observations per year and I was asked to estimate an individual regression line for each year within a single model.

My data has three years (1979, 1980 and 1981) and two independent variables ($X_1$ and $X_2$).

My model looks as follows: $$y_i = D_{79,i} \big( \beta_0 + \beta_1 X_{1,i} + \beta_2 X_{2,i} \big) + \\ D_{80,i} \big(\beta_3 + \beta_4 X_{1,i} + \beta_5 X_{2,i} \big) + \\ D_{81,i} \big(\beta_6 + \beta_7 X_{1,i} + \beta_8 X_{2,i} \big) + u_i$$

Where $D_{y,i}$ is an indicator for year $y$.

In essence, this model fits one regression line per year to each group of observations.

How can I carry out an F-test to test if all the $\beta$ coefficients associated with $X_1$ and $X_2$ are the same between each year?

That is, test if $\{\beta_1 = \beta_4 = \beta_5\}$ and $\{\beta_2 = \beta_5 = \beta_6\}$ simultaneously.


1 Answer 1


This seems to be equivalent to the following linear regression model in R formula syntax:

modelFull <- lm(y ~ (X_1 + X_2) * Yr)

where Yr is a 3-level categorical predictor representing the 3 different years.* That allows all coefficients, including the intercept implicit in that syntax, to depend on the value of Yr.

The simplest overall F-test would be to test that model against a model that omits Yr:

modelSimple <- lm(y ~ X_1 + X_2)

which returns a single intercept and single coefficients for each of X_1 and X_2. In R, the anova() function uses an F-test by default to compare 2 linear regression models.

*The way you wrote the model doesn't allow you to estimate values of all of the specified parameters independently. You have listed 13 parameters, but only 9 coefficients can be estimated uniquely: 3 individual coefficients including the intercept for each year, times 3 years.

  • $\begingroup$ Thanks! It makes sense that I was asked to estimate the model without year-specific terms before doing this. Just to make things clear, the terms $D_{y,i}$ are not parameters. They are dummy variables that take the value of 1 when the year equals $y$. $\endgroup$
    – Arturo Sbr
    Nov 28, 2021 at 21:56

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.