Principal Component Analysis
GX-TXT DEV112 P011-bis
Run PCA and read scores, loadings and the share of explained variance, with an example scree plot.
Prepare variables measured on the same observations
Generate a Session Standalone with Grouped Statistics Student Lab and enable Principal Component Analysis in Configuration → Modules. Open student.grouped.source in the tab Dataset and identify voltage_V and current_A. Each row identifies the same observation for all variables. The different units make the standardized comparison of the exercise meaningful.

Set data, scale and components
- In Analysis choose
student.grouped.sourceasprimary. In Numeric variables assign the two measurements. Use + Add for an additional variable and Remove to remove a row. Avoid duplicate or equivalently rescaled columns if you want to interpret distinct factors. - Leave Data selection on
Nonefor the 18 rows. The lab also providessel_001, defined on the X interval ofsample3–18. In Missing row policy,listwise_omitremoves a row if at least one selected measurement is non-finite.errorstops the run. In the exercise 16 rows remain withlistwise_omit. - Enable Subtract variable means and use
standardizein Variable scaling. The module subtracts the means and divides by the sample standard deviations. Withnonekeeps the scale of the measurements and requires compatible dimensions. If you turn off mean subtraction, the origin stays that of the variables and the result reflects the second moments about that origin. Apply this choice only if zero has the intended meaning. - For Component selection uses
countand Number of components 2. Withvariance_targetset instead a fraction between 0 and 1 in Cumulative explained-variance target. The number retained is the minimum that reaches the threshold. Reset of the field restores the initial value. - Write
pca.countin Output Dataset ID prefix and leave the three plots on. Tick Run / recalculate now, check the plan and press Run enabled analyses.

Read variance, loadings, scores and transformations
.componentscontains eigenvalue, share of variability, cumulative share, singular value and selection flag. The first component explains about 99.8632% and the second 0.1368%. The high share reflects the strong agreement between the two standardized measurements..loadingskeeps the variable weights per component. In the first component they are about 0.7071 for both. The sign of the whole eigenvector can flip together with the sign of the scores, leaving the solution unchanged..scorescontains one row per valid observation, withsource_rowto trace back to the original row. The scores are coordinates in component space..scalingshows the observed means, the factors applied and the units, useful for reconstructing the transformation of new compatible data.


To try variance_target, replace current_A with constant_V. Press + Add, assign constant_V in the new row and remove the previous current row. Set sel_001, none for the scale, centering off, threshold 0.90 and plots off. In the confirmed result the first component explains 0.92930 of the uncentered spectral share, enough to retain one component. The metric is shown as Cumulative uncentered spectral proportion.

To customize the already published scree plot, select the variant of Explained variance ratio. In Presentation → Title and labels… set Variance share per component. Save and use Render → Rerender. The title changes and the two shares published in the Dataset remain available for comparison.


In Plots open scree for the variance per component, scores for the distribution of the observations and loadings for the contribution of the variables. The variants plot.dataset allow presentation changes. For a repetition without images turn off Create scree, score and loading graphs and choose a new prefix. If you try none with V and A the module rejects the dimensional incompatibility. With the policy error the example Dataset also brings out the presence of non-finite values.