How to run a Pearson correlation
- Copy the two measurement columns together with the header (the values must be paired row by row).
- Select the cause side (for example temperature) as Variable X and the effect side (for example strength) as Variable Y. The two columns must differ.
- Press Analyze and check r, the p-value, the confidence interval and the interpretation in the statistics panel.
Worked example with sample data
The sample data are 30 pairs of heat treatment temperature (810-898 °C) and the tensile strength measured at it (319.2-421.9 MPa).
Pearson r is 0.8604, a 'very strong positive correlation', and the p-value of 1.089e-09 is far below 0.05, so it is hard to explain by chance. Even the lower bound of the 95% confidence interval (0.7248-0.9318) is above 0.7, so a strong correlation is likely to appear again with new data.
The trendline y = 0.982x - 471.1 means tensile strength rises by about 0.98 MPa on average for each 1 °C increase, and R² = 0.7403 (= r²) means about 74% of the variation in strength is explained by the straight-line relationship with temperature.
There is no guarantee the same relationship holds outside the measured range (810-898 °C). Rather than concluding that raising the temperature is enough, confirm cause and effect with a process experiment.
How it is calculated
r is the sum of the products of the deviations divided by the spread of each variable, between -1 and 1. The p-value is a two-sided test of 'the population correlation is 0', using the t distribution with n-2 degrees of freedom (the same beta-distribution formula as SciPy's pearsonr).
The 95% confidence interval uses the Fisher z-transformation (z = artanh r, standard error 1/√(n-3)). With fewer than 4 pairs or |r|=1 the interval is not calculated.
Missing values
Rows where X or Y is blank or not a number are dropped entirely (only complete pairs are used). At least 3 valid pairs are needed.
How to read the correlation coefficient r
- |r| below 0.1 is read as almost no correlation, below 0.3 weak, below 0.5 moderate, below 0.7 strong, and 0.7 or more very strong. A positive sign means the variables increase together; a negative sign means one decreases as the other increases.
- A p-value below 0.05 means the correlation is statistically significant. With a lot of data even a weak correlation becomes significant, so look at the size of r too.
- Pearson r only measures straight-line relationships. If the scatter plot is curved, Spearman rank correlation fits better - and correlation does not imply causation.
Frequently asked questions
Is it the same as Excel's CORREL?
Yes. r equals Excel's CORREL and PEARSON functions; here you also get the p-value and confidence interval.
How are R² and r related?
The R² of the linear trendline is r squared. In the example r=0.8604, so R²≈0.7403.
What if there are outliers?
Pearson r is strongly affected by outliers. If you see isolated points on the scatter plot, check with Spearman or Kendall rank correlation as well.