m

marah othman

05/25/2023, 1:27 PM
hello ,if i am doing this test adfuller and i got the p value under 0.05 this mean the data stationary but i can see there is seasonality or cyclic pattern how this can happened ?
a

Ayush

05/25/2023, 1:37 PM
What you are saying is a mis-conception, p-value<0.05 means you can reject the null hypothesis, i.e the time series does not have a unit root. Please share what is the test-statistic you are getting and the critical values as well.
m

marah othman

05/25/2023, 2:51 PM
Copy code
2. P-Value :  2.4764955108000915e-11
3. Num Of Lags :  31
4. Num Of Observations Used For ADF Regression: 4201
5. Critical Values :
1% :  -3.431907557775807
5% :  -2.8622282433049357
10% : -2.567136357688722
a

Ayush

05/26/2023, 8:01 AM
Apologies for the delay in response. See the thing is your ADF test looks good to me, however it helps us determine whether a time series is stationary in terms of having a constant mean and variance. It does not address seasonality. This is an example of series that is stationary and has a repetitive seasonality. You can take a seasonal difference or normal difference also to handle this.
Copy code
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)

time = np.arange(0, 100, 0.1)

# Generate a stationary time series with seasonality
seasonality = np.sin(time / 2)
noise = np.random.normal(0, 0.1, len(time))
time_series = seasonality + noise

# Plot the time series
plt.figure(figsize=(10, 6))
plt.plot(time, time_series)
plt.title('Stationary Time Series with Seasonality')
plt.xlabel('Time')
plt.ylabel('Value')
plt.grid(True)
plt.show()