AI for Coding & Analysis¶
AI-assisted code for research is acceptable only when you can explain, test, and maintain it. This means that you need to understand the language the code is written in, review package documentation and understand the default assumptions and methods, and validate any code written by AI.
- Acknowledge that the act of coding is separate than applying a method for analysis. AI may assist in writing code or proposing methods that may be suitable for your research question, but it is up to you to make the methodological choices, understand the code and assumptions behind it, and defend why it is appropriate!
- Do not expose restricted code, data, keys, or internal infrastructure details to AI (See more in research-data).
- Review dependencies, usage licences, security implications, and edge cases.
- Test and validate code against known results and inspect failures. Develop tests for positive and negative examples (successes and failures).
- Independently validate statistical methods, assumptions, and interpretations.
- Review every line of AI-generated or substantially modified code before it contributes to a manuscript or report.
- Do not accept AI interpretation of results without independent verification.
- Use AI to add unit tests, documentation, reproducible environments, and clearer project organisation.
- Preserve prompts or a concise use record when AI materially shaped an analysis. [best practices to be discussed -- WIP]
- Treat generated code like an external contribution: review it before merging.
- Code written with AI assistance should be disclosed in Github commit messages or commit authorship.
For trainees learning a new method, your first step should be to develop an initial implementation by yourself, and use AI support only for explanation, feedback, debugging, or comparison. Potential exceptions to this learning sequence should be discussed with Andrew/Elizabeth/Javier.