THE WORKING RESEARCHER’S AI TOOLKIT · DAY 6 OF 6
Six short, practical guides to using AI in a research career, one a day this week. Every guide has copy-and-paste prompts that work in ChatGPT, Claude, Gemini or Copilot.
Of everything in this series, data analysis is where AI has changed researchers’ work the most. Ask it to write R or Python, explain an error message or convert old SPSS syntax, and a job that took days can take an afternoon. The catch with AI for data analysis is that it can run the wrong analysis with complete confidence, and anything you upload, including participant data, ends up on someone else’s server.
This guide covers quantitative analysis and the code behind it, in R, Python, SPSS or Stata, from planning an analysis to sharing the script. It shows where AI helps; it isn’t a statistics course. Using AI on interview transcripts raises different questions, so for that, see this article on qualitative data analysis for PhD research. For writing up your results, see Day 4’s guide to writing with AI, and for general help with analysis, there’s a list of our best resources at the end.
Everything here rests on one habit: test everything on dummy data first. After that, the guide follows the order you’d work in: planning the analysis, writing and fixing the code, then checking it and making sense of the output. It finishes with how to run AI on your own computer when your data is too sensitive for anything else.
In brief
This guide shows you how to use AI for data analysis and coding without putting your participants’ data at risk. It’s for PhD students, postdocs and anyone who analyses data and writes code, or wants to. By the end you will:
- Know which tools suit which data: chat assistants, coding assistants in your editor, notebook agents and models that run offline on your own computer.
- Have prompts for each job: planning an analysis, writing and fixing code, translating old syntax, reviewing a script and explaining output.
- Have one habit that keeps you safe: AI writes and tests the code on dummy data, and you run it on the real data yourself.
Most of the tools here are free. Start with the dummy data prompt.
On this page
Start with data protection and the “Can I paste this?” checker, how good AI really is at statistics, the tools you’ll need with a setup picker, and the dummy data habit with a prompt builder.
Part 1: Planning the analysis. Get a second opinion on your plan.
Part 2: Writing and fixing the code. Ask for code you can check, fix an error, translate old code, use an assistant in your editor and try a notebook agent.
Part 3: Checking it and making sense of it. Test against a known answer, review the script, understand the output and make it rerunnable.
Then sensitive data and local models, bonus: AI as a coding tutor, a worked example, where to be careful, five things to try, common questions and the whole series.
Data protection comes first
Before anything else: participant data does not go into a public AI tool. Not if it looks anonymised, and not a few rows to test something. University guidance is clear. UCL’s guidance on third-party AI services says personal data, research data and other confidential information should not be put into third-party AI tools, and its advice on third parties in research applies to pseudonymised data too. Oxford’s policy on generative AI in research says that when research involves personal data, any use of AI must be set out in both the proposal and the ethics application.
Your university’s own licensed AI, such as Microsoft Copilot Chat, ChatGPT Edu or Gemini with your university login, gives you more protection than a personal account. Check what kind of data it’s cleared for, though, because some universities still say no personal data even there. Your ethics approval and data management plan say where your data can go. If they don’t mention AI tools, AI tools aren’t covered.
The good news is that most of what AI does well for analysis needs your data’s structure, not your data. This guide is built around that. Not sure whether something is safe to paste? Check it here.
Try it
Can I paste this into an AI tool?
Pick what you want to paste and where. Nothing you choose here leaves this page.
Choose one option from each list to see the answer.
A rule of thumb, not an approval. Your ethics approval, data management plan and university policy always come first.
How good is AI for data analysis?
Good, with the right prompt, and worse than it sounds without one.
32.5%
of ChatGPT’s inferential statistics were correct with basic prompts, in a JMIR study using healthcare data.
92.5%
were correct when the same study used detailed prompts. How you ask matters as much as which tool you use.
0 of 6
leading AI models got data manipulation, contingency tables and Bayesian models fully right in a 2026 test (a preprint, not yet peer reviewed).
In that 2026 test, ChatGPT, Claude and Gemini all got the descriptive statistics right, and none was right about everything. The author concluded they work best alongside proper statistical software, not instead of it. In short: be specific, let AI write code rather than give you answers, and check.
The tools you’ll need to use AI for data analysis
The tools fall into five kinds, and the main difference between them is where your code and data go.
| Tool | Good for | Cost |
|---|---|---|
| Chat assistants: plan, write, explain and fix code | ||
| ChatGPT, Claude or Gemini | Planning, writing and debugging code in any language. They can also run Python on files you upload, but only use that with public or dummy data | Free with limits, paid plans about US$20 a month |
| Your university’s licensed AI Copilot Chat, ChatGPT Edu or Gemini with your university login |
The first place to look for anything that touches university data, once you’ve checked what it’s cleared for | Free with a university login |
| Coding assistants: work inside your editor | ||
| GitHub Copilot in RStudio, Positron or VS Code |
Suggests code as you type and answers questions about your script | Free for verified students and teachers through GitHub Education. A limited free plan for everyone |
| Posit Assistant in RStudio or Positron |
An assistant that can see your loaded data, plots and console, and run code for you | Posit AI subscription, US$20 a month. RStudio and Positron themselves are free |
| Notebook agents and built-in helpers: run the analysis for you | ||
| Google Colab’s Data Science Agent | Describe an analysis in plain English, and it writes and runs a complete Python notebook in your browser | Free with limited computing, Colab Pro from US$9.99 a month |
| SPSS AI Output Assistant in SPSS Statistics 31 and later |
Explains output tables and charts in plain language | 30 free insights, then an IBM watsonx.ai account |
| Local models: nothing leaves your computer | ||
| LM Studio, Ollama, Jan or GPT4All | Running an open AI model offline, for explaining and fixing code near sensitive data | Free download. 16 GB of memory is the practical minimum |
GitHub paused new Copilot Student sign-ups between April and June 2026. They have reopened, but check the current terms when you apply. Some universities are now writing policies on AI for programming too: UCL’s research computing centre published one for its own staff in October 2026. Check whether your department has one, and ask your IT or research data team which AI tools are approved for which kinds of data.
Not sure where to start? Answer four questions for a suggested setup.
Try it
Which AI setup suits you?
Answer four questions for a suggested starting setup. Nothing you choose here leaves this page.
Answer all four questions to see a suggestion.
Prices checked in November 2026. Check with your university first: it may already license some of these.
The habit that makes AI for data analysis safe: dummy data
AI needs your data’s structure, not your data: the column names, the types of variable and rough ranges. So give it that, and ask it to make a fake dataset with the same shape. You can then build and test the whole analysis on the fake version in any AI tool. Once the code works, you run it on the real data in your own secure environment, with no AI involved.
There’s a second benefit. If you build a known effect into the dummy data, you know the answer your analysis should find, which is the simplest test there is of whether the code does what you think.
Copy this prompt · Make me a dummy dataset
Write [R / Python] code that creates a realistic dummy dataset matching this structure. I'll use it to build and test an analysis without sharing any real data. [Describe each variable, for example:] - n = 300 participants, 4 visits each (long format) - id: participant ID - visit: 0, 1, 2, 3 (years) - age_baseline: 60 to 90 - sex: female or male - apoe4: 0, 1 or 2 copies (about 25% have at least one) - mmse: 0 to 30, mostly 24 to 30 at baseline, declining slightly over time - about 15% dropout by visit 3, more likely in people with lower scores Build in one known effect so I can check my analysis finds it: [e.g. APOE4 carriers decline 0.4 points a year faster]. Use a fixed random seed so it's reproducible, and include the missing data pattern, because I need to test how my analysis handles it.
Use the copy button in the top corner, or click once inside the box to select it all. Replace the example variables with your own.
To describe your variables without showing any values, run sapply(your_data, class) in R, or df.dtypes in Python. That lists the name and type of each column and nothing else. Avoid str(), summary() and head(), which all print real values. Add rough ranges and the missing data pattern yourself, from memory or your codebook.
Prefer to fill in a form? This builds the same prompt for you, for R or Python.
Try it
Build your dummy data prompt
Describe your dataset's shape, not its contents, and this writes the prompt for you. Nothing you type leaves this page.
Variables
For each one, give a name, a type and the rough range or categories. No real values.
1
Part 1
Planning the analysis
A second opinion on your approach, before you look at any results.
The most useful moment to use AI for data analysis is before you’ve run anything. Planning the analysis before you see the results is good practice anyway, and AI makes it quick to think through options, assumptions and what you’ll need to report.
Get a second opinion on your plan
Copy this prompt · Plan my analysis
I'm analysing [design, e.g. a cohort with four yearly visits] to answer this question: [your question]. Outcome: [variable and type]. Main exposure: [variable]. Covariates: [list]. Missing data: [pattern, e.g. about 15% dropout, more likely in people with lower scores]. 1. Recommend an analysis and explain why, in plain English, including what it assumes. 2. List the checks I should run on those assumptions, and how to interpret them. 3. Name one or two reasonable alternatives, and when I'd choose them instead. 4. Say exactly what I should report: estimates, intervals, model fit. 5. Name the most common mistake people make with this analysis. Don't write any code yet.
Use the copy button in the top corner, or click once inside the box to select it all.
Treat the answer as a second opinion, not a ruling. AI can sound equally sure about a good choice and a poor one. Take the plan to your supervisor or a statistician before you commit, and ask whether your university runs a statistics clinic or advisory service, as many do for free. If you’re pre-registering the study, this prompt gives you a good first draft of the analysis section.
2
Part 2
Writing and fixing the code
Code you can read and check, error messages explained, and old syntax translated.
This is where AI saves the most time. You can do all of it in a free chat assistant, or with a coding assistant inside your editor.
Ask for code you can check
A vague request gets code that runs and may still be wrong. Tell it which packages to use, and ask it to show its working.
Copy this prompt · Write the code
Using the analysis plan above, write [R / Python] code for my dummy data. My variables and their types are: [paste the output of sapply(your_data, class) or df.dtypes]. - Use only these packages: [e.g. tidyverse, lme4 and lmerTest]. - Comment each step in plain English. - Don't drop rows without saying so: print how many rows are lost at each step, and why. - Set a random seed wherever anything is random. - List any defaults the code relies on that could change my results, such as how missing values are handled, contrasts, or the type of sums of squares.
Use the copy button in the top corner, or click once inside the box to select it all.
Fix an error
Error messages are where most beginners give up, and where AI is at its most useful. Paste the error and the code that caused it. Don’t paste the data.
Copy this prompt · Explain and fix this error
This [R / Python] code gives the error below. Explain in plain English what the error means and why it's happening, then show the corrected code with comments. My variables and their types are: [paste the output of sapply(your_data, class) or df.dtypes]. Code: [paste the code] Error: [paste the full error message]
Paste the whole error message, not just the last line. The useful clue is often near the top.
Translate old code
Moving from SPSS or Stata to R or Python, or picking up a former colleague’s script, used to take weeks. AI can translate it line by line, but the different packages make different default choices, and those change results.
Copy this prompt · Translate this code
Convert this [SPSS syntax / Stata do-file] to [R using the tidyverse / Python using pandas and statsmodels]. Comment each step. Then list every place where the new language's defaults differ from the original's and could change the results, such as contrasts, sums of squares, how missing values are handled, or how standard errors are calculated. Tell me how to match the original if I need to reproduce its numbers exactly. [paste the code]
Run both versions on the same dummy data and compare the results before you trust the translation.
Use an assistant in your editor
Copying code between a chat window and your script gets tedious. A coding assistant works inside your editor instead. GitHub Copilot in RStudio is switched on under Tools, then Global Options, then Copilot, and it also works in Positron and VS Code. Write a comment such as # fit a mixed model with random intercepts for id, and it suggests the code. It saves typing on routine work, and it’s free for verified students and teachers.
Posit Assistant, in RStudio and Positron, goes further. It can see the data frames you have loaded, your plots and your console, and run code for you, so it can write code that fits your actual data. That also means it sends what it sees to the AI company behind it. Posit has a zero data retention agreement with that provider, but it’s still a third party. So use it with dummy data, unless your university has approved it for your data.
Try a notebook agent, on open data
In Google Colab, the Data Science Agent takes a plain request, such as “clean this file, plot the trends over time and fit a regression”, and writes and runs a complete Python notebook. It’s free, and a fast way to explore a public dataset or to learn Python by reading the code it writes. Your file goes to Google, so use it with open or dummy data only.
3
Part 3
Checking it and making sense of it
Prove the code does what you meant, review the script, and understand what the output is telling you.
The biggest risk when you use AI for data analysis isn’t code that fails. It’s code that runs, looks fine and is wrong. A wrong join, rows dropped without warning or a model that ignores repeated measures will all run without complaint. This part is about catching that.
Test it against a known answer
Run your code on the dummy data first. Because you built a known effect into it, you know what the analysis should find. If the estimate comes out close to the effect you built in, the code is doing what you meant. If it doesn’t, something is wrong with the code, and you’ve found out before it touched your real data. It’s also worth building a version with no effect at all, to check the code doesn’t find one that isn’t there.
Review the script before anyone else sees it
Copy this prompt · Review my script
Review this analysis script as a careful statistician and research software engineer. 1. Errors or risky steps: for example rows dropped without warning, wrong joins, or categories read as numbers. 2. Is it reproducible? Check for a random seed, recorded package versions and hard-coded file paths. 3. Is the statistical approach right for the question in the comments? 4. What would be unclear to someone reading it for the first time? List the problems with line numbers. Don't rewrite the whole script. [paste the script]
Check the script contains no real data, passwords or file paths that reveal anything sensitive before you paste it.
Understand the output
Model output is dense, and it’s easy to misread an interaction term or miss a warning. Output tables are summaries rather than raw data, so they’re usually safe to paste into an AI tool. Take care with small groups, though: a table with a handful of people in one cell can identify someone, so leave those out or round them.
Copy this prompt · Explain this output
Here is the output from [the analysis, e.g. a linear mixed model]. My question was: [your question]. 1. Explain what each part of the output means, in plain English. 2. What can I conclude, and what can't I conclude, from these results? 3. Flag anything that suggests a problem, such as warnings, a model that failed to converge, or very wide intervals. 4. Which numbers should I report, and how? [paste the output]
In SPSS 31 or later, the built-in AI Output Assistant does a similar job, but it sends your output to IBM, so the same care applies.
Make it something someone else can rerun
Your analysis should end up as a script that someone else can rerun, not as a series of answers in a chat window. If an AI tool ran an analysis for you on an uploaded file, ask it for the code it used and rewrite that as a proper script. Then ask it to help you document the work: “Add a short header to this script saying what it does, what data it expects and which package versions it was run with. Then draft a README for the project folder explaining how to rerun the analysis from start to finish.” That small step makes your work far easier to check, share and come back to.
Using AI for data analysis with sensitive data: run it on your own computer
Free apps such as LM Studio, Ollama, Jan and GPT4All download an open AI model to your computer and run it offline, so nothing leaves your machine. The models are less capable than the big online ones, but they’re fine for explaining code and fixing errors. You’ll want 16 GB of memory or more, and LM Studio, the easiest to start with, recommends that as a minimum.
Even so, check with your information governance or research data team before you use one near real participant data. Running locally doesn’t remove the need for approval, though it often makes approval easier to get.
Bonus
Use AI as a coding tutor, not just a code writer
If you’re learning R or Python, copying code you don’t understand will catch up with you, usually in a viva or a review. Used differently, AI is one of the fastest ways to learn. Ask it to teach rather than do, and keep the real work in your own hands.
Copy this prompt · Teach me this code
I'm learning [R / Python] and I understand [what you know, e.g. basic data frames but not loops or functions]. Explain this code to me line by line, at my level. Then give me three small changes to make myself, without the answers. When I paste back my attempts, tell me what's right, what's wrong and why, but let me fix the mistakes myself. [paste the code]
Run your attempts on dummy data, so a mistake costs you nothing.
Many universities also run free R and Python workshops through their library, doctoral school or research software engineering team. AI works best alongside them, not instead of them.
Worked example: using AI for data analysis on a first mixed model
Priya is a made-up postdoc with four yearly waves of cognitive data, held in her university’s secure research environment. She wants to know whether people who carry the APOE4 gene decline faster. She’s run t-tests and regressions before, but never a mixed model.
First attempt (what not to do). She asked a chatbot to “write R code to see if APOE4 affects MMSE over time”. It gave her lm(mmse ~ visit * apoe4, data = df). The code runs, and it looks fine. But it treats 1,200 rows as 1,200 independent people, when they’re really 300 people measured four times. Her standard errors would have been far too small, and nothing in the output warned her.
Second attempt (the way this guide suggests).
- Dummy data. She ran the dummy data prompt, with APOE4 carriers built to decline 0.4 points a year faster. Now she knew the answer her code should find.
- The plan (Part 1). The planning prompt recommended a linear mixed model with a random intercept and slope for each participant. It explained that, if the data are “missing at random”, this approach uses every visit people attended rather than dropping anyone who left the study. It also warned that this assumption can’t be proved, and suggested a sensitivity analysis. She checked the plan with her department’s statistician, who agreed.
- The code (Part 2). She asked for commented code, using only the packages she named.
The code she ended up with
library(lme4)
library(lmerTest) # adds p-values for the fixed effects
dummy$apoe4_carrier <- as.integer(dummy$apoe4 >= 1)
m1 <- lmer(
mmse ~ visit * apoe4_carrier + age_baseline + sex +
(1 + visit | id), # each person has their own starting point and rate of change
data = dummy
)
summary(m1)
confint(m1, parm = "beta_", method = "Wald")
- The known answer (Part 3). On the dummy data, the
visit:apoe4_carrierestimate came out close to the −0.4 she had built in. The code was doing what she meant. - The review. The script review prompt flagged a hard-coded file path, and reminded her to report how many people contributed at each visit.
- The real data. Only then did she copy the script into the secure environment and run it on the real data, with no AI anywhere near it.
The whole thing took an afternoon. Learning it from a textbook would have taken her a week. The step that mattered most was testing on dummy data with a known answer, because it’s the one that would have caught the first attempt’s mistake.

