# Variable Workshop Overview

### Creating and Transforming Variables for Better Models

The Variable Workshop is your central hub for engineering new variables from your raw data. This powerful feature lets you create transformations that capture real-world marketing behaviors like carryover effects, diminishing returns, and time-shifted impacts—all without writing code.

***

### What is Variable Engineering?

#### Beyond Raw Data

**Raw marketing data often needs transformation to capture:**

* **Carryover effects:** TV ads continue influencing sales for weeks
* **Diminishing returns:** First $10K has more impact than next $10K
* **Time delays:** Marketing in Week 1 affects sales in Week 2-3
* **Interaction effects:** TV + Digital together more effective than sum of each
* **Seasonal adjustments:** Normalize for time-of-year patterns

**Variable Workshop creates these transformations automatically.**

***

### Why Transform Variables?

#### Problem: Linear Models Miss Reality

**If you model raw spend:**

```
Sales = β₀ + β₁ × TV_Spend
```

**You're assuming:** ❌ Impact is immediate (no carryover) ❌ Returns are constant (no saturation) ❌ Each dollar has same effect (linear)

**Reality:** ✅ Impact persists over time ✅ Returns diminish with more spend ✅ Relationship is non-linear

***

#### Solution: Transformed Variables

**With transformations:**

```
Sales = β₀ + β₁ × f(TV_Spend_adstocked_saturated)
```

**Now capturing:** ✅ Carryover effects (adstock) ✅ Diminishing returns (saturation) ✅ Realistic marketing response

**Result:** More accurate attribution, better ROI estimates, actionable insights

***

### Variable Workshop Interface

#### Three Main Sections

**1. Available Variables (Left Panel)**

* All variables from your uploaded data
* Previously created transformations
* Search and filter functionality

**2. Transformation Builder (Center Panel)**

* Select transformation type
* Configure parameters
* Preview transformation effect
* Name new variable

**3. Variable Library (Right Panel)**

* All created variables
* Edit or delete transformations
* Add directly to models
* Export list

***

### Transformation Types Available

#### Time-Based Transformations

**Lead/Lag Transformations** Shift variables forward or backward in time

