Skip to content

[Bug]: Scatter plot for partial correlation shows original data points instead of residuals #3507

@mupeker

Description

@mupeker

JASP Version

0.19.3

Commit ID

No response

JASP Module

Regression

What analysis are you seeing the problem on?

partial correlation

What OS are you seeing the problem on?

Windows 10

Bug Description

Dear JASP Team,

When performing Spearman partial correlation analysis in JASP, I've observed an inconsistency in the generated scatter plot output. The software correctly calculates and labels the partial Spearman correlation coefficient (ρ XY.Z) alongside the plot. However, the scatter points and the displayed trend line within the graph appear to represent the original ranked values of the dependent and independent variables, rather than the residuals.

This means that for a partial correlation between X and Y controlling for Z, the plot shows the relationship between X's ranks and Y's ranks, even though the accompanying numerical ρ value represents the partial correlation (i.e., the correlation between X's residuals and Y's residuals after controlling for Z). This creates a discrepancy where the visual representation does not accurately align with the numerical statistical result being reported for the partial correlation.

Thank you for your attention to this matter. I find JASP to be an excellent tool, and I believe this small refinement would significantly enhance the accuracy and interpretability of its statistical visualizations.

Sincerely,
[mupeker]

Image

Image

Expected Behaviour

When requesting a scatter plot for partial correlation, the graph should visually represent the relationship between the residuals of the involved variables, after controlling for the specified variable(s).

Specifically for Spearman partial correlation:
The scatter plot for the partial correlation between X and Y, controlling for Z, should display:

X-axis: The residuals of the rank of X after linearly regressing it on the rank of Z.

Y-axis: The residuals of the rank of Y after linearly regressing it on the rank of Z.

The points plotted on the graph should correspond to these residual values, and the displayed trend line should accurately reflect the relationship between these residuals. This visual representation would be consistent with the calculated partial correlation coefficient displayed alongside it.

Steps to Reproduce

Open JASP (e.g., JASP 0.19.3).
Load a dataset with at least three continuous variables (e.g., the built-in Big Five dataset or a custom dataset with continuous data).
Navigate to Analyze > Regression > Correlation > Partial Correlation.
In the Variables box, select two continuous variables (e.g., Extraversion and Neuroticism).
In the Control Variables box, select one continuous variable (e.g., Openness).
Under the Correlation Matrix options, check Spearman.
Under the Plots options, check Scatter plots.

Upon following these steps, observe the generated scatter plots in the Results window. You will see two plots: one for the simple correlation (e.g., Extraversion vs. Neuroticism) and one for the partial correlation (Extraversion vs. Neuroticism, controlling for Openness). Both plots will appear to display the same original data points/scales, even though the partial correlation plot is accompanied by a different ρ value that corresponds to the partial correlation.

Log (if any)

No response

More Debug Information

No response

Final Checklist

  • I have included a screenshot showcasing the issue, if possible.
  • I have included a JASP file (zipped) or data file that causes the crash/bug, if applicable.
  • I have accurately described the bug, and steps to reproduce it.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions