# 051. Random-variable negative controls

**Question:** How do source-supplied random controls compare with measured variables in an association screen?

## Result

The largest computed metric is 0.3024 for lights; the smallest is -0.009289 for rv2. Metric: spearman_rho (Spearman correlation).

rv1 and rv2 are explicitly source-generated random controls, not physical measurements. The remaining energy and sensor observations are real.

![Random-variable negative controls](outputs/chart.png)

| feature | spearman_rho | absolute_rho | paired_rows |
| --- | --- | --- | --- |
| lights | 0.3024 | 0.3024 | 19735 |
| t1 | 0.244 | 0.244 | 19735 |
| t_out | 0.2155 | 0.2155 | 19735 |
| rh_1 | 0.06052 | 0.06052 | 19735 |
| rv2 | -0.009289 | 0.009289 | 19735 |
| rv1 | -0.009289 | 0.009289 | 19735 |

The chart shows 6 of 6 result rows; the table previews the first 6 in the analysis-defined order. [Download the full result table](outputs/results.csv). Numerical values are computed from the source; missing results stay unavailable.

## Method

Rank correlations for declared controls and selected real measurements; audit control duplication.

The study uses shared source preparation and reusable statistical routines. Its specific transformations are in [analysis.py](analysis.py), and common model/evaluation code is in [portfolio/methods.py](../../portfolio/methods.py). The [notebook](analysis.ipynb) executes the study and displays the saved results.

## Decision and limitations

Use negative controls to question apparent signals before selecting features.

Measurements come from one home over a limited period. Energy is Wh per recorded 10-minute interval. This is not a representative household sample; tariffs and occupancy labels are unavailable. 

Related studies may share observations or holdouts. These are focused analytical studies, not independent replications or deployed business systems. Any model refinements informed by these results need new untouched evaluation data. No commercial impact is inferred from an association or backtest.

## Reproduce

From the repository root, after installing `requirements.txt`:

```powershell
python projects/051-random-variable-negative-controls/analysis.py
```

Source data are downloaded automatically if absent. Original archives are retained unchanged and checked by SHA-256. The cleaned cache normalizes column names; field-specific changes are visible in [data preparation](../../portfolio/data.py). Runtime evidence is in [receipt.json](outputs/receipt.json).

## Source

[Appliances Energy Prediction](https://archive.ics.uci.edu/dataset/374/appliances+energy+prediction), Candanedo (2017). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/energy.json) and [prepared-data audit](../../data/provenance/energy_prepared.json) record the downloaded files, field coverage and hashes.
