hello ,if i am doing this test adfuller and i got ...
# general
m
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
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
Copy code
1. ADF :  -7.59481163692407
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
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()
#check adf 
from statsmodels.tsa.stattools import adfuller as adf
# ADF Test
result = adf(time_series, autolag='AIC')
print(f'ADF Statistic: {result[0]}')
print(f'p-value: {result[1]}')
print(f'n-lags: {result[2]}')
print(f'n-obs: {result[3]}')
for key, value in result[4].items():
    print('Critial Values:')
    print(f'   {key}, {value}')