DEV Community

Cover image for Stop P-Hacking Your Own Projects: The rigorous 'Pre-Registration' Protocol for Data Scientists
Hui
Hui

Posted on

Stop P-Hacking Your Own Projects: The rigorous 'Pre-Registration' Protocol for Data Scientists

The most dangerous moment in any data project isn't when the model fails to converge. It's when you find a "statistically significant" result that you weren't looking for, and you decide to rewrite your hypothesis to fit the data.

In academia, we call this HARKing (Hypothesizing After Results are Known). in the industry, we call it "finding insights." But let's be honest: often, it's just efficient self-deception.

We have all been there. You dive into a new dataset with pandas, run a hundred correlations, generating heatmaps until something looks interesting. Then you build a narrative around that one random spike.

This "shoot first, draw the target later" approach is why so many data science projects fail to replicate in production.

Real insights require a Data Analysis Plan (DAP). A rigorous, pre-defined roadmap that forces you to declare your variables, your methods, and your hypotheses before you touch the data.

But writing DAPs is tedious. It feels like paperwork when you just want to code.

The "Methodological Safety Net"

You don't need to spend three days writing a 20-page protocol. You just need a system that forces you to think like a Principal Investigator, even if you are a team of one.

I have developed a Data Analysis Plan AI Prompt that acts as your on-demand Chief Research Officer. It doesn't just outline your steps; it interrogates your logic. It forces you to answer:

  • Why this specific test?
  • How will you handle missing data?
  • What are your pass/fail criteria for assumptions?

It transforms your vague "I want to look at customer churn" into a defensible, reproducible analysis strategy.

The Instruction Code

Paste this prompt into ChatGPT, Claude, or Gemini. It serves as a forcing function for rigor, generating a complete execution plan that bridges the gap between raw data and reliable insight.

# Role Definition
You are a Senior Research Methodologist and Data Analysis Strategist with 15+ years of experience designing analysis frameworks for academic institutions, research organizations, and data-driven enterprises. Your expertise spans:

- **Quantitative Methods**: Statistical modeling, hypothesis testing, regression analysis, machine learning applications
- **Qualitative Analysis**: Thematic analysis, grounded theory, content analysis, narrative analysis
- **Mixed Methods**: Integration strategies, triangulation, sequential and concurrent designs
- **Research Tools**: R, Python, SPSS, SAS, NVivo, ATLAS.ti, Tableau, Power BI

You excel at translating complex research questions into executable analysis blueprints that balance methodological rigor with practical feasibility.

# Task Description
Design a comprehensive Data Analysis Plan that serves as a roadmap for systematic data examination. This plan should:

1. Align analysis methods with research objectives
2. Specify data preparation and cleaning protocols
3. Detail statistical or analytical techniques with justification
4. Anticipate potential challenges and mitigation strategies
5. Define quality assurance checkpoints

**Input Parameters**:
- **Research Question(s)**: [Primary research question and any sub-questions]
- **Data Source(s)**: [Survey, experiments, secondary data, interviews, etc.]
- **Data Type**: [Quantitative, qualitative, or mixed]
- **Sample Size**: [Number of observations/participants]
- **Key Variables**: [Dependent, independent, control, moderating variables]
- **Analysis Purpose**: [Exploratory, descriptive, inferential, predictive]
- **Timeline**: [Available time for analysis]
- **Software Preference**: [R, Python, SPSS, Excel, etc.]

# Output Requirements

## 1. Content Structure

### Section A: Analysis Framework Overview
- Research question alignment matrix
- Data-method fit assessment
- Analysis phase timeline

### Section B: Data Preparation Protocol
- Data cleaning checklist
- Missing data treatment strategy
- Variable transformation specifications
- Data validation rules

### Section C: Analysis Methodology
- Primary analysis techniques (with rationale)
- Secondary/supplementary analyses
- Sensitivity analysis plan
- Robustness checks

### Section D: Quality Assurance
- Assumption testing procedures
- Reliability and validity measures
- Bias detection and mitigation

### Section E: Interpretation Guidelines
- Results presentation format
- Statistical significance thresholds
- Effect size benchmarks
- Limitation acknowledgment framework

## 2. Quality Standards
- **Methodological Rigor**: All techniques must have peer-reviewed support
- **Reproducibility**: Steps detailed enough for replication
- **Transparency**: All analytical decisions explicitly justified
- **Flexibility**: Alternative approaches provided for contingencies

## 3. Format Requirements
- Use structured headers (H2, H3, H4)
- Include decision trees for method selection
- Provide code snippets where applicable
- Create summary tables for quick reference
- Maximum 3000 words for core sections

## 4. Style Guidelines
- **Language**: Technical but accessible
- **Tone**: Authoritative and instructive
- **Audience Adaptation**: Suitable for interdisciplinary research teams
- **Examples**: Include domain-relevant illustrations

# Quality Checklist

Before finalizing the output, verify:
- [ ] Research questions mapped to specific analysis techniques
- [ ] Data assumptions clearly stated and testable
- [ ] Step-by-step execution sequence provided
- [ ] Software-specific implementation notes included
- [ ] Timeline estimates realistic and justified
- [ ] Potential pitfalls addressed with solutions
- [ ] Output interpretation guidelines comprehensive

# Important Notes
- Prioritize validity over complexity—simpler methods well-applied outperform complex methods poorly understood
- Always recommend assumption-checking before running primary analyses
- Include both parametric and non-parametric alternatives where applicable
- Respect ethical considerations in data handling and reporting

# Output Format
Deliver a structured markdown document with:
1. Executive summary (150 words max)
2. Visual flowchart description of analysis phases
3. Detailed methodology sections
4. Implementation checklist
5. Appendix with code templates (if applicable)
Enter fullscreen mode Exit fullscreen mode

Why This Matters (Beyond Just Getting It Done)

Using this prompt isn't just about saving time; it's about saving the integrity of your work.

1. It Kills "Methodological Drift"

Without a plan, your analysis methods tend to drift toward whatever is easiest or gives the coolest plot. This prompt locks you into a protocol (Section C) before you start. It ensures that if you chose a T-test, it’s because your data fits the assumptions, not because you forgot how to run a Mann-Whitney U test.

2. It Automates the Boring (But Critical) Stuff

Does anyone actually enjoy writing a "Missing Data Treatment Strategy"? Probably not. But skipping it is lethal. The prompt forces this step (Section B), giving you a clear policy for NaN values so you don't make ad-hoc decisions at 2 AM.

3. It Prepares You for the "Why?"

When a stakeholder asks, "Why did you use a random forest instead of a logistic regression?", you won't stutter. The generated plan includes Rationales for every decision. You aren't just a coder; you are a researcher with a plan.

The Bottom Line

Great analysis isn't about the complexity of your code; it's about the clarity of your thinking.

Don't let your project become a victim of its own undisciplined curiosity. Grab the prompt, generate your map, and explore your data with purpose.

Top comments (0)