help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
statsmodels-statistical
/
examples
RSK World
statsmodels-statistical
Statistical Modeling with Statsmodels
examples
  • advanced_time_series_example.py1.4 KB
  • hypothesis_testing_example.py1.4 KB
  • model_selection_example.py1.5 KB
  • regression_example.py1.5 KB
  • time_series_example.py1.6 KB
time_series_example.py
examples/time_series_example.py
Raw Download
Find: Go to:
"""
Time Series Analysis Example

Author: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
"""

import numpy as np
import pandas as pd
import sys
import os

# Add parent directory to path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from time_series_analysis import TimeSeriesModel


def main():
    print("Time Series Analysis Example")
    print("=" * 70)
    
    # Generate sample time series data
    np.random.seed(42)
    dates = pd.date_range('2020-01-01', periods=100, freq='D')
    trend = np.linspace(0, 10, 100)
    seasonal = 2 * np.sin(2 * np.pi * np.arange(100) / 7)
    noise = np.random.randn(100) * 0.5
    data = pd.Series(trend + seasonal + noise, index=dates)
    
    # Create time series model
    ts_model = TimeSeriesModel()
    ts_model.data = data
    
    # Test stationarity
    print("\nStationarity Test:")
    print("=" * 70)
    ts_model.test_stationarity()
    
    # Fit ARIMA model
    print("\n" + "=" * 70)
    print("ARIMA Model:")
    print("=" * 70)
    ts_model.fit_arima(data, order=(1, 1, 1))
    ts_model.summary()
    
    # Check residuals
    print("\n" + "=" * 70)
    print("Residual Analysis:")
    print("=" * 70)
    ts_model.check_residuals()
    
    # Generate forecast
    print("\n" + "=" * 70)
    print("Forecast:")
    print("=" * 70)
    forecast, conf_int = ts_model.forecast(steps=10)
    print(f"Forecast values:\n{forecast}")
    print(f"\nConfidence intervals:\n{conf_int}")


if __name__ == "__main__":
    main()

67 lines•1.6 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer