EC 350 International Economics - Project
Student Handout: Using Positron AI Agent
Purpose
Use Positron AI to answer each analysis question one by one with code you understand and can explain.
Non-Negotiable Rule
For every AI request, ask for:
- one code chunk only
- short explanation
- one validation check
Use this exact line in prompts:
“Return code first, then explanation, then one validation check.”
Setup Prompt (Copy/Paste)
I am working in an R Quarto file for a project related to current account dynamics.
Create a .qmd file that renders to an html output file.
Write one code chunk to load tidyverse, readxl, writexl, and glue. Use pacman package to install and load the packages at once. Then explain briefly what each package is used for. Return code first, then explanation, then one validation check.
Inputs Prompt (Copy/Paste)
Write one R chunk with these inputs:
my_country <- "<YOUR COUNTRY>"
start_date <- 2000
end_date <- 2019
data_file <- "GMD_sub_1995_2019.xlsx"
save the data_file as df.
Also add a file-existence check that stops with a clear error if missing.
Return code first, then explanation, then one validation check.
Read + Filter Prompt
Write one R chunk to read the Excel file into df and filter by my_country and year range.
Add a compact summary table with country, min_year, max_year, n_rows, n_columns.
Explain how this prevents downstream errors.
Return code first, then explanation, then one validation check.
Question-by-Question Prompts (Matching the live demo)
Q1A) Current Account vs Trade Balance (Time Series)
Use df as the dataset. Write one ggplot chunk for CA and trade_balance over time.
Include a zero line, clear labels, and title/subtitle using my_country/start_date/end_date.
Then explain how to interpret divergence between CA and trade_balance.
Return code first, then explanation, then one validation check.
Q1B) Current Account vs Trade Balance (Scatter)
Use df as the dataset. Write one ggplot scatter chunk of CA (x) vs trade_balance (y) with zero lines and a 45-degree reference line.
Give 3 interpretation bullets for points above/below the 45-degree line.
Return code first, then explanation, then one validation check.
Q1C) Correlation Between CA and Trade Balance
Use df as the dataset. Write one R chunk to compute Pearson correlation between CA and trade_balance.
Return a short sentence with the rounded value.
Explain why this correlation can be close to 1 but not exactly 1.
Return code first, then explanation, then one validation check.
Q1D) Income Balance = CA - Trade Balance
Use df as the dataset. Write one R chunk to create income_balance = CA - trade_balance.
Then show summary statistics: mean, median, min, max.
Explain the economic meaning of income_balance.
Return code first, then explanation, then one validation check.
Q1E) Plot CA, Trade Balance, and Income Balance
Use df as the dataset. Write one ggplot time-series chunk with CA, trade_balance, and income_balance.
Add a zero line and readable labels.
Then explain what drives the gap between CA and trade_balance.
Return code first, then explanation, then one validation check.
Q2A) Domestic Absorption = C + I + G
Use df as the dataset. Write one R chunk to create dom_abs = cons + inv + govexp.
Show a small table with year, nGDP, dom_abs, and CA.
Explain CA = GDP - absorption in plain English.
Return code first, then explanation, then one validation check.
Q2B) Plot GDP, Absorption, and Current Account
Use df as the dataset. Write one faceted time-series plot for nGDP, dom_abs, and CA.
Put nGDP and dom_abs in one panel and CA in another panel.
Then explain what to look for when absorption exceeds GDP.
Return code first, then explanation, then one validation check.
Q3A) Savings = GDP - C - G
Use df as the dataset. Write one R chunk to create savings = nGDP - (cons + govexp).
Then report average savings, investment, and CA.
Explain CA = S - I in plain English.
Return code first, then explanation, then one validation check.
Q3B) Plot Savings, Investment, and Current Account
Use df as the dataset. Write one faceted time-series plot for savings, inv, and CA.
Then explain what it implies when investment is above savings.
Return code first, then explanation, then one validation check.
Q4A) Correlation Matrix
Use df as the dataset. Write one chunk to compute a correlation matrix for nGDP, dom_abs, trade_balance, and CA.
Format output cleanly.
Then explain what high/low correlations mean in this context.
Return code first, then explanation, then one validation check.
Q4B) GDP with Trade Balance and Current Account
Use df as the dataset. Write one R chunk to compute correlations of nGDP with trade_balance and with CA.
Interpret signs/magnitudes with one caveat.
Return code first, then explanation, then one validation check.
Q4C) Scatter: GDP vs Trade Balance
Use df as the dataset. Write one scatter plot of nGDP (x) vs trade_balance (y) with an lm trend line.
Then explain whether the relationship appears pro-cyclical or counter-cyclical.
Return code first, then explanation, then one validation check.
Q4D) Scatter: Domestic Absorption vs Trade Balance
Use df as the dataset. Write one scatter plot of dom_abs (x) vs trade_balance (y) with an lm trend line.
Include the correlation value in the subtitle.
Return code first, then explanation, then one validation check.
Q4E) Time Series: GDP, Absorption, Trade Balance
Use df as the dataset. Write one faceted time-series plot for nGDP, dom_abs, and trade_balance.
Then explain how this helps interpret business-cycle comovement.
Return code first, then explanation, then one validation check.
Q5A) Government Revenues, Expenditures, and Deficit
Use df as the dataset. Write one faceted time-series plot for govrev, govexp, and govdef.
Then explain what this says about fiscal stance over time.
Return code first, then explanation, then one validation check.
Q5B) Government Deficit vs Current Account
Use df as the dataset. Write one chunk to plot govdef and CA over time in separate facets.
Compute their correlation and provide a cautious interpretation of twin deficits.
Include one sentence: correlation does not imply causality.
Return code first, then explanation, then one validation check.
Q5C) As Percent of GDP
Use df as the dataset. Write one faceted time-series plot for govdef_GDP and CA_GDP.
Label the y-axis as percent of GDP.
Then explain how % of GDP improves cross-country interpretation.
Return code first, then explanation, then one validation check.
Q6) Export Cleaned Data
Write one R chunk to export df (with all created variables) to Excel as:
Proj1_clean_<country>_<start>_<end>.xlsx
Use underscores for spaces in country names.
Return code first, then explanation, then one validation check.
Writing Prompt for Your Report
Write a 120-150 word interpretation of my results.
Requirements:
- use evidence from at least two plots and one correlation
- include one economic mechanism
- include one limitation/caveat
- use clear undergraduate-level language
Return paragraph first, then a 3-item self-check.
Self-Audit Prompt (Use Before Submission)
Audit my interpretation for overclaiming.
List statements not supported directly by evidence and rewrite conservatively.
Rescue Prompts (When Something Breaks)
My chunk failed. Diagnose in order:
1) object not found
2) missing column
3) zero rows after filter
4) wrong file path
Return corrected chunk and one-sentence cause.
Before plotting, write a check that verifies required columns exist in df.
If missing, list missing columns and stop with a helpful error.
Submission Checklist
- Updated
my_country,start_date, andend_date - Re-ran all chunks top-to-bottom without errors
- Verified all plots are for your country
- Rendered HTML output
- Included your edited QMD file
- Exported cleaned Excel file (if required)
Integrity Checklist
- I can explain each chunk I used.
- I checked variable names and signs before interpreting.
- I did not copy AI text without verifying against my output.
Short Reminder
AI can help you code faster. You are still responsible for correctness, interpretation, and economic reasoning.