A four step workflow for using AI in data analysis safely: describe the data structure, test on dummy data, check the code carefully and run real data only in a secure environment.
Where to be careful when using AI for data analysis
Code that runs isn’t code that’s right
The most dangerous mistakes don’t produce errors. Test on dummy data with a known answer, every time.
Real data stays out of public tools
That includes “just the first ten rows” and data you think is anonymised. Small datasets with dates, postcodes or rare conditions can identify people.
Defaults differ
R, Python, SPSS and Stata make different default choices, for example about contrasts, sums of squares and missing values. Ask the AI to name the defaults it’s relying on.
Niche packages trip it up
AI is reliable on common tasks and less so on specialist packages, where it can invent functions or arguments that don’t exist. Check against the package documentation.
Keep the code, not the chat
If an AI tool ran the analysis for you, get the code and rerun it yourself as a script.
Say what you used
Journals increasingly ask how AI was used in analysis. Note which tool helped with which part, as you would for any other software.
Five ways to start using AI for data analysis this week
- Make a dummy version of your current dataset with the dummy data prompt, with one known effect built in.
- Run the planning prompt for an analysis you’re about to do, before you look at any results.
- Paste an old error message and its code into the fix-an-error prompt.
- If you’re a student or teacher, apply for GitHub Education and switch on Copilot in RStudio or Positron.
- Put your most important analysis script through the review prompt.
Common questions about using AI for data analysis
Using AI for data analysis safely
Is it safe to put research data into ChatGPT?
Not participant data, unless your ethics approval and data management plan allow it, and they almost never name a public AI tool. Removing names isn’t the same as anonymising: dates, postcodes and rare conditions can still identify people, and universities such as UCL treat pseudonymised data in the same way as personal data. Use dummy data instead, or a university-licensed tool that’s cleared for that kind of data. If your university hasn’t approved any tool, do the planning, dummy data and debugging in public tools, and run everything real in your secure environment.
Can ChatGPT do statistical analysis?
It can run simple analyses on files you upload, and with detailed prompts it gets most common tests right. In one study it managed 92.5% with detailed prompts but only 32.5% with basic ones, and it can pick the wrong test without any warning. It’s safer to use it to plan the analysis and write the code, then run that code yourself in R, Python or SPSS, where you can check and rerun every step.
Can ChatGPT analyse an Excel or CSV file?
Yes. Upload a spreadsheet or CSV and it writes and runs Python code to answer your questions about it, and there’s now a ChatGPT add-in for Excel and Google Sheets too. Only do this with open or dummy data, and ask to see the code it used, so you can check it and rerun it yourself.
Can I use ChatGPT for data analysis in my thesis?
Usually, if you use it to help write and understand code that you check and run yourself, and you say so. Rules vary between universities and are often stricter for assessed work, including theses, so check your university’s policy and talk to your supervisor. Keep your prompts and your final scripts, and be ready to explain every step of your analysis in your viva.
Do I need to disclose AI use in my analysis?
Usually, yes. The medical journal editors’ committee, ICMJE, updated its recommendations in January 2026 to say that AI used in data analysis should be described in the methods, and many publishers ask the same. Note the tool, the version and what it did, and keep the code and prompts so the work can be checked.
Tools and costs
Can ChatGPT write R code?
Yes, and it’s good at common jobs such as reshaping data, plots, regression and mixed models. It’s less reliable with specialist packages, where it can invent functions or arguments that don’t exist. Test the code on dummy data and check anything unfamiliar against the package documentation. The same goes for Python.
What is the best AI for data analysis?
It depends on the job, and there’s no single winner. For writing and fixing R or Python code, Posit’s own tests found the leading models from Anthropic, OpenAI and Google close together, and they change every few months. Tools built for uploading a spreadsheet and chatting to it, such as Julius AI, are popular, but they only suit open or dummy data. The free versions of the big chat assistants are fine for most tasks, and if your university licenses one, start there.
Is GitHub Copilot free for students?
Yes, for verified students through GitHub Education, and teachers can get Copilot Pro free too. Everyone else can use the limited Copilot Free plan. GitHub paused new student sign-ups from April to June 2026 and has since reopened them, so check the current terms when you apply.
Does SPSS have AI?
Yes. SPSS Statistics 31 and later include the AI Output Assistant, which explains your output in plain language. You get 30 free insights, then need an IBM watsonx.ai account. It sends your output to IBM, so take care with tables that show small groups.
Can I run AI locally on my laptop?
Yes. LM Studio, Ollama, Jan and GPT4All are free and run an open model offline, so nothing leaves your computer. You’ll want at least 16 GB of memory, and the models are less capable than the big online ones. Check with your information governance team before using one near real participant data.
Learning and getting help
Does using AI make you worse at coding?
It can, if you copy code without reading it. When Anthropic studied developers learning a new Python library, those using AI understood the code less well afterwards, and how they used it made the difference. Ask it to explain each line, then make small changes yourself, as in our coding tutor prompt. Used that way, it’s one of the fastest ways to learn.
Where can I find general help with data analysis and statistics?
This guide is about how AI can help. For broader help with analysis, start with these:
- Free Research Tools for PhD Students, including free statistics software such as JASP, jamovi and Positron
- Qualitative Data Analysis for PhD Research
- Presenting Your Data Like a Pro
- From Data to Viz: the code you need
- statcheck, a spellchecker for statistics
- How to make your data accessible, discoverable and useful
That’s the series
Over six days, The Working Researcher’s AI Toolkit has covered:
- An AI morning briefing
- Finding and applying for jobs
- Raising your research profile
- Writing, with AI as an editor
- The literature, without the made-up references
- Data analysis and code, today’s guide
The thread through all of it: let AI do the slog and ask the awkward questions, keep the judgement and the final words for yourself, and check anything before you rely on it.
We last checked the prices, plans, features and statistics in this guide in November 2026. AI tools change every few weeks, so check each provider’s own website before relying on anything here. Dementia Researcher has no commercial relationship with any of the companies or products mentioned. If you’ve found a prompt or tool that works well for you, tell us at dementiaresearcher@ucl.ac.uk. We’d like to share the best ones.
