# Variable Charts Overview

### What Are Variable Charts?

Variable Charts in MixModeler allow you to visualize your data with interactive charts to explore patterns, trends, and relationships between variables before and during model building.

**Purpose:** Explore data visually to understand trends, relationships, and patterns that inform model specification and validate assumptions.

### Why Use Variable Charts?

**Data Exploration:**

* Understand time trends before modeling
* Identify relationships between variables
* Detect seasonality and patterns
* Spot outliers and data quality issues

**Model Validation:**

* Verify expected relationships exist
* Check for multicollinearity visually
* Compare raw vs. transformed variables
* Validate model assumptions

**Communication:**

* Create publication-ready visualizations
* Share insights with stakeholders
* Support data-driven discussions
* Illustrate key findings

### Accessing Variable Charts

**Navigation:**

1. Click "Variable Charts" in the left sidebar (under Data Management)
2. Select your model from the dropdown
3. Choose variables to visualize
4. Select chart type
5. Generate chart

**Prerequisites:**

* Data must be uploaded
* At least one model created (to access variables)
* Variables available for charting

### Available Chart Types

MixModeler provides five chart types for different analytical needs:

| Chart Type             | Best For                                       | Variables Needed    |
| ---------------------- | ---------------------------------------------- | ------------------- |
| **Line Chart**         | Time trends, temporal patterns                 | 1+ variables        |
| **Scatter Plot**       | Relationships between two variables            | Exactly 2 variables |
| **Bar Chart**          | Period comparisons, discrete data              | 1+ variables        |
| **Stacked Chart**      | Part-to-whole relationships, mix analysis      | 2+ variables        |
| **Correlation Matrix** | Multi-variable correlations, multicollinearity | 2+ variables        |

### Typical Workflow

**Step-by-Step Process:**

1. **Start with Line Charts**
   * Understand individual variable trends over time
   * Identify seasonality and patterns
   * Check for outliers
2. **Use Scatter Plots**
   * Explore relationships (e.g., Spend vs. KPI)
   * Validate expected correlations
   * Detect non-linear patterns
3. **Check Correlation Matrix**
   * Identify multicollinearity before modeling
   * Find redundant variables
   * Understand variable relationships
4. **Compare Transformations**
   * View raw vs. transformed variables
   * Validate transformation effects
   * Ensure transformations make sense
5. **Use Stacked Charts**
   * Analyze media mix over time
   * Understand budget allocation
   * See proportional changes

### Chart Interface Layout

**Left Panel - Variable Selection:**

* Model dropdown
* Variable search box
* Variable checkboxes with info
* Chart type buttons
* Options (dual axis, KPI inclusion)
* Generate Chart button

**Right Panel - Chart Display:**

* Title editor (customizable)
* Interactive chart
* Zoom/pan controls
* Legend
* Tooltip on hover

### Variable Selection

**Search Functionality:**

* Type to filter variables by name
* Makes finding variables easier
* Works across all variable types

**Select All:**

* Quickly select all filtered variables
* Uncheck to deselect all
* Saves time with many variables

**Individual Selection:**

* Check/uncheck specific variables
* See variable details:
  * Type (KPI, Feature, etc.)
  * Transformation applied
  * Group assignment (if set)

**Variable Limit:**

* Line charts: 2-8 variables recommended
* Scatter plots: Exactly 2 required
* Correlation: 2+ variables
* Stacked charts: 2+ variables

### Key Features

#### Dual Y-Axis Support

**When to Use:**

* Comparing variables with very different scales
* Example: Spend ($1000s) vs. Percentage (0-100)
* Prevents one variable from being flattened

**How It Works:**

* First half of variables use left Y-axis
* Second half use right Y-axis
* Each axis scales independently

#### Include KPI Option

**Purpose:**

* Add KPI variable to any chart
* See relationships with target variable
* Validate expected correlations

**Use Case:**

* Check if marketing spend correlates with KPI
* Verify timing of impacts
* Identify leading/lagging relationships

#### Transformed vs. Raw Variables

**Toggle Option:**

* View transformed variables (adstock, curves, etc.)
* Compare transformation effects
* Validate transformations make sense

**Note:** Transformed variables are created in Variable Workshop and Model Builder

#### Customizable Chart Title

**Edit Inline:**

* Click in title box to edit
* Descriptive titles for exports
* Professional presentation

### Interactive Features

**All charts include:**

**Zoom:**

* Mouse wheel zoom
* Selection box zoom (click and drag)
* Zoom in/out buttons in toolbar

**Pan:**

* Drag to move around when zoomed
* Navigate across time or data range

**Tooltip:**

* Hover over data points for exact values
* Shows date, variable name, value
* Multiple series shown together

**Legend:**

* Click to show/hide individual series
* Isolate specific variables
* Compare subsets

**Toolbar:**

* Top right corner
* Zoom controls
* Pan toggle
* Reset to original view

### Common Use Cases

#### Pre-Model Exploration

**Before building a model:**

1. Plot all potential variables as line charts
2. Identify which show clear trends
3. Check scatter plots for expected relationships
4. Use correlation matrix to find redundant variables
5. Remove or combine highly correlated variables

#### Model Validation

**After fitting a model:**

1. Compare predicted vs. actual (line chart)
2. Check residuals over time
3. Validate relationships still hold
4. Confirm no obvious patterns missed

#### Transformation Verification

**When applying transformations:**

1. Plot raw variable
2. Toggle to show transformed
3. Verify transformation achieves desired effect
4. Check for unintended consequences

#### Budget Mix Analysis

**Understanding spend allocation:**

1. Use stacked chart with all spend variables
2. See proportions over time
3. Identify shifts in mix
4. Inform budget allocation decisions

#### Multicollinearity Check

**Before finalizing model:**

1. Run correlation matrix on all planned variables
2. Identify correlations > 0.8
3. Decide which variables to keep/remove
4. Reduce VIF issues before modeling

### Best Practices

**Start Simple:**

* Begin with one or two variables
* Understand individual patterns
* Then add complexity

**Use Appropriate Chart Types:**

* Time data → Line charts
* Relationships → Scatter plots
* Comparisons → Bar charts
* Mix/composition → Stacked charts
* Correlations → Matrix

**Limit Variables Per Chart:**

* Too many variables = cluttered
* 2-5 variables ideal for most charts
* Use multiple charts if needed

**Customize Titles:**

* Descriptive titles help later
* Include date ranges if relevant
* Professional for exports

**Leverage Interactivity:**

* Zoom into specific periods
* Hide/show variables via legend
* Use tooltips for exact values

**Save Insights:**

* Screenshot important charts
* Export for presentations
* Document findings

### Tips for Success

**Efficient Selection:**

* Use search to filter variables
* Select All then uncheck unwanted
* Saves time with many variables

**Compare Scales:**

* Use dual axis when scales differ greatly
* Prevents visual distortion
* Makes both variables visible

**Check Correlations:**

* Always run correlation matrix before modeling
* Identifies multicollinearity early
* Saves time in model building

**Include KPI:**

* Add KPI to see target relationships
* Validates variable usefulness
* Identifies timing of effects

**Iterate:**

* Charts inform next questions
* Explore, discover, repeat
* Build understanding gradually

### Next Steps

After exploring with Variable Charts:

* Proceed to **Chart Types** to learn about each chart in detail
* Review **Interactive Features** for advanced usage
* Learn about **Export & Sharing** to use charts in presentations
* Apply insights in **Variable Engineering** and **Model Building**
