Pearson and Spearman correlations
Testing the association between two quantitative variables – direction, strength, significance and confidence interval – for all the selected pairs at once. The output: a correlation matrix in the standard table layout (and a "submission table" version with two decimals), a detail table with confidence intervals, scatter plots with a figure note, report sentences in English, "Interpreting the result", Word and SPSS syntax.
Loading the data
Paste columns directly from the sheet (including the header row) – select them in Excel, copy, and paste here:
Variable selection and correlation type
When to use?
When you want to test the association between two variables: whether an increase in the value of one is related to an increase, or rather to a decrease, in the value of the other. Pearson requires two quantitative variables (interval or ratio scale); Spearman is suitable also when one of the variables was measured on an ordinal scale – the full distinction follows right below. Both assume independent observations: each row in the data is a different participant, and there is no relation between the rows – the same participant measured twice, or students from the same class, violate this assumption. The correlation coefficient reports two things at once – the direction of the association (positive or negative) and its strength. It is important to remember: correlation is not causation. Even a very strong association still does not mean that one variable causes the other: a third variable, not measured at all, may create the association between them; the direction of influence may be the reverse of what we thought; and there may be other explanations. On examining a suspected third variable, see partial correlation further down the page.
Pearson or Spearman?
Pearson's r (Pearson)
Suitable for a pair of continuous quantitative variables, when the association between them is approximately linear. The coefficient is especially sensitive to outliers. Normality is not a condition for computing the coefficient itself – it concerns mainly the validity of the significance test and the confidence interval, especially in small samples.
Spearman's rho (Spearman)
Based on ranks – the position of each observation in order from smallest to largest – and not on the values themselves. Suitable when at least one of the variables was measured on an ordinal scale (such as a single Likert item), when the association is monotonic – consistently increasing or consistently decreasing, even if not in a straight line – and when asymmetric distributions or extreme outliers make Pearson unsuitable. A small sample alone is not a reason to prefer Spearman – in small samples the p value of Spearman is also based on an approximation.
And what if one of the variables is dichotomous? When one variable is dichotomous (only two values, e.g., studied/did not study) and the other is quantitative (e.g., salary), the correlation known as Point-biserial is used: the dichotomous variable is coded as 0 and 1, and the calculation itself is identical to that of the Pearson correlation (Gravetter & Wallnau, 2017, pp. 516-517; Field, 2024, Section 8.4.5; Cohen et al., 2003, Section 2.3.3, pp. 29-30) – and so in practice it can also be computed with the calculator on this page, using such coding.
But do not create an artificial dichotomy. The reverse direction is not recommended: do not cut a continuous variable into two "groups" (e.g., a split at the median – median split) to "simplify" the analysis. Cutting gives up information: for normally distributed variables, the correlation obtained after a split at the mean will be only about 80% of the original correlation – a loss of about a fifth, equivalent to giving up about 38% of the sample; and the farther the cut point is from the mean (e.g., "high/low" by some threshold), the larger the loss – with a cut at one standard deviation only about two thirds of the correlation remain (Cohen, 1983). Statistical power also suffers: the chance of detecting an association that really exists drops – in the example of MacCallum and colleagues, for ρ = .40 and N = 50, power drops from .84 to .63 after splitting one variable at the mean (MacCallum et al., 2002, pp. 26-27). The point-biserial correlation is intended for a variable that is dichotomous by nature – not for a continuous variable that has been split.
How to interpret the result?
The correlation coefficient r – and for the Spearman correlation: rs – ranges from -1 to +1, and it has two components, each of which tells a different story. The sign – positive or negative – tells the direction of the association. The magnitude, regardless of the sign (|r|), tells how strong the association is: the closer it is to 1, the stronger the association – the linear one in Pearson, the monotonic one in Spearman – and the closer it is to 0, the weaker.
A perfect Pearson correlation (r = ±1) means that all the points lie exactly on one straight line – rising or falling. A perfect Spearman correlation (rs = ±1) requires less than that: it is enough that every increase in one variable is always accompanied by an increase (or always by a decrease) in the other variable – even if the points do not lie on a straight line.
And what does r = 0 say? Only that there is no linear association. A low or zero correlation does not prove that there is no association at all between the variables: there may still be a strong nonlinear association between them – for example, in the shape of a U – which the Pearson coefficient simply does not see. So it is always worth glancing at the scatter plot in the output as well.
The same r – completely different pictures. The most famous demonstration of the importance of the scatter plot is "Anscombe's quartet": four data sets that all have the same means, the same standard deviations and the same correlation – r = .816 – but in a scatter plot they look completely different from one another: in one – an ordinary linear association; in the second – a curve that is not linear; in the third – a perfect line from which one outlier "pulls" the coefficient; and in the fourth – a correlation that rests entirely on a single extreme observation (Anscombe, 1973). The conclusion: never settle for the coefficient alone – always look at the data themselves too. And there is no need to postpone this look until SPSS: on the site's Scatter plot and regression line page you can upload the same data file, choose a pair of variables and immediately get their scatter plot – with the regression line, the correlation coefficients and R².
Strength of the association. There is no universal threshold for dividing correlations into weak, moderate or strong. For orientation, Cohen's conventions are commonly used (Cohen, 1988, pp. 79-81): |r| < .10 – negligible; .10-.30 – weak; .30-.50 – moderate; .50 and above – strong. This is also the scale used by the automatic report sentences on this page. Some guides suggest a slightly different division, and Cohen himself stresses that these are conventions to be used only when no more suitable yardsticks are available for the field. Therefore the strength of a correlation should be interpreted according to the research context, the nature of the variables and previous findings in the field – and not by ready-made thresholds (Cohen, 1988, p. 79; Field, 2024, Section 8.2.2; Pallant, 2020, Chapter 11).
Significance is not strength. A large sample does not make the association itself stronger – it only makes its measurement more precise. The result: in a large sample even a tiny correlation may come out significant, and in a small sample a real association may simply be missed. So always report r, p and N, and do not settle for only one of them.
The confidence interval. The sample r is an estimate; the 95% confidence interval says in what range the correlation in the population plausibly lies – and so it complements what p alone does not say. The detail table and the report sentences on the page show it for every Pearson correlation, computed via the Fisher transformation (the formula and an example – in the formulas section; Field, 2024, section 8.2.4). Two things to read in it: whether it includes zero (if so – the data do not rule out the absence of an association, and this parallels a non-significant p), and how wide it is – an interval such as [.02, .53] (e.g., r = .30 with n = 50) shows that the correlation was estimated with considerable imprecision, even if it is significant. The interval is not symmetric around r – and that is fine. Field (2024, section 8.8) recommends reporting the confidence interval alongside the correlation – and this is what the report sentences on the page do.
Why is the correlation lower than expected? Two "technical" factors systematically shrink correlations. Restricted range (restriction of range): when the sample covers only part of the range of values – for example, testing the association between a selection score and success on the job only among those who were hired – the observed correlation comes out lower than the correlation in the full population; Cohen even warns that his sample-size tables are not valid under restricted range (Cohen, 1988, p. 100). Attenuation due to reliability (attenuation): when the measurement instruments are not precise, random noise is added to the scores – and this noise attenuates (reduces) the observed correlation (Cohen, 1988, p. 79). The approximate rule: the correlation seen in the sample equals the true correlation times √(rxx·ryy) – the square root of the product of the reliabilities of the two instruments. Example: a true association of .50 between two measures, each with a reliability of .70, will appear in the sample as only about .35. Therefore, when comparing a correlation to previous findings, it is worth paying attention both to the range of the sample and to the reliability of the instruments. For a systematic discussion of the factors that affect the size of r – including the correction formulas for both phenomena – see Cohen et al. (2003, section 2.10).
Multiple comparisons. When many correlations are tested at once, the chance increases that at least one of them will be found significant by chance: with five variables, ten tests are already conducted. In confirmatory research it is advisable to define the hypotheses in advance, or to consider a correction to the significance values for multiple comparisons (e.g., the Holm or FDR correction).
The correlation is not a percentage. A correlation of r = .50 does not indicate "a 50% association". To express the proportion of variance shared by the two variables, the Pearson coefficient is squared: in this case r² = .25, that is, 25% shared variance. The shared-variance interpretation is correct for the Pearson correlation – it is not applied automatically to the square of the Spearman coefficient.
Common mistakes
Reporting the p value without reporting the strength of the correlation (r) – significance alone does not say how strong the association is. Interpreting a "non-significant" result as proof that "there is no association" – perhaps the sample is simply too small to detect an existing association. Inferring causation from correlation. Presenting r as a percentage. Running a Pearson correlation on a single Likert item without considering Spearman – for a single item Spearman is in most cases more suitable, although this is an accepted convention and not an absolute rule: Jamieson (2004) on the strict side, Norman (2010) on the lenient side – and he also showed on real Likert data (64 pairs of correlations) that Pearson and Spearman give almost the same results, even in highly skewed distributions (a correlation of .99 between the two types of coefficients). And forgetting to report the sample size (N) on which each correlation is based.
And relying on pairwise deletion without thinking. The calculator, SPSS and R (with pairwise.complete.obs) compute each correlation on the participants who have a valid value on both variables of that pair – which is why in the example table N ranges from 447 to 483. This convenience is not free. Gelman & Hill (2007, pp. 531-532) call the method available-case analysis and point to two problems. The first: each correlation in the matrix is computed on a different subset of the participants, and so the correlations "are not necessarily consistent with one another" – they describe, in practice, slightly different samples. The second, which also applies to listwise deletion: if those who did not respond differ systematically from those who did, the estimate is biased. Their example from a survey in New York: 90% of the Black respondents reported their income compared with 81% of the white respondents, and so the income summary represents a different population from the one the education summary represents. The practical conclusion is not to give up pairwise deletion – when the missingness is small and random it is reasonable, and usually preferable to throwing out whole participants – but three habits: report the range of N (as the table does); check, when the gap between the pairs is large, who is missing and on which variable; and remember that when the missingness is not random, the solution is model-based completion of the data (imputation; ibid., sections 25.3-25.6; see the Handling missing values page), not a choice between two deletion methods.
Partial correlation – controlling for a third variable
Sometimes the correlation between two variables does not reflect a direct association between them, but is "created" by a third variable correlated with both – a phenomenon known as spuriousness (spurious correlation). The partial coefficient (Partial correlation) tests such a suspicion: it computes the correlation between x and y while statistically controlling for a third variable z (Gravetter & Wallnau, 2017, p. 502; Field, 2024, Section 8.5.2; Cohen et al., 2003, Section 3.3.3, p. 74).
A well-known example: in a sample of cities, the number of houses of worship in a city is strongly correlated with the number of serious crimes in it – r = .92. The explanation is not that houses of worship breed crime: both variables are correlated with a third variable – population size (r = .96 with the number of houses of worship and r = .96 with the number of crimes). A big city has a lot of both, a small town – little of both. After controlling for population size, the partial correlation drops to zero – a classic spurious correlation (Gravetter & Wallnau, 2017, pp. 497, 503; the data in this example are invented for illustration, as stated in the book). Note that here rxy ≈ rxz·ryz – and this is exactly the formal condition for a spurious association: x is related to y only through z (Cohen et al., 2003, Section 3.4.4, p. 78). But controlling does not always "break up" the association: in Pallant's example (2020, chapter 12) the correlation between perceived control and perceived stress is r = −.58, and after controlling for social desirability it remains almost the same (partial correlation r = −.55). When the partial correlation is close to the original correlation, this is in fact evidence that the association stands on its own and is not a product of the third variable tested. The partial correlation is computed from the three pairwise correlations:
And in the houses-of-worship and crime example (with the exact numbers from the book):
A close relative: the semi-partial correlation. In the partial correlation the third variable is removed from both variables. In the semi-partial correlation (semi-partial; in SPSS it is called Part) z is removed from only one of the variables. The difference in interpretation: the square of the semi-partial correlation gives the unique contribution of x to explaining y, as a proportion of the total variance of y. In the square of the partial correlation, by contrast, the proportion is computed only out of the variance that remains after removing z (Field, 2024, Section 8.5). The measure is important mainly in multiple regression, where it expresses the unique contribution of each predictor. The formula is identical to that of the partial correlation – except that only one square root remains in the denominator:
It is also possible to control for two variables simultaneously – a second-order partial correlation (Field, 2024, Section 8.5.3). Note: a low partial correlation does not "cancel" the observed association – it shows that a considerable part of it is explained by the third variable; and the choice of the variable to control for is a theoretical consideration, not a statistical one. For the full development of the partial and semi-partial correlations in a multivariate context, see Cohen et al. (2003, sections 3.3.2-3.3.3, pp. 72-75).
Three different roles for a third variable. Partial correlation deals with a third variable in one role – a confounding variable (confounder), which creates a spurious association, like population size in the houses-of-worship and crime example (Cohen et al., 2003, Section 3.4.4). But a third variable can also play a moderating role (moderator): the strength or direction of the association between x and y changes according to the values of z – a first glimpse of this is given by comparing the correlation between groups (see "Comparing two correlations" in the formulas section), and the full test is done with an interaction in regression (the classic development: Cohen et al., 2003, chapter 7); or a mediating role (mediator): z is the mechanism through which x is related to y (x → z → y), and then a mediation analysis decomposes the total association into a direct and an indirect effect (the development: Cohen et al., 2003, chapter 12; Field, 2024, sections 11.3-11.4). It is important to know: partial correlation cannot distinguish between a confounder and a mediator – the calculation is identical in both cases, and the distinction between them is a matter of theory and research design. Moderation and mediation belong to the world of regression – see the Moderation and mediation page (interaction, simple slopes, indirect effect with bootstrap), the Multiple linear regression page, and for mediation in a path model – the Path analysis and mediation page, which decomposes the association into a direct and an indirect effect with confidence intervals.
And how do you do it in SPSS?
The calculator on this page parallels the common settings of the Bivariate Correlations procedure in SPSS. For detailed guides see Pallant (2020, chapters 11-12) and Field (2024, chapter 8).
Version note. The screenshots in this section were produced in SPSS version 21. The procedures themselves are stable across versions, but the location of menu items and the names of options may change slightly – and if your screen looks a little different, that is probably why. A concrete example appears further down the page: the Confidence Interval button was added to the Bivariate Correlations window only in version 27, and in earlier versions you will not find it there. Field (2024) was written for version 29, and he himself is reassuring on the matter: new versions come out between editions, and the procedures the book describes are hardly affected by this.
In the menu, choose Analyze › Correlate › Bivariate…:
In the dialog box that opens (Bivariate Correlations), the list of variables in the file appears on one side, and the variables whose association you want to test (two or more) are moved into the Variables box. Under Correlation Coefficients, the Pearson coefficient (Pearson) is checked by default – another click unchecks it – while the Spearman coefficient (Spearman), which is not checked by default, is checked in that same box; you can also check both together, like the "Both" option on this page. (Kendall's tau-b is another rank coefficient that appears there, which the page does not compute.)
The SPSS defaults are identical to those of the page – two-tailed significance (Two-tailed), flagging significant correlations with asterisks (Flag significant correlations) and pairwise deletion of missing values (Options › Exclude cases pairwise) – so in most cases the results should be identical up to rounding differences. (The page always computes two-tailed significance, and does not include other options of the procedure such as a one-tailed test.) One small difference in flagging: SPSS flags only p < .05 and p < .01, whereas here *** is also flagged for p < .001, as is customary in APA tables (American Psychological Association [APA], 2020, Section 7.14).
Clicking Paste in the dialog box saves the action as syntax – useful for documenting the analysis and reproducing it:
CORRELATIONS /VARIABLES=leadership efficacy readiness belonging trust /PRINT=TWOTAIL NOSIG /MISSING=PAIRWISE.
And the confidence interval? The syntax above does not print it. In SPSS 27 and later, click Confidence interval… in the Bivariate Correlations window and check Estimate confidence interval of bivariate correlation parameter – and a second table with the lower and upper bounds of each correlation is added to the output (Field, 2024, Sections 8.4.1-8.4.2). For Pearson the calculation is the Fisher transformation – the same interval the detail table on this page shows. In earlier versions the button does not exist, and the interval is computed with the formula in the formulas section – or here on the page.
And even before the coefficients – a look at all the pairs at once. The scatter-plot advice can be applied to all pairs of variables in one go, using a scatter-plot matrix: in the menu Graphs › Legacy Dialogs › Scatter/Dot… › Matrix Scatter › Define, move the variables into the Matrix Variables list and confirm. The same matrix can also be built in the modern Chart Builder, where you can also create a single scatter plot with a fit line or a scatter plot grouped by groups (Field, 2024, Section 5.8). Here too Paste saves the syntax:
For a single, more detailed scatter plot – with a regression line, R² and ready-made report sentences – see the scatter plot page, which also has a full illustrated SPSS guide to the procedure.
GRAPH /SCATTERPLOT(MATRIX)=leadership efficacy readiness belonging trust /MISSING=LISTWISE.
Three points in reading the matrix. First, all the cells show a rising cloud – consistent with the ten positive and strong correlations in the output table, and without signs of a curved association or influential outliers; this is exactly the check that Anscombe's quartet teaches (see above). Second, the points pile up on an orderly "grid" – this is expected when the variables are means of discrete scale items, and is not a problem. And third, note that the GRAPH command uses listwise deletion by default (/MISSING=LISTWISE) – unlike the pairwise deletion of the correlation table – and so the number of points in each cell may be slightly smaller than the N of that pair in the table.
And checking normality in practice? As noted, normality concerns mainly the validity of the significance test, especially in small samples. The check is done graphically: in the menu Analyze › Descriptive Statistics › Explore check Normality plots with tests and you get a Q-Q plot – if the points hug the diagonal line, the distribution is close to normal – alongside the measures of asymmetry (skewness) and kurtosis in the same output (Field, 2024, Sections 6.9.4-6.9.5). And when doubt remains – a bootstrap confidence interval (see the formulas section) greatly reduces the dependence on the normality assumption; it too, of course, relies on independent observations and on a sample that represents the population.
Reading the output
This is what the SPSS output table (Correlations) looks like for the five resilience variables – leadership, efficacy, readiness, belonging and trust. The output table is a symmetric matrix: the variables serve as headings both in the rows and in the columns, and each pair gets two identical cells – one above the diagonal and one below it. Each cell has three rows:
The first row in each cell – the correlation coefficient (Pearson Correlation). In the row marked with the arrow, for example, the correlation between readiness and leadership is .722 – a positive correlation: high levels of readiness tend to go together with high levels of leadership, and by Cohen's conventions this is a strong correlation. Had the sign been negative, the meaning would have been the reverse – the higher the value of one, the lower the value of the other. On the diagonal there will always be 1: each variable is perfectly correlated with itself. This is not a finding – simply skip the diagonal.
The second row – significance (Sig. (2-tailed)). SPSS shows the p value with three digits after the decimal point, so .000 does not mean zero but p < .001 – and that is also how it is reported (never p = 0; APA, 2020, section 6.36). The asterisks next to the coefficients, explained in the footnote below the table, mark a significant correlation; in this table all the correlations are significant.
The third row – sample size (N). The number of participants on whose data that correlation was computed. Note that N changes from pair to pair (e.g., 455 for the leadership-efficacy pair vs. 447 for the leadership-readiness pair): this is pairwise deletion – each correlation is computed on the participants who have a valid value on both variables of that pair, in accordance with /MISSING=PAIRWISE in the syntax.
What is important to know about pairwise deletion. The advantage – each correlation uses the maximum of the available data. The price – each correlation is computed on a slightly different subsample, so the comparison between coefficients in the matrix is not based on exactly the same participants; when there are many missing values, such a matrix may even turn out inconsistent for follow-up analyses that rely on it (such as multiple regression or SEM). Therefore N is reported for each correlation (as in the table note this page shows), and when there are many missing data, listwise deletion (Options › Exclude cases listwise in the Bivariate window) or dedicated handling of missing data is considered.
Two things determine the reading: the magnitude of the coefficient, from which the strength is read, and its sign, from which the direction is read. In this table all ten correlations are positive, strong (.622-.738) and significant. The output table of the Spearman correlation is built in exactly the same layout. This page presents the same information in a more economical APA format: a lower-triangle matrix in which the asterisks mark significance, and N is reported in the table note.
Reporting the results
The decision between text and table is a matter of quantity: one pair amounts to a sentence; ten pairs, as here, can no longer be read in sequence – so two levels are combined: a concise table that gathers all the correlations, and text that highlights the picture emerging from the table – without repeating every number that already appears in it. This is what the report will look like for the output we have just read.
The table. The SPSS matrix is not copied into the paper as is: it shows each correlation twice, and in research reporting there is no need to report any correlation more than once. A correlation table should be concise and contain only the necessary information: a lower triangle, values without a leading zero and with two digits after the decimal point – as the APA format requires (APA, 2020, Section 6.36) – and without exact p values – significance is marked with asterisks, whose legend is written below the table (section 7.14). This is exactly the structure of the sample correlation table in the manual: the variables are numbered in the stub column, the column headings show the numbers only, and the diagonal – where the correlation of a variable with itself is 1 – is marked with a long dash (em dash), and not with a number (section 7.21, Table 7.10). Nor is there any need to write the sample size in each cell: when the same N repeats, it is reported once, below the table or below its title, and when it changes from pair to pair – as here, because of pairwise deletion – the range is reported. (The correlation matrix the page shows in the output actually stays at three digits, as in SPSS and R, to make it easier to check and cross-check against them; in the table submitted in a paper, round to two – the "Copy submission table" button below the matrix does this automatically.) Note: the correlations marked in the output with ** (significant at the .01 level) are actually p < .001 – and so in the table they are marked ***.
Table 1. Correlation matrix (Pearson) of the five resilience variables
| 1 | 2 | 3 | 4 | |
|---|---|---|---|---|
| 1. Leadership | — | |||
| 2. Efficacy | .72*** | — | ||
| 3. Readiness | .72*** | .71*** | — | |
| 4. Belonging | .67*** | .68*** | .62*** | — |
| 5. Trust | .67*** | .74*** | .63*** | .68*** |
*** p < .001 (two-tailed). Pairwise deletion; N ranges from 447 to 483.
The text. A verbal report of a correlation includes three components: the correlation itself, its significance and the sample size. The rule behind them: the text should include enough information for the reader to understand the analysis performed and to be able to verify it, including effect sizes and confidence intervals when available (APA, 2020, Section 6.43). It is worded so that the finding is read in words and the statistics are given in parentheses, for example: it was found that the higher the efficacy, the higher the trust (r = .74, 95% CI [.69, .78], p < .001, n = 479). The confidence interval goes in the parentheses after r – this is also how Field (2024, section 8.8) reports, and how the report sentences on the page are worded. The sample size can be reported as n, or as degrees of freedom in the parentheses after the r – r(477) = .74, where df = N − 2 – and when N is the same for all the correlations, it is reported once at the head of the results chapter, saving the repetition. In the body of the text, refer to the table, describe the overall pattern and highlight notable findings, for example the strongest and the weakest correlation:
To examine the associations among the five resilience variables, Pearson correlations were computed between all ten pairs of variables. As shown in Table 1, all the correlations were found to be positive, strong and significant (rs = .62–.74, ps < .001). The strongest correlation was found between efficacy and trust, r(477) = .74, 95% CI [.69, .78], p < .001, and the weakest – between readiness and belonging, r(476) = .62, 95% CI [.56, .67], p < .001.
Pearson correlations were computed among the five resilience variables. As shown in Table 1, all ten correlations were positive, strong, and statistically significant (rs ranged from .62 to .74, all ps < .001). The strongest correlation was found between "efficacy" and "trust", r(477) = .74, 95% CI [.69, .78], p < .001, and the weakest between "readiness" and "belonging", r(476) = .62, 95% CI [.56, .67], p < .001.
The calculator on this page produces the table and the report sentences in this format automatically from the data file, and the full output can be downloaded as a Word file.
And the chart. When the scatter plot itself goes into the results chapter – and is not only used for checking the assumptions before the calculation – it is a figure, and a figure has a structure of its own: a number, a title in italics, the variable names on both axes, and a note below it. The note is easy to forget, but it is the component that makes the figure stand on its own, and APA (2020, section 7.28) specifies what it should say: explain units of measurement, symbols and abbreviations not explained in the legend, and explain any shading, color or other design element that carries meaning. In a scatter plot this translates into two short sentences – what each point represents (one participant, by their values on the two variables) and what the line is (the linear regression line). And if error bars or a confidence band are shown in the chart, state explicitly whether they represent standard deviations, standard errors, confidence limits or ranges – and the manual adds that it is worth stating the sample size alongside them (ibid.). The figure note is written in the format of a table note, and in the same order – general, specific, probability – and the significance asterisks, if any, are explained in a probability note exactly as below a table (section 7.14).
In the output of this page each scatter plot comes with such a figure note, built automatically: what each point represents and on which axis each variable is, what the line is (and when only Spearman is selected there is no line – and the sentence is omitted), and the sample size with the method of handling missing values. The chart itself is copied from the screen (it is not included in the Word file), and the note – from the output table.
And how do you do it in R?
R is a free, open-source environment for statistics, and exactly the same analysis is done in it in a few lines: cor() gives the correlation matrix, crossprod(!is.na()) the N of each pair, and cor.test() – for a single pair – t, p and the confidence interval (via the Fisher transformation, like the page). The script below was run verbatim on the page's sample file (DATA_correlations_example_eng.xlsx, the three variables selected in it by default), and the results – identical to Tables 1-2 and to the report sentences – are recorded in the comments. The site rule for Hebrew in R: a UTF-8 file, every comment line starts with an English word, short English names for computation, and a UTF-8 locale for Hebrew names (on Windows: Sys.setlocale("LC_ALL", "Hebrew") or R 4.2 and later). Replace the path and the variable names with your own; in R the path is written with a regular forward slash (/).
# Pearson and Spearman correlations – Professor Stat. This file is saved in UTF-8; every comment line starts with an English word
library(readxl) # reading Excel
# Loading: the standard template – row = participant, column = variable; the sheet "data"
d <- read_excel("C:/Rdata/DATA_correlations_example_eng.xlsx", sheet = "data")
d <- d[, c("age", "attitude1", "attitude_score")] # the variables selected on the page (the sample file's default)
names(d) <- c("age", "att1", "att") # short English names
# Table 1 – Pearson matrix with pairwise deletion, three digits as in SPSS and as in the table on the page
round(cor(d, use = "pairwise.complete.obs"), 3) # age-att1 .116, age-att .209, att1-att .684
# Number of participants in each pair (N of the pairwise deletion – the table note)
crossprod(!is.na(d)) # 114, 116, 118 (and on the diagonal: 116, 118, 120 valid observations for each variable)
# Table 2 – single pair: r, df, t, p and 95% confidence interval via the Fisher transformation (like the page)
cor.test(d$age, d$att) # r = .209, t(114) = 2.278, p = .0246, CI [.027, .377] – as in Table 2 and the report sentence
# Spearman correlation – the same matrix on the ranks; for the p of a single pair: cor.test(..., method = "spearman", exact = FALSE)
round(cor(d, use = "pairwise.complete.obs", method = "spearman"), 3) # .095, .226, .669
cor.test(d$age, d$att, method = "spearman", exact = FALSE) # rho = .226, p = .0145 (t approximation, as in SPSS and on the page)
Two important points in the code: the argument use = "pairwise.complete.obs" is pairwise deletion – without it, in the presence of missing values R will return NA, and with listwise deletion the results will not match SPSS; and cor.test computes for a single pair on the complete observations of that pair only (hence df = 114 in the example – 116 participants with a value on both variables). p-value < 2.2e-16 is R's notation for a value smaller than anything it displays – and in the report write p < .001. In Spearman, when there are tied ranks, cor.test without exact = FALSE will warn "Cannot compute exact p-value with ties" – this is fine: it switches to an approximation, the same approximation that both SPSS and this page use. (Optional: the Hmisc package with rcorr() prints r, n and p for all pairs in a single SPSS-style output.)
The three tools – SPSS, R and the calculator on this page – compute the same coefficients when they are set up the same way – pairwise deletion and two-tailed significance: in SPSS and in the calculator these are the defaults, and in R this is stated explicitly in the code above. Therefore on the same data file they return the same results. Such cross-checking between two tools is an excellent way to make sure the analysis was done correctly.
The formulas behind the coefficients
For a detailed development of the formulas in this section, see Gravetter & Wallnau (2017, chapter 15).
The Pearson coefficient – from standard scores. The most transparent way to understand Pearson is through standard scores: convert each value to a standard score – how many standard deviations it is above or below the mean of its variable, zx = (x − x) / sx – and then sum the products of the pairs of standard scores and divide by n − 1:
(Why n − 1? Because that is the divisor inside the sample standard deviation s from which the standard scores were built. In books that define standard scores with a population standard deviation, the division here is also by n – as long as the convention is the same in the numerator and the denominator, r comes out identical.)
The logic: when an observation is above the mean on both variables, both standard scores are positive and the product is positive; when it is high on one and low on the other, the product is negative. If most of the products are positive – r comes out positive; if most are negative – negative; and when there is no consistent pattern, the positive and negative products cancel each other out and r approaches 0.
Covariance. The same idea can also be reached from the raw values: for each observation, multiply the deviation from the mean of x by the deviation from the mean of y, sum the products and divide by n − 1 – the same convention as the sample standard deviation:
The covariance measures how much the two variables "move together", but in raw values – so its size depends on the units of measurement (measuring height in cm instead of meters will inflate it 100 times). To get a unit-free measure, divide by the standard deviations of the two variables – and the result is exactly the Pearson coefficient:
This division standardizes the covariance into a fixed range, -1 to +1. Note the distinction between two related terms we have met on the page: the covariance is the joint variation in raw units, whereas r² expresses the proportion of shared variance – a standardized, unitless measure. (Technical note: some books divide by n and some by n − 1; r comes out identical, because the same factor appears in the numerator and the denominator and cancels out.)
Three properties worth knowing. First, r is not affected by a linear transformation of the variables – adding a constant or multiplying by a positive constant (switching from cm to meters, from points to percentages) does not change it at all; multiplying by a negative constant only reverses the sign, and the strength |r| is preserved. Second, r itself is not interpreted as a ratio scale: r = .40 is not an association "twice as strong" as r = .20; to compare amounts of shared variance, compare the squares (.16 vs. .04). And third, Pearson takes into account the actual values of the observations – unlike Spearman, which sees only their position in the ranking.
The Spearman coefficient – from the ranks. Spearman is computed on the rankings only. When there are no tied ranks, the familiar shortcut formula can be used:
where di is the difference in ranks of observation i between the two variables, and n the number of observations. If the two rankings are completely identical, all the differences are 0 and rs = +1 is obtained; if the ranking on one variable is exactly the reverse of the ranking on the other, rs = -1 is obtained. The raw values carry no weight at all – only the position in the ranking.
A small example: five candidates were ranked in an interview by two interviewers, and we want to know how much the rankings agree with each other:
| Candidate | Interviewer A's ranking | Interviewer B's ranking | d | d² |
|---|---|---|---|---|
| A | 1 | 2 | -1 | 1 |
| B | 2 | 1 | 1 | 1 |
| C | 3 | 3 | 0 | 0 |
| D | 4 | 5 | -1 | 1 |
| E | 5 | 4 | 1 | 1 |
Σd² = 4
That is, high agreement between the two interviewers. An important note for practical use: when there are tied ranks (ties), the tied observations are given the mean of their ranks, and then the shortcut formula is no longer exact. The general method – which is always correct – is to compute the Pearson coefficient on the ranks. This is exactly how Spearman is computed both on this page and in SPSS, and so when there are no tied ranks both methods return exactly the same value.
The significance test of the correlation. A correlation found in the sample still needs to be tested: is there enough evidence that it also exists in the population? The null hypothesis is that there is no correlation in the population (ρ = 0). From r and the sample size n, a t value is computed:
This value follows a t distribution with df = n − 2 degrees of freedom – these are the degrees of freedom we met in the reporting format r(df). If the resulting p value is smaller than the significance level (usually 5%), the null hypothesis is rejected and it is concluded that a correlation exists in the population. The formula is stated for Pearson; the p value of Spearman is computed – on this page and also in SPSS – with the same t approximation, hence the reservation mentioned above regarding small samples. The hypothesis can be stated as non-directional (two-tailed) or as directional (one-tailed), according to the research hypothesis. The distinction can be decisive: in the example of Gravetter & Wallnau (2017, pp. 507-509), a correlation of r = .35 in a sample of 30 participants gives t(28) = 1.97 – a value that does not cross the two-tailed threshold (2.048) but does cross the one-tailed threshold (1.701). The very same correlation is significant in a directional test and not significant in a non-directional test; therefore the direction of the hypothesis is set in advance, according to theory, and not after seeing the result. The formula, the explanation of the degrees of freedom and the t test are also developed in Field (2024, section 8.2.3).
Confidence interval for the Pearson correlation. The r found in the sample is a point estimate, and it is recommended to report a confidence interval alongside it. Because the sampling distribution of r is not symmetric, the interval is computed via the Fisher transformation (Fisher z): r is converted to a value z′,
whose standard error is 1/√(n − 3). A 95% confidence interval is built around z′ (±1.96 standard errors) and its limits are converted back to the r scale. The resulting interval is not symmetric around r – and that is fine. Example: r = .30 with n = 50 gives a confidence interval from .02 to .53 – a concrete reminder that in small samples even a "moderate correlation" is estimated with great imprecision. This is exactly how the confidence interval in the detail table and in the report sentences of the page is computed (Field, 2024, section 8.2.4, equations 8.12-8.14; in his example – r = .87 with n = 5 – the interval is [−.05, .99]: in a tiny sample the interval is almost useless). In SPSS 27 and later the same intervals can be requested directly in the Bivariate Correlations window (the Confidence interval button; see above).
Bootstrap confidence interval. When there is concern about violation of the normality assumption, a confidence interval can also be built with the bootstrap – resampling from the sample itself, without assumptions about the shape of the distribution (but assuming independent observations and a sample that represents the population); this is also the accepted way to obtain a confidence interval for the Spearman correlation. In SPSS: the Bootstrap button in the Bivariate window, and it is customary to report the bias-corrected version (BCa) of the confidence interval. Bootstrap results vary slightly from run to run, because the method is based on random sampling – this is a feature, not a bug (Field, 2024, Sections 8.4, 6.10.8).
Comparing two correlations. The Fisher transformation is used here too. When the correlations come from two independent groups (e.g., does the association between test anxiety and grade differ between men and women?), each correlation is converted to z′ and the difference is tested:
The resulting z is compared with the normal distribution: an absolute value above 1.96 means a significant difference at the 5% level (two-tailed). When the correlations come from the same sample (e.g., is x more strongly related to y than z is?), the comparison is done with a t test with df = N − 3, which uses the three pairwise correlations; in SPSS there is no built-in menu for this (Field, 2024, Section 8.6). And note: the fact that one correlation came out significant and the other did not – is not evidence that they differ from each other; the difference itself must be tested directly.
References
American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000
Anscombe, F. J. (1973). Graphs in statistical analysis. The American Statistician, 27(1), 17-21.
Cohen, J. (1983). The cost of dichotomization. Applied Psychological Measurement, 7(3), 249-253. https://doi.org/10.1177/014662168300700301
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.
Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Lawrence Erlbaum Associates.
Field, A. (2024). Discovering statistics using IBM SPSS statistics (6th ed.). SAGE.
Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge University Press.
Gravetter, F. J., & Wallnau, L. B. (2017). Statistics for the behavioral sciences (10th ed.). Cengage Learning.
Jamieson, S. (2004). Likert scales: How to (ab)use them. Medical Education, 38(12), 1217-1218. https://doi.org/10.1111/j.1365-2929.2004.02012.x
MacCallum, R. C., Zhang, S., Preacher, K. J., & Rucker, D. D. (2002). On the practice of dichotomization of quantitative variables. Psychological Methods, 7(1), 19-40. https://doi.org/10.1037/1082-989X.7.1.19
Norman, G. (2010). Likert scales, levels of measurement and the "laws" of statistics. Advances in Health Sciences Education, 15(5), 625-632. https://doi.org/10.1007/s10459-010-9222-y
Pallant, J. (2020). SPSS survival manual: A step by step guide to data analysis using IBM SPSS (7th ed.). Routledge.
According to the site rule, the reference list includes only sources that were read in the original. Field (2024) and Pallant (2020) in a reflowable digital copy – cited by section and chapter; Gravetter and Wallnau (2017), Cohen (1988), Cohen et al. (2003), Gelman and Hill (2007) and APA (2020) – by page and section of the printed edition; the articles (Anscombe, 1973; Cohen, 1983; MacCallum et al., 2002; Jamieson, 2004; Norman, 2010) – according to the original text. The calculation on the page is validated against scipy and R.