# Linear Regression Calculator

Linear regression calculator and prediction interval calculator with step-by-step solution.

## Linear regression calculator

The linear regression calculator generates the linear regression equation. It also draws: a linear regression line, a histogram, a residuals QQ-plot, a residuals x-plot, and a distribution chart.

It calculates the R-squared, the R, and the outliers, then testing the fit of the linear model to the data and checking the residuals' normality assumption and the priori power.

### What is linear regression?

The linear regression is the linear equation that best fits the points.

There is no one way to choose the best fit ting line, the most common one is the ordinary least squares (OLS). The linear regression describes the relationship between the dependent variable (Y) and the independent variables (X).

The linear regression model calculates the dependent variable (DV) based on the independent variables (IV, predictors).

### What is "ordinary least squares"?

The ordinary least squares method chooses the line parameters that minimize the sum of squares of the differences between the observed dependent variables (Y) and the estimated value by the linear regression (Ŷ).

### Why do you need linear regression?

We may use linear regression when we want to do one of the following- Predict the dependent variable (Ŷ).
- Estimate the effect of each independent variable (X) on the dependent variable (Y).
- Calculate the correlation between the dependent variable and the independent variables.
- Test the linear model significance level.

### How to calculate linear regression?

Following the linear regression formula:_{0}+b

_{1}x

_{0}- the y-intercept, where the line crosses the y-axis.

b

_{1}- the slope, describes the line's direction and incline.

b_{1} = | SP_{xy} | = | Σ(x_{i}-x̄)(y_{i}-ȳ) |

SS_{x} | Σ(x_{i}-x̄)^{2} |

_{0}= ȳ - b

_{1}x̄

### linear regression prediction

The prediction calculator uses the linear regrssion to predict the depdendent variable based on the independent value. The calculator also creates the confidence interval, and the prediction interval.

#### Confidence interval of the prediction

The prediction interval for the **mean value** of the dependent variable.

This is the interval for the equation line, the true value equation will be in this interval. If we would know the true equation then the width of this interval would be zero.

If you would calculate the confidence interval over an infinite number of regressions with the same sample size, 95% (confidence level) of the calculated confidence intervals will contain the mean's true value.

Since this interval is for the mean, the standard error is smaller and the the range is narrower than the range of the prediction interval.

MS_{residual} = S^{2}_{residual} = | Σ( y_{i} - ŷ)^{2} |

n - 2 |

S.E²_{ci} = S²_{residual} | ( | 1 | + | (x₀ - x̄)² | ) |

n | SS_{x} |

Ŷ ± T_{1-α/2}(n-2)*S.E_{ci}

#### Prediction Interval

The prediction interval for a **particular observation** of the dependent variable.

This is the interval for any single value.

The prediction inteval takes into consideration the fact that you don't know the true equatio, and the fact the the liner regression explaned only part of the variance (the part is R-squared). Even if we would know the true equation then the width of this interval would be greater than zero.

Since this interval is for a single observation, the standard error is larger and the range is wider than the range of the confidence interval

S.E²_{prediction} = S²_{residual} | ( | 1+ | 1 | + | (x₀ - x̄)² | ) |

n | SS_{x} |

Ŷ ± T_{1-α/2}(n-2)*S.E_{prediction}

### How to calculate R squares?

R squares is the percentage of the variance explain by the regression (SS_{Regression}) from the overall variance (SS

_{Total}).

R^{2} = | SS_{Regression} |

SS_{Total} |

### Linear regression in calculator

This online calculator supports all the basic functionality and more.

**right-tailed**F test checks if the entire regression model is statistically significant. Why only right tail?

**Multiple regression calculator**with the stepwise method and assumptions validations:

**multiple regression calculator**

The following statistic checks if the linear regression model supports better results than the average of Y.

_{0}: Y = b

_{0}

_{1}: Y = b

_{0}+b

_{1}X

F = | MS(regression) |

MS (residual) |