• No products in the cart.

# 204.1.5 R-Squared in Python

##### Basic statistical measure for fitness of regression line.

Link to the previous post : https://statinfer.com/204-1-4-how-good-is-my-regression-line/

In this post we will move toward the statistical measure for a good fit.

### R-Squared

• A good fit will have
• SSE (Minimum or Maximum?)
• SSR (Minimum or Maximum?)
• And we know SST= SSE + SSR
• SSE/SST(Minimum or Maximum?)
• SSR/SST(Minimum or Maximum?)
• The coefficient of determination is the portion of the total variation in the dependent variable that is explained by variation in the independent variable.
• The coefficient of determination is also called R-squared and is denoted as R2
R^2=SSR/SST

where 0<= R2<=1

### Practice : R- Square

(We are continuing with the python session from posts 204.1.1 – 204.1.4; we have already built models required for this practice session)

• What is the R-square value of Passengers vs Promotion_Budget model?
• What is the R-square value of Passengers vs Inter_metro_flight_ratio?
In :
#What is the R-square value of Passengers vs Promotion_Budget model?
fitted1.summary()

Out:
Dep. Variable: R-squared: Passengers 0.933 OLS 0.932 Least Squares 1084. Wed, 27 Jul 2016 1.66e-47 11:48:27 -751.34 80 1507. 78 1511. 1 nonrobust
coef std err t P>|t| [95.0% Conf. Int.] 1259.6058 1361.071 0.925 0.358 -1450.078 3969.290 0.0695 0.002 32.923 0.000 0.065 0.074
 Omnibus: Durbin-Watson: 26.624 1.831 0 5.188 -0.128 0.0747 1.779 2.67e+06
In :
#What is the R-square value of Passengers vs Inter_metro_flight_ratio

fitted2.summary()

Out:
Dep. Variable: R-squared: Passengers 0.242 OLS 0.232 Least Squares 24.90 Wed, 27 Jul 2016 3.58e-06 11:48:27 -848.30 80 1701. 78 1705. 1 nonrobust
coef std err t P>|t| [95.0% Conf. Int.]
Intercept 2.044e+04 4993.747 4.093 0.000 1.05e+04 3.04e+04
Inter_metro_flight_ratio 3.507e+04 7027.768 4.990 0.000 2.11e+04 4.91e+04
 Omnibus: Durbin-Watson: 10.172 1.385 0.006 10.098 0.822 0.00641 3.573 9.48

The next post is about multiple regression in python.

Link to the next post: https://statinfer.com/204-1-6-multiple-regression-in-python/

21st June 2017
0 responses on "204.1.5 R-Squared in Python"