Covariance and Correlation
GX-TXT DEV112 P011-bis
Estimate covariance and correlation between variables and interpret the values given in the result matrices.
Prepare several measurements on the same rows
Create a Session Standalone with Session → New Session → Generate Session → Grouped Statistics Student Lab. Enable Covariance and Correlation from Configuration → Modules. The Dataset student.grouped.source contains 18 rows and measures both the voltage, in V and in mV, and the current in A. In Dataset → Canonical table check the column names and verify that the measurements in each row belong to the same observation.

Choose variables, interval and rows to exclude
- In Analysis → Covariance and Correlation set
student.grouped.sourceas primary. In Variables selectvoltage_Vandcurrent_A. Press + Add to addvoltage_mV. Remove removes the corresponding variable from the list. - In Data selection uses
Nonefor all rows. To limit yourself to the lab window choosesel_001, defined on the axissamplefrom 3 to 18. The repetition with only the columnsvoltage_Vandcurrent_ArecordedSelection: sel_001in the report. - Set Missing-pair policy on
pairwiseand NaN / Inf policy onomit. The first uses the valid rows for each single pair.listwiserequires finite values in all the listed variables and uses the same rows for all pairs. Witherrorthe module rejects the presence of NaN or Inf after the selection. - Set Pairwise results Dataset ID on
covarianza.pairwise, leave on Create correlation heatmap and tick Run / recalculate now. In Run update the plan, then press Run enabled analyses. For the comparison repeat withlistwise, IDcovarianza.listwiseand the map off.

Read covariance, Pearson and Spearman
Open the resulting Dataset from Results or from Dataset. Three variables produce nine rows, including the diagonal and the pairs in both orders. Check n_input, n_valid and n_excluded before comparing two coefficients. The sample covariance divides the sum of the products of the deviations by n−1, the population covariance by n. The units are the product of the two source units. Pearson measures the standardized linear relationship. Spearman applies the correlation to the ranks and measures monotonic association. Both are dimensionless and require useful variability. Check the status fields when a series is constant or the data are insufficient.
In the run with pairwise the V/A pair uses 16 of 18 rows, has a sample covariance of 0.417070833 V·A, Pearson 0.997264 and Spearman 0.998528. The voltage expressed in V and in mV uses 17 rows and gives Pearson 1 within numerical rounding. The value comes from the scale conversion of the same measurement. With listwise all elements use 16 rows. With more variables, pairwise exclusion can build coefficients from different samples. A high association alone does not identify a causal relationship.

Open the map and rename the variant
In Plots search for correlation_heatmap for the module plot and its variant plot.dataset for persistent presentation changes. The map shows Pearson between the variables in the same order on both axes. Choose the variant, use Presentation → Title and labels…, save the title and use Render → Rerender. Open the figure with Graph → Open PNG 1:1. Check the plot just produced by matching its title and source to the run: an existing figure may come from a previous run with the option on.


