I want to extract the linear trend of my NDVI time series. When I use the linear regression in Python using this code:
from sklearn.linear_model import LinearRegression
import pandas as pd
data_orig = pd.read_csv('NDVI.csv')
N_values = data_orig['N'].values.reshape(-1, 1)
NDVI_values = data_orig['NDVI'].values
model = LinearRegression()
model.fit(N_values, NDVI_values)
slope = model.coef_[0]
intercept = model.intercept_
print("Linear trend equation: NDVI = {:.4f} * N + {:.4f}".format(slope, intercept))
The output of this code is Linear trend equation: NDVI = 0.0000 * N + 0.0485.
I don't think this equation is correct because the vegetation in the time series is clearly increasing over time.
I also tried LOESS with this code:
import matplotlib.pyplot as plt
import pandas
from pandas.plotting import register_matplotlib_converters
data_orig = pandas.read_csv('NDVI.csv')
from statsmodels.tsa.seasonal import STL
res = STL(data_orig['NDVI'], period=46, trend_jump=460).fit()
From this I got a good and significant upward trend. However, I want to know if it's ok to set the trend_jump to 460 (which is the number of my time series values).

This code is rounding the slope to four decimal places before printing. Eyeballing the graph, it appears to go up by 0.015 over the course of 460 steps.
The slope this implies approximately 0.015 / 460 = 0.000032. Rounded to four decimal places, that's 0.0000.
Therefore, I think LinearRegression probably is detecting a slope - but one that is zero after rounding it.
I think this would probably work: