# How do I compare 5 simple linear regressions?

I'm trying to compare 5 equations of simple linear regressions. All of them have the same variables: abundance of individuals vs. year. I want to know if the slopes are significantly different from each other, the statistic that would help me with this answer is the F value, isn't it? Here is the result of my ANOVA, which gives me blank value. This value may be due to the fact that it is only for two samples? If the answer is yes, then what do you recommend me to use?

Res.Df    RSS Df Sum of Sq F Pr(>F)
1     12 52.263
2     12 68.344  0   -16.081
3     12 21.111  0    47.233
4     12 30.890  0    -9.779
5     12  6.717  0    24.173

Here is the script.

# ZONA 1 - CRIAS
Y <- datosC$$Año X <- datosC$$C
rC <- lm(X~Y)
plot(Y, X, pch = 10, cex = 1.3, col = "black", main = "ln(NCRIAS) vs año", xlab = "Año", ylab = "Ntotal", ylim = c(0,9), xlim = c(1990,2018))
abline(rC)
summary(rC)

# ZONA 1 - HJ
Y <- datosHJ$$Año X <- datosHJ$$H.J
rHJ <- lm(X~Y)
summary(rHJ)
plot(Y, X, pch = 8, cex = 1.3, col = "blue", main = "ln(NHEMBRA-JUVENIL) vs año", xlab = "Año", ylab = "Ntotal", ylim = c(0,9), xlim = c(1990,2018))
abline(rHJ, col = "blue")

# ZONA 1 - M
Y <- datosM$$Año X <- datosM$$M
rM <- lm(X~Y)
plot(Y, X, pch = 12, cex = 1.3, col = "green", main = "ln(NMACHOS) vs año", xlab = "Año", ylab = "Ntotal", ylim = c(0,9), xlim = c(1990,2018))
abline(rM, col = "green")
summary(rM)

# ZONA 1 - MSUB
Y <- datosMSUB$$Año X <- datosMSUB$$MSUB
rMSUB <- lm(X~Y)
plot(Y, X, pch = 13, cex = 1.3, col = "orange", main = "ln(NMSUB) vs año", xlab = "Año", ylab = "Ntotal", ylim = c(0,9), xlim = c(1990,2018))
abline(rMSUB, col = "orange")
summary(rMSUB)

# ZONA 1 - MH
Y <- datosMH$$Año X <- datosMH$$M.H
rMH <- lm(X~Y)
plot(Y, X, pch = 14, cex = 1.3, col = "red", main = "ln(NMH) vs año", xlab = "Año", ylab = "Ntotal", ylim = c(0,9), xlim = c(1990,2018))
abline(rMH, col = "red")
summary(rMH)

summary(rMH)
summary(rMSUB)
summary(rM)
summary(rC)
summary(rHJ)

anova(rMH, rMSUB, rM, rC, rHJ)

rMH$$coefficients rMSUB$$coefficients
rM$$coefficients rC$$coefficients
rHJ\$coefficients

Linear regressions were calculated between loge numbers of individuals for each age class and years of census. A test for equality of slopes of several regression lines was performed for each colony to determine whether the relationships obtained were similar between age classes during the study period (i.e., the colony did not change its social composition despite growing in number of individuals). I want to know WHICH is the test for equality of slopes of several regression lines.

I added an example of one of my tables from the raw data

• Welcome to CV, Paula. Do you have the raw data? Commented Nov 2, 2018 at 22:30
• Your analysis has problem. DF (degree of freedom) = 0? Negative Sum of Square? Commented Nov 2, 2018 at 22:42
• @a_statistician actually, I think those Sum of Squares are the differences in RSS from consecutive rows. And same for Df so since they all have Df 12, then difference is always 0. Commented Nov 2, 2018 at 22:43
• @a_statistician I think OP ran something like anova(mod.1, mod.2, ..., mod.5) in R which produced this output that is not very helpful. Commented Nov 2, 2018 at 22:54
• I just read in another post this message: You may notice that the ANOVA table lists the degrees of freedom associated with the analysis as 0; you have the same number of variables in both models, that is the reason that no F or p-values can be computed. Commented Nov 3, 2018 at 0:29

Your ANOVA is meaningless. What you need to do is

1) Organize your data as following:

Year   C             Group
1991  9.23244802       1
1992  0                1
........
2018  x.xxxxx          5

2) Fit the model $$Y = \beta_0 + \beta_1 X +\beta_2G_2 + \beta_3G_3 +\beta_4G_4 +\beta_5G_5 +\beta_6G_2X +\beta_7G_3X +\beta_8G_4X +\beta_9G_5X + \epsilon$$ where $$X$$ = year and $$G_i = 1$$ if group = $$i$$, otherwise = 0, for $$i=2,...,5$$.

3) Test the multiple null hypothesis $$H_o: \beta_6= \beta_7=\beta_8=\beta_9=0$$. If $$H_o$$ is rejected, it means at least two slopes are different. Otherwise, there is not enough evidence to say that 5 slopes are not the same.

You data-set is not in the best format for doing what you want to do which is to fit a full model with a new factor defining which outcome it is (call that group) and then adding the interaction between group and outcome. Some combination of the R commands cbind() and reshape() should work here but code advice is off-topic here, ask on R-help if necessary.

There is an alternative which is to take the slopes you currently have and their standard errors and do a meta-analysis and test for heterogeneity but if you are not familiar with meta-analysis that might be a step too far.