Skip to content

[Bug]: PC scores added on wrong row if data have pass-through filters #2972

@MCube78

Description

@MCube78

JASP Version

0.19.1

Commit ID

No response

JASP Module

Factor

What analysis are you seeing the problem on?

PCA

What OS are you seeing the problem on?

Windows 10

Bug Description

When performing a PCA and selecting "add PC scores to data", the scores are inserted correctly if no observations are filtered out. However, if any observations in the data are filtered out, then data in the PC score columns will be added incorrectly. Specifically, if you filter out F observations, the software is clever enough to know it needs to generate N-F scores, but then when adding the PC score column in the data it doesn't skip the filtered out rows (which means the score are translated by F rows).

This is easy to see in the following figures:

FIGURE 1: 29 Observations, Filtered: 0; all PC scores added correctly
image

FIGURE 2: 29 Observations, Filtered: 1 (1st row); scores added incorrectly (i.e., PC score was added to the filtered observation, which should have none, and missing in the last row). In short, all scores are added to the wrong row, by 1 position.
image

FIGURE 3: 29 Observations, Filtered: 2 (1st and 2nd rows); scores added incorrectly (i.e., PC score was added to the filtered observation, which should have none, and missing in the last row). In short, all scores are added to the wrong row, by 2 positions.
image

Of course, the same is true if you filter out rows from the middle of the data. From the first filtered out observation down, all the scores are offset.

So of course, if then you use those scores to do any additional analysis, the result will be incorrect (since each score is in the wrong row).

I hope I was able to explain clearly enough, should be easy to reproduce. Let me know what you think

Cheers

Martin

Expected Behaviour

When inserting the PC score column(s) it should skip any filtered-out row.

Steps to Reproduce

  1. Perform a PCA on full dataset, selecting "add PC scores to data"
  2. Apply a pass-through filter which filters out one or more observations
  3. Look at the data again, you should see as many empty cells, per each PC, as filtered out observations (refreshing or re-running the PCA does not change the behavior)
    ...

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions