Skip to content

Comparative Advantage Calculator

Run the Comparative Advantage Calculator MicroSim Fullscreen
Edit in the p5.js Editor

About This MicroSim

This MicroSim demonstrates the principle of comparative advantage -- one of the most important ideas in economics. Two countries (or people) each produce two goods (Cars and Clothing), and the simulator calculates opportunity costs to determine which country should specialize in which good. Students can see Production Possibility Frontier (PPF) graphs for each country, an opportunity cost comparison table, and a detailed before-and-after analysis showing how both countries can consume more through specialization and trade, even when one country is better at producing everything.

How to Use

  1. Select a Preset -- Use the dropdown to choose from built-in scenarios (US vs Vietnam, Germany vs Greece, Two Friends) or "Custom" to set your own values.
  2. Adjust Production Values -- In Custom mode, use the four small sliders to change how many Cars and Clothing units each country can produce per day.
  3. Read the Opportunity Cost Table -- The table shows the cost of producing one Car (in Clothing) and one Clothing unit (in Cars) for each country. Stars mark the country with the lower opportunity cost (comparative advantage).
  4. Show Trade Gains -- Click "Show Trade Gains" to see the before-and-after comparison: what each country produces without trade vs. what they can consume after specializing and trading.
  5. Press Reset -- Click Reset to return to the default values and hide the trade analysis.

Iframe Embed Code

You can add this MicroSim to any web page by adding this to your HTML:

<iframe src="https://dmccreary.github.io/economics-course/sims/comparative-advantage/main.html"
        height="512px"
        width="100%"
        scrolling="no"></iframe>

Lesson Plan

Grade Level

9-12 (High School Economics)

Duration

10-15 minutes

Prerequisites

  • Understanding of scarcity and tradeoffs
  • Familiarity with the concept of opportunity cost
  • Basic understanding of production possibilities

Activities

  1. Exploration (5 min): Have students try the "US vs Vietnam" preset. Ask them to note that the US produces more of both goods (absolute advantage) yet Vietnam still has a comparative advantage in Clothing. Click "Show Trade Gains" to verify both countries benefit.
  2. Guided Practice (5 min): Switch to Custom mode and create a scenario where Country A produces 10 Cars and 20 Clothing, while Country B produces 5 Cars and 15 Clothing. Have students calculate the opportunity costs by hand, then verify with the simulator. Discuss why the country with higher opportunity cost in one good automatically has lower opportunity cost in the other.
  3. Assessment (5 min): Students explain in writing why it makes sense for a country that is better at producing everything to still trade with a less productive country, using the concept of comparative advantage and specific numbers from the simulator.

Assessment

  • Can the student calculate opportunity costs for two producers and two goods?
  • Can the student explain the difference between absolute advantage and comparative advantage?
  • Does the student understand why both countries benefit from specialization and trade?

References

  1. Comparative advantage - Wikipedia
  2. Production-possibility frontier - Wikipedia
  3. Comparative Advantage - Khan Academy