# Principal component analysis (/docs/analyses/pca)



## When to use it [#when-to-use-it]

Use PCA when you have several correlated scores and want a few components that keep as much of the variance as possible. It is a compression of the variables, not a test that a particular factor model is true. For a stated factor model, use [confirmatory factor analysis](/docs/analyses/confirmatory-factor-analysis).

## Assumptions [#assumptions]

Variables are numeric. Tensr standardizes them first, so the analysis is on the correlation matrix, not the covariance matrix. Rows with any missing value are dropped. There is no KMO or Bartlett test on this request.

## Running it in Tensr [#running-it-in-tensr]

<Steps>
  <Step>
    Analyze → Dimension Reduction → PCA. In chat: “PCA of these six items, two components.”
  </Step>

  <Step>
    Select at least two columns. Leave components empty to keep every component that fits, or set a number from 1 to 50.
  </Step>
</Steps>

## Options [#options]

<TypeTable
  type="{
  columns: {
    type: 'string[]',
    description: 'Variables to compress. At least two.',
  },
  n_components: {
    type: 'integer',
    description: 'How many components to keep. Empty means as many as the data allow, up to the number of variables.',
    default: 'null',
  },
  decimal_places: {
    type: '0–6',
    description: 'Report output. Decimal places.',
    default: '3',
  },
  apa_format: {
    type: 'boolean',
    description: 'Report output. APA-style p-values.',
    default: 'true',
  },
  include_charts: {
    type: 'boolean',
    description: 'Report output. Shared chart switch.',
    default: 'true',
  },
}"
/>

The wizard may send an empty string for the component count. That has to become null before it reaches the API. A blank field means “let the server decide.”

## Reading the output [#reading-the-output]

Six items from that same scale. The first component should take a clear share and leave a real second component.

| Component | Eigenvalue | Variance % | Cumulative % |
| --------- | ---------: | ---------: | -----------: |
| PC1       |      2.286 |    37.782% |      37.782% |
| PC2       |      1.024 |    16.923% |      54.705% |

| Variable |   PC1 |    PC2 |
| -------- | ----: | -----: |
| item1    | 0.378 | -0.316 |
| item2    | 0.426 | -0.429 |
| item3    | 0.448 |  -0.32 |
| item4    | 0.449 |  0.231 |
| item5    | 0.414 |  0.291 |
| item6    | 0.321 |   0.69 |

PCA on 6 variables, n = 120. PCA on 6 variables, n = 120. Metrics: Components = 2; PC1 variance = 37.782%.

## Reporting (APA 7) [#reporting-apa-7]

PCA on 6 variables, n = 120. Report the estimate in the table. This procedure is not summarised by one p-value.

## Coming from SPSS [#coming-from-spss]

Analyze → Dimension Reduction → Factor, Extraction: Principal components. SPSS can also print KMO and Bartlett’s test. This request does not.