* **Use case:** Model delayed effects
* **Example:** `TV_Spend_lag1` (last week's TV spend)

**Split by Date** Create separate variables for different time periods

* **Use case:** Isolate campaign periods or seasonal changes
* **Example:** `TV_Spend_Q4_Only`

***

#### Mathematical Transformations

**Multiply Variables** Combine two variables into one

* **Use case:** Create interaction terms
* **Example:** `TV_x_Digital` (synergy effect)

**Weighted Variables (WGTD)** Apply custom weights to variable values

* **Use case:** Emphasize certain periods or adjust for inflation
* **Example:** `Sales_Weighted`

***

#### Marketing-Specific Transformations

**Adstock (Carryover Effects)** Model how marketing impact decays over time

* **Use case:** Capture lasting effects of TV, Radio, Print
* **Example:** `TV_Spend_ads60` (60% carryover rate)

**Saturation Curves** Model diminishing returns using S-shape or concave curves

* **Use case:** Realistic ROI at different spend levels
* **Example:** `TV_Spend_ATAN_curve`

***

#### Statistical Transformations

**AVO (Average Value Optimization)** Smooth volatile data using moving averages

* **Use case:** Reduce noise in erratic variables
* **Example:** `Sales_AVO_4week`

**Standardization (STA)** Scale variables to mean=0, std=1

* **Use case:** Compare effect sizes across different units
* **Example:** `TV_Spend_Standardized`

***

### Basic Workflow

#### Step 1: Select Base Variable

Choose the variable you want to transform from your uploaded data

#### Step 2: Choose Transformation Type

Pick from the transformation menu (Lead/Lag, Adstock, Saturation, etc.)

#### Step 3: Configure Parameters

Set transformation settings:

* Lag periods (1, 2, 3 weeks)
* Adstock rate (30%, 50%, 70%)
* Curve parameters (alpha, beta, gamma)

#### Step 4: Preview Transformation

Interactive chart shows:

* Original variable (before)
* Transformed variable (after)
* Side-by-side comparison

#### Step 5: Create Variable

Click "Create" - new variable added to your library

#### Step 6: Use in Models

Add transformed variable to your models in Model Builder

***

### Preview and Testing

#### Interactive Preview

**Before creating a variable, see:**

**Visual Comparison:**

* Line chart: Original vs. Transformed values
* Scatter plot: Transformation function shape
* Statistics: Mean, range, variance changes

**Example Preview:**

```
Original TV_Spend: Mean = $18,500
Adstocked (60%):   Mean = $27,300 (accumulated effect)

Chart shows: Smoother line with peak values extended
```

***

#### Test Before Committing

**Preview lets you:**

* Experiment with different parameters
* See immediate visual feedback
* Understand transformation impact
* Avoid creating unusable variables

**Iterate until satisfied, then create**

***

### Combining Transformations

#### Chained Transformations

**You can apply multiple transformations sequentially:**

**Example: TV with Adstock AND Saturation**

1. Start: `TV_Spend` (raw)
2. Apply adstock: `TV_Spend_ads60`
3. Apply saturation: `TV_Spend_ads60_ATAN`

**Order matters:**

* Usually: Adstock FIRST, then Saturation
* Captures: Marketing accumulates over time, then saturates

***

#### Creating Complex Variables

**Interaction Terms:**

1. Create adstocked TV: `TV_ads60`
2. Create adstocked Digital: `Digital_ads40`
3. Multiply them: `TV_ads60_x_Digital_ads40`

**Result:** Captures synergy between channels with proper carryover

***

### Best Practices

#### Start Simple

**Build Complexity Gradually:**

1. First: Use raw variables in OLS model (baseline)
2. Then: Add adstock to media channels
3. Next: Apply saturation curves
4. Finally: Test interaction terms if needed

**Don't over-engineer initially**

***

#### Name Variables Clearly

**Good Naming Convention:**

```
{Base}_{Transformation}_{Parameter}

Examples:
TV_Spend_ads60
Digital_Display_lag2
Radio_ATAN_a15_p12
Sales_AVO_4week
```

**Benefits:**

* Easy to identify transformations
* Understand at a glance
* Avoid confusion

***

#### Document Your Transformations

**Keep Track:**

* Why transformation was applied
* Parameter choices and rationale
* Which models use which transformations

**Use Variable Notes:** Each created variable has optional notes field - use it!

***

#### Test Impact on Model

**After creating transformation:**

1. Add to model in Model Builder
2. Check coefficient significance (t-stat)
3. Compare R² with/without transformation
4. Verify makes business sense

**If transformation doesn't improve model, don't use it**

***

### Variable Management

#### Editing Variables

**Modify existing transformations:**

* Click variable in library
* Adjust parameters
* Preview changes
* Update (replaces in all models using it)

***

#### Deleting Variables

**Remove unused transformations:**

* Right-click variable → Delete
* Confirmation dialog (can't undo)
* Models using it will show warning

**Best Practice:** Export models before deleting variables

***

#### Exporting Variable List

**Download Documentation:**

* All created variables
* Transformation types
* Parameters used
* Creation dates

**Format:** Excel or CSV

**Use Case:** Documentation, sharing with team, reproducibility

***

### Common Use Cases

#### Use Case 1: TV Campaign with Carryover

**Scenario:** TV ads continue influencing sales for 4-6 weeks

**Solution:**

1. Create `TV_Spend_ads60` (60% carryover)
2. Test in model
3. Compare with raw TV spend
4. Use adstocked version (higher significance)

***

#### Use Case 2: Digital Diminishing Returns

**Scenario:** First $5K in digital has high ROI, next $5K less effective

**Solution:**

1. Create `Digital_ATAN_concave` saturation curve
2. Test parameters in Curve Testing
3. Use saturated variable in model
4. Calculate ROI at different spend levels

***

#### Use Case 3: Seasonal Campaign Isolation

**Scenario:** Holiday campaign Q4 only, want to measure separately

**Solution:**

1. Create `TV_Spend_Q4_Only` (Split by Date)
2. Use in model alongside `TV_Spend_NonQ4`
3. Compare coefficients
4. Understand seasonal vs. baseline effectiveness

***

#### Use Case 4: Lagged Price Effect

**Scenario:** Price changes take 2 weeks to affect sales

**Solution:**

1. Create `Price_lag2` (2-week lag)
2. Test in model
3. If significant, use instead of current price
4. Better captures actual price-sales relationship

***

### Advanced Features

#### Batch Creation

**Create multiple transformations at once:**

* Select multiple base variables
* Apply same transformation type
* Configure once, create all

**Example:** Transform all media channels with 50% adstock in one step

***

#### Template Library

**Save transformation configurations:**

* Store commonly used parameter sets
* Apply to new variables quickly
* Ensure consistency across models

**Example Template:** "Standard Media Adstock" = 60% rate, applied to TV/Radio/Print

***

#### Variable Dependencies

**Track relationships:**

* See which variables are based on others
* Understand transformation chains
* Avoid circular dependencies

**Visual Dependency Graph** (coming soon)

***

### Summary

**Key Takeaways:**

🛠️ **Variable Workshop = Transformation Hub** - create all variable engineering here

📊 **Multiple transformation types** - time-based, mathematical, marketing-specific

👁️ **Preview before creating** - see transformations visually before committing

🔗 **Combine transformations** - adstock + saturation for realistic models

📝 **Clear naming** - use descriptive names with transformation details

✅ **Test in models** - verify transformations improve fit and make sense

🎯 **Start simple, add complexity** - don't over-engineer initially

**Next Steps:** Explore each transformation type in detail in the following pages!
