Math

Linear Regression Calculator

Live

Fit a least-squares line to paired x and y observations and make a prediction.

About Linear Regression Calculator

Fit a least-squares line to paired x and y observations and make a prediction. Enter x values, y values, x value to predict in a purpose-built statistics workspace with explicit units and relevant controls. The slope is covariance divided by x variance; the intercept passes the line through the sample means. The result panel reports regression equation, slope, intercept, r-squared, predicted y with supporting context. Results depend on the entered assumptions and should be checked against the real terms, measurements, or source data. Processing stays in your browser and entered values are not sent to UtilityPages.

Set up Linear Regression Calculator

Workspace

Structured calculation

Follow the input-to-result path; the fields below remain the source of every value.

Complete the fields to prepare a result.

Enter the x values used by this tool.

Enter the y values used by this tool.

Enter the x value to predict used by this tool.

Linear Regression Calculator results

Enter the values above, then fit regression to see the result.

Linear Regression Calculator method

The slope is covariance divided by x variance; the intercept passes the line through the sample means.

How it works

The slope is covariance divided by x variance; the intercept passes the line through the sample means. Results depend on the entered assumptions and should be checked against the real terms, measurements, or source data.

Examples

Linear Regression Calculator example

Example input
{
    "x_values": "1, 2, 3, 4, 5",
    "y_values": "2.1, 4.2, 5.8, 8.1, 10.2",
    "prediction_x": 6
}
Expected result
{
    "equation": "y = 2.01x + 0.05",
    "slope": 2.01,
    "intercept": 0.05,
    "r_squared": 0.99735854646,
    "predicted_y": 12.11,
    "points": [
        {
            "x": 1,
            "y": 2.1,
            "fitted_y": 2.06,
            "residual": 0.04
        },
        {
            "x": 2,
            "y": 4.2,
            "fitted_y": 4.07,
            "residual": 0.13
        },
        {
            "x": 3,
            "y": 5.8,
            "fitted_y": 6.08,
            "residual": -0.28
        },
        {
            "x": 4,
            "y": 8.1,
            "fitted_y": 8.09,
            "residual": 0.01
        },
        {
            "x": 5,
            "y": 10.2,
            "fitted_y": 10.1,
            "residual": 0.1
        }
    ]
}

Privacy

This tool does not store your inputs or results on UtilityPages.org.

Frequently asked questions

How does the Linear Regression Calculator work?

The slope is covariance divided by x variance; the intercept passes the line through the sample means.

What should I enter in the Linear Regression Calculator?

Enter x values, y values, x value to predict. Keep units consistent with the labels and use values from the same scenario.

What does the Linear Regression Calculator return?

The result includes regression equation, slope, intercept, r-squared, predicted y. Supporting values are included to make the headline result easier to check.

How exact is the Linear Regression Calculator?

Results depend on the entered assumptions and should be checked against the real terms, measurements, or source data.