Slackbot
05/25/2023, 1:27 PMAyush
05/25/2023, 1:37 PMmarah othman
05/25/2023, 2:51 PM1. 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.567136357688722Ayush
05/26/2023, 8:01 AMimport 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}')