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
GITHUB_RELEASE_INSTRUCTIONS.mdregression_example.py
examples/regression_example.py
Raw Download
Find: Go to:
"""
Linear Regression Example

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

import numpy as np
import sys
import os

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

from regression_analysis import LinearRegressionModel
from statistical_diagnostics import ModelDiagnostics


def main():
    print("Linear Regression Example")
    print("=" * 70)
    
    # Generate sample data
    np.random.seed(42)
    n = 100
    X = np.random.randn(n, 3)
    y = 2 + 1.5 * X[:, 0] + 0.8 * X[:, 1] - 0.5 * X[:, 2] + np.random.randn(n) * 0.5
    
    # Create and fit model
    model = LinearRegressionModel()
    model.fit(X, y)
    
    # Print summary
    print("\nModel Summary:")
    model.summary()
    
    # Diagnostic checks
    print("\n" + "=" * 70)
    print("Diagnostic Checks:")
    print("=" * 70)
    
    model.check_multicollinearity()
    model.check_heteroscedasticity()
    model.check_autocorrelation()
    
    # Comprehensive diagnostics
    print("\n" + "=" * 70)
    print("Comprehensive Diagnostics:")
    print("=" * 70)
    
    diagnostics = ModelDiagnostics(model.results)
    diagnostics.comprehensive_diagnostics()
    
    # Make predictions
    print("\n" + "=" * 70)
    print("Predictions:")
    print("=" * 70)
    
    X_new = np.random.randn(5, 3)
    predictions = model.predict(X_new)
    print(f"New data predictions:\n{predictions}")


if __name__ == "__main__":
    main()

69 lines•1.5 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