Hello, I have three sets of data:
- With two constant values
- With three constant values
- With four constant values
For each of them, I need to obtain the slope of a linear regression to see their trend. However, for case 2 (3 constant values), the slope is <0 (a very low value, but in practice negative), while for the other two cases, the slope is equal to 0.
I cannot understand the reason for this difference in the cases if the values are constant in all three.
datos_2 <- data.frame(Año = c(2018, 2019), Porc_Satisf = c(100, 100))
datos_3 <- data.frame(Año = c(2017, 2018, 2019), Porc_Satisf = c(100, 100, 100))
datos_4 <- data.frame(Año = c(2017, 2018, 2019,2020), Porc_Satisf = c(100, 100, 100, 100))
lm(Porc_Satisf ~ Año, data = datos_2) # Resultado limpio
lm(Porc_Satisf ~ Año, data = datos_3) # Posibles problemas numéricos
lm(Porc_Satisf ~ Año, data = datos_4) # Resultado limpio
Resultados:
# n = 2
lm(Porc_Satisf ~ Año, data = datos_2) # Resultado limpio
Call:
lm(formula = Porc_Satisf ~ Año, data = datos_2)
Coefficients:
(Intercept) Año
100 0
# n = 3
lm(Porc_Satisf ~ Año, data = datos_3) # Posibles problemas numéricos
Call:
lm(formula = Porc_Satisf ~ Año, data = datos_3)
Coefficients:
(Intercept) Año
1.000e+02 -2.461e-14
# n = 4
lm(Porc_Satisf ~ Año, data = datos_4) # Posibles problemas numéricos
Call:
lm(formula = Porc_Satisf ~ Año, data = datos_4)
Coefficients:
(Intercept) Año
100 0
Regards,