My data set:
structure(list(year = 2010:2019, pop = c(9574323, 9657592, 9749476,
9843336, 9932887, 10031646, 10154788, 10268233, 10381615, 10488084
), ye = 1:10), row.names = c("1", "2", "3", "4", "5", "6", "7",
"8", "9", "10"), class = "data.frame")
I only the linear regression of the Year and Pop columns. When I run the summary(lm) for those two columns this is what I get:
> summary(lm(pop~year, data = this))
Call:
lm(formula = pop ~ year, data = this)
Residuals:
Min 1Q Median 3Q Max
-27821.4 -10094.9 656.5 12968.3 27549.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -196556312 4240960 -46.35 5.19e-11 ***
year 102539 2105 48.71 3.49e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 19120 on 8 degrees of freedom
Multiple R-squared: 0.9966, Adjusted R-squared: 0.9962
F-statistic: 2372 on 1 and 8 DF, p-value: 3.493e-11
The slope intercept equation is not correct. But when I run the lm using the ye column, its correct.
summary(lm(pop~ye, data = this))
Call:
lm(formula = pop ~ ye, data = this)
Residuals:
Min 1Q Median 3Q Max
-27821.4 -10094.9 656.5 12968.3 27549.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9444234 13062 723.00 < 2e-16 ***
ye 102539 2105 48.71 3.49e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 19120 on 8 degrees of freedom
Multiple R-squared: 0.9966, Adjusted R-squared: 0.9962
F-statistic: 2372 on 1 and 8 DF, p-value: 3.493e-11
This isn't what I'm looking for because I want to predict for the years 2020, 2021 and so on. What do I need to change to make the Year column work in the equation? I tried this in excel too, and its the same thing.