> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Variance Reduction

> Use pre-exposure data in the Stats API to reduce variance and increase experiment precision.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Configure Variance Reduction"
  description="Use pre-exposure data in the Stats API to reduce variance and increase experiment precision."
  steps={[
{
  name: "How It Works",
  text: "The Stats API applies regression adjustment to reduce variance. You provide pre-exposure measurements alongside your post-exposure data, and the API uses the correlation between them to produce more precise estimates.",
},
{
  name: "Configure Variance Reduction for Analysis",
  text: "Include pre-exposure data in the adjustment field within your summary data: The adjustment object contains: | Field | Description |",
},
{
  name: "Configure Variance Reduction for Power Analysis",
  text: "For power analysis, include the expected covariance adjustment in your power data: | Field | Description | |-------|-------------|",
},
{
  name: "Interpret Results",
  text: "The API returns both adjusted and unadjusted estimates. The treatment effect estimate benefits from the reduced variance, providing tighter confidence intervals. The response includes a varianceReductionRate field showing the achieved reduction.",
},
]}
/>

Variance reduction uses pre-exposure data to reduce noise in your experiment metrics. This allows you to detect effects with fewer samples or detect smaller effects with the same sample size.

## How It Works

The Stats API applies regression adjustment to reduce variance. You provide pre-exposure measurements alongside your post-exposure data, and the API uses the correlation between them to produce more precise estimates.

## Configure Variance Reduction for Analysis

Include pre-exposure data in the `adjustment` field within your summary data:

```json theme={null}
{
  "id": "my-metric",
  "segments": [
    {
      "dimensions": {},
      "groups": [
        {
          "group": "control",
          "data": {
            "zTest": {
              "summary": {
                "mean": 10.5,
                "variance": 25.0,
                "count": 1000,
                "adjustment": {
                  "mean": 9.8,
                  "variance": 22.0,
                  "covariance": 15.2
                }
              }
            }
          }
        },
        {
          "group": "treatment",
          "data": {
            "zTest": {
              "summary": {
                "mean": 11.2,
                "variance": 26.0,
                "count": 1000,
                "adjustment": {
                  "mean": 9.9,
                  "variance": 21.5,
                  "covariance": 14.8
                }
              }
            }
          }
        }
      ]
    }
  ]
}
```

### Adjustment Fields

The `adjustment` object contains:

| Field        | Description                                              |
| ------------ | -------------------------------------------------------- |
| `mean`       | Mean of the pre-exposure measurements                    |
| `variance`   | Variance of the pre-exposure measurements                |
| `covariance` | Covariance between pre-exposure and post-exposure values |

## Configure Variance Reduction for Power Analysis

For power analysis, include the expected covariance adjustment in your power data:

```json theme={null}
{
  "hypotheses": [
    {
      "id": "my-metric",
      "segments": [
        {
          "dimensions": {},
          "powerData": {
            "zTest": {
              "baselineMean": 10.0,
              "baselineVariance": 25.0,
              "adjustment": {
                "baselineVariance": 22.0,
                "baselineCovariance": 15.0
              }
            }
          }
        }
      ]
    }
  ]
}
```

### Power Analysis Adjustment Fields

| Field                | Description                                                   |
| -------------------- | ------------------------------------------------------------- |
| `baselineVariance`   | Variance of the pre-exposure covariate                        |
| `baselineCovariance` | Covariance between the pre-exposure covariate and the outcome |

## Interpret Results

The API returns both adjusted and unadjusted estimates. The treatment effect estimate benefits from the reduced variance, providing tighter confidence intervals. The response includes a `varianceReductionRate` field showing the achieved reduction.

## Related Resources

<CardGroup cols={2}>
  <Card title="Variance Reduction" href="/docs/experiments/stats/variance-reduction">
    Learn about variance reduction concepts
  </Card>

  <Card title="Run an Analysis" href="/docs/api/how-to-guides/stats/run-analysis">
    Complete analysis tutorial
  </Card>

  <Card title="Run Power Analysis" href="/docs/api/how-to-guides/stats/run-power-analysis">
    Calculate required sample sizes
  </Card>
</CardGroup>
