Synthetic data

From flonat/flonat-research · View interactive version

Synthetic data is an AI agent skill from the GitHub repository flonat/flonat-research. Generate structurally realistic synthetic datasets for pipeline prototyping, test coverage, or prospective power analysis. Use when code or design must be exercised before real data are available or accessible. Never substitute synthetic records for governed raw data.

How to use this skill

Skill file

Synthetic Data Generation

Generate structurally realistic synthetic datasets for pilot testing, power analysis, and method development.

Modes

| Mode | What it produces | Entry point |

|------|-----------------|-------------|

| From design | Synthetic data matching an existing experiment design document | "Generate test data for my experiment" |

| From schema | Synthetic data from a user-described structure | "Create a dataset with these variables" |

| Calibrated | Synthetic data calibrated to published summary statistics | "Make fake data matching these descriptives" |

Default: From schema. If an experiment design document exists in docs/, auto-select From design. If user provides published statistics, auto-select Calibrated.

When to Use

When NOT to Use


Workflow

Step 1: Detect Mode

Detect from context or ask:

| Signal | Mode |

|--------|------|

| docs/experiment-design.md exists | From design |

| User describes variables, types, relationships | From schema |

| User provides means, SDs, correlations from a paper | Calibrated |

| Ambiguous | Ask |

Step 2: Interview for Data Structure

Gather the following (adapt questions to mode):

| Parameter | Question | Default |

|-----------|----------|---------|

| Variables | What variables do you need? | — |

| Types | Continuous, binary, ordinal, categorical? | Infer from name |

| Sample size | How many observations? | 500 |

| Treatment | Is there a treatment variable? How many arms? | — |

| Effect size | Expected treatment effect (Cohen's d, OR, etc.)? | 0.3 (small-medium) |

| Correlations | Which variables should be correlated? How strongly? | — |

| Clustering | Are observations nested (e.g., students in classrooms)? | No |

| Panel structure | Multiple time periods? How many? | Cross-section |

| Missing data | Should the data include realistic missingness? | No |

| Language | R or Python? | Detect from project or ask |

For From design mode, extract most parameters from the design document automatically and confirm with the user.

For Calibrated mode, require the user to provide published summary statistics. Read references/calibration-targets.md for the calibration procedure.

Step 3: Generate Script

Read references/dgp-recipes.md for code patterns matching the requested design.

Read shared/multi-language-conventions.md for language-specific code style.

Generate a self-contained script that:

  1. Sets a random seed (document the seed value)
  2. Defines the data generating process with clear comments
  3. Generates the dataset
  4. Adds realistic noise and distributional features
  5. Introduces missing data patterns if requested
  6. Saves the dataset as CSV (and optionally .rds/.parquet)
  7. Prints a summary of the generated data

Step 4: Execute

For large Monte Carlo sweeps (10k+ simulations, multi-condition grids, or long-running bootstrap): run on [HPC cluster] instead of locally. Drop the generation script into hpc/ with submit.sbatch (compute partition) or sweep.sbatch (array over seeds/conditions) — templates at Task Management templates/slurm/, guide at docs/guides/hpc.md. All SLURM templates log git-sha.txt to OUT_DIR so synthetic datasets remain traceable to the DGP code version.

Run the script and verify:

Step 5: Save Output

Output routing:

| File | Location |

|------|----------|

| Generated dataset | data/synthetic/{name}.csv |

| Generation script | code/generate_synthetic_{name}.R (or .py) |

| Data dictionary | data/synthetic/{name}_dictionary.md |

NEVER write to data/raw/. The data-sensitivity rule applies -- synthetic data is not raw data and must be clearly separated.

Create data/synthetic/ if it does not exist.

Step 6: Data Dictionary

Produce a markdown data dictionary alongside the dataset:

# Data Dictionary: {name}

Generated: {date}
Script: `code/generate_synthetic_{name}.R`
Seed: {seed}
N: {sample_size}

| Variable | Type | Description | Distribution | Parameters |
|----------|------|-------------|-------------- |------------|
| id | integer | Unique identifier | Sequential | 1 to N |
| treatment | binary | Treatment assignment | Bernoulli | p = 0.5 |
| outcome | continuous | Primary outcome | Normal | mu = 0, sigma = 1 (control) |
| ... | ... | ... | ... | ... |

## Treatment Effects
- True ATE: {value}
- True CATE by subgroup: {if applicable}

## Missing Data
- Mechanism: {MCAR/MAR/MNAR}
- Rate: {percentage} of {variable}

Key Principles

Reproducibility

Realism

Missing Data

Calibration (Calibrated Mode)


Mode: From Design

Workflow

  1. Locate design document -- check docs/experiment-design.md, docs/pre-analysis-plan.md, log/plans/
  2. Extract parameters:
  1. Confirm with user -- present extracted parameters and ask for adjustments
  2. Generate -- follow Steps 3-6 above

Integration with `experiment-design`

The design document produced by experiment-design Design mode contains everything needed:


Mode: From Schema

Workflow

  1. Interview -- ask user to describe each variable (or provide a sketch)
  2. Infer structure -- detect relationships from the description:
  1. Generate -- follow Steps 3-6 above

Common Requests

| User says | Interpret as |

|-----------|-------------|

| "A standard survey dataset" | Demographics + Likert DVs + treatment + attention checks |

| "Panel data" | Units x time with unit and time fixed effects |

| "Something like [paper name]" | Switch to Calibrated mode, use paper's descriptives |


Mode: Calibrated

Workflow

  1. Collect targets -- user provides published summary statistics:
  1. Read references/calibration-targets.md for the calibration procedure
  2. Generate with matching -- use the Cholesky decomposition or copula method to match the target correlation structure
  3. Validate -- compare synthetic descriptives to targets, report match quality
  4. Save -- follow Steps 5-6 above, include calibration targets in the data dictionary

Cross-References

| Resource | When read |

|----------|-----------|

| references/dgp-recipes.md | All modes (code patterns for each design type) |

| references/calibration-targets.md | Calibrated mode (matching procedure) |

| shared/multi-language-conventions.md | All modes (code style) |

| experiment-design skill | From design mode (reads its design documents) |

| data-analysis skill | Consumes synthetic data for pipeline testing |

| data-sensitivity rule | Never write to data/raw/ |

| design-before-results rule | Synthetic data supports locking the design before real data |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.