Regression and Correlation
Fit a line or polynomial to paired X and Y data and calculate correlation, R² and residual standard deviation.
Association and fitting
Enter paired X and Y lists to calculate linear correlation and an ordinary least squares fit. Degree one fits a straight line. Higher degrees fit polynomials. Correlation r always measures linear association, even when the fitted polynomial has a higher degree.
Using the output
The calculation centers and scales X and solves the fit by QR decomposition. Polynomial coefficients are shown in both x and z = (x − c) / h. For X = 1, 2, 3, 4 and Y = 3, 5, 7, 9 the line is y = 1 + 2x and the residual sum of squares is zero. Residual standard deviation uses the number of observations minus the degree minus one as its divisor.
Limits
Increasing the degree does not by itself improve a model. Inspect outliers and residual patterns. A high R² does not establish causation or reliable future predictions. Constant Y produces undefined r and R². Nearly dependent columns and insufficient distinct X values are rejected.
Frequently asked questions
How do you calculate the correlation coefficient?
The paired data X = 1 2 3 4 5 and Y = 2 4 5 4 5 give a linear correlation coefficient of 0.774596669. Divide the centered cross product sum by the square root of the product of squared deviation sums, keeping the pairs aligned. This example shows a strong but imperfect positive relationship, and correlation does not establish causation and is sensitive to outliers.
Related calculators
-
Statistics and Data Analysis
Normal Distribution and Z Score
Calculate a z score, normal lower and upper tail probabilities, and a quantile. -
Statistics and Data Analysis
Binomial and Poisson Distributions
Calculate exact count, cumulative and upper tail probabilities, plus the mean and variance of discrete event counts. -
Statistics and Data Analysis
Chi Square Goodness of Fit Test
Calculate a chi square goodness of fit statistic, degrees of freedom and approximate p value from observed and expected counts. -
Statistics and Data Analysis
Confidence Interval for a Mean
Calculate a confidence interval from summary statistics. Use a normal interval for known population deviation or a t interval for sample deviation. -
Statistics and Data Analysis
Data Charts and Moving Average
Create histograms, box plots, scatter plots and trailing moving averages. Download data as CSV and charts as SVG. -
Statistics and Data Analysis
Descriptive Statistics Calculator
Find the mean, median, modes, sample and population variance, standard deviation, quartiles and percentiles from a data list.
Found a mistake or something missing?
If a value looks wrong, a size is missing or you need a feature, write to us and we will fix it.