I have a large dataset (n>1000) of environmental data over time. With the use of ggplot I create a figure in R, and with the use of geom_smooth I applied a simple linear model to have an idea about the magnitude of the trend. With a different method I already found a significant trend.
I have used the function stat_poly_eq as described in Add regression line equation and R^2 on graph by @Pedro Aphalo to retrieve the formula of the trendline, but I do not agree on the result. If I apply x=1980 and x=2020 to the suggested formula, the results (y=0.1776 and y=0.1775) do not (visually) agree with the computed trendline. By checking the line I expected it to be more around y=0.18 and y=0.15.
What might be going wrong here?
library(ggplot)
library(ggpmisc)
ggplot(df, aes(x=Date, y=NDVI))+
geom_point()+
geom_smooth(method="lm", formula= y~x)+
stat_poly_eq(formula= y~x,
aes(label=paste(..eq.label.., ..rr.label.., sep="~~~")),
parse=TRUE)