Git Product home page Git Product logo

statistics's Introduction

linear_reg.py

A multivariate linear regression class built from first principles.

In R, the multivariate linear regression is an incredibly simple function, where one can also see the significance of each variable within the model.

The class here applies the same linear regression and outputs the same results including:

  • the estimated coefficients (beta),
  • the standard error (SE),
  • the t-statistic for the SE (tstat), and
  • the corresponding p-value(p_val) for each input variable.

To filter out the variables that are not contributing to the predictor variable, we can also apply the regression over every combination of input variables to output the models that only have significant input variables. This method should be used with caution as the quality of the model is not determined just by the significance of variables but also by the R squared and AIC/ BIC measures.

To achieve a quadratic regression, one would simply add the quadratic values of an input variable as an extra input variable, then run the linear regression on all variables. That is, instead of calculating coefficients for b_1 + b_2* X, we would calculate b_1 + b_2X + b_3X^2. Given this ease of applying quadratic regression, I included the addition of such transforms into the class, so that new variables can be created to apply exponential, logarithmic, snusoidal, etc, regressions.

statistics's People

Contributors

shahradj avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.