Overview

Column



YOUR LIFE IN THE NEXT TEN YEARS


What will your life be like in the next 10 years? What kind of work will you do after ‘Varsity’? How much will you ear in your first job after graduating? Where will you be living,and who will your friends be? How many friends will yu have? Who might you marry? Will you buy a house in the next few years? If so, how much will you pay for it? And, maybe most importantly, will you be happy?

Well, you may be surprised but according to Arnold (2014) the answers to these questions and many more have to do with economics. He goes on to explain, for example, the salary your earn has to do wih the concept of opportunity cost. What you do in your first job after Varsity has to do with the state of the economy when you graduate. Whom you marry has to do with the costs and benefits connected to the people you date. The price you pay for a house has to do with the state of the housing market. How many friends you have has to do with the economy concept of scarcity. Whether you are happy depends on such things as the net benefits you receive in various activities, the utility you gain by doing certain things, and other circumstances.

As you can see, economics provides significant insights into your present and future at an individual level. This perspective can be extended to other levels of analysis, such as national and international contexts. Hence, economics plays a crucial role in explaining various aspects of everyday life. This importance has led some economists to refer to economics as the “Queen of Social Sciences.” Political scientists, however, have labeled their field as the “Master Science” – long story!

In this course, we adopt the view that economics and political science are two sides of the same coin and should therefore be considered together for analytically purposes. Importantly, before proceeding further and introducing the topic of demand and supply, in the following clickable ‘tab’ key concepts in economics are defined.

Key concepts

Column

Concepts


Goods, Bads and Resources: a good is anything that gives a person utility, or satisfaction (e.g. car, computer, love, etc.). A bad is something that gives a person disutility or dissatisfaction (e.g. flu).
Goods do not appear before us when we snap our fingers – it takes resources to produce goods. Oftentimes resources are referred to as inputs or factors of production. Generally economist divide resources in 4 categories, namely: land, labor, capital and entrepreneurship.


Scarcity: is the condition in which our wants (for goods) are greater than the limited resources available to satisfy those wants. Scarcity has a number of effects, for example, (1) the need to make choices; (2) the need for a rationing device; and (3) competition.


Opportunity cost: is the most highly valued opportunity or alternative forfeited when a choice is made. So every time you make a choice you incur an opportunity cost. Importantly, the higher the opportunity cost of doing something is, the less likely it will be done. In short, a change in opportunity cost can change a persons’ behavior.


Costs and Benefits: Economists think in terms of both costs and benefits. Asked what benefits of taking a walk may be, an economist will also mention the related costs.


Incentive: is something that encourages or motivates a person to undertake an action. For example, individuals have incentives to undertake an action if the benefits are greater than the costs, that is, they expect to receive some net benefits (benefits greater than costs).


Ceteris Paribus: is a Latin term that means “all other things constant” or “nothing else changes”. The term is used to designate what we believe is is the correct relationship between two variables.

Column

Examples

Scarcity


Low admission rates at Yale
Each year Yale University receives more applications for admission to the freshmen class than spots available. Im most years, for ever 100applications that Yale receives, it can accept only seven applications for admissions. What Yale has to do, then, is ration its available admission spots. But how does it do that?
One way is imply to use money as a rationing device. In other words, raise the dollar amount of attending Yale to a high enough level so that the number equals the number of students willing and available to pay for admission.
As you may know, Yale does not ration its available spots this way. If fact, it uses numerous rationing devices in an attempt to whittle down the number of applicants to the number of available spots. For example, it might use the rationing device of high school grades. If after doing this Yale still has too many applicants, then it might then make use of the rationing device of standardized test scores. If there are still too many applicants, other rationing devices may be used to whittle down the number of applicants to the number of available spots.
In the first week of April each year, Yale sends out more rejection letters than acceptance letters. The point here is simple: with scarcity comes the need for a rationing device. More people want a spot at Yale than there are spots available. Yale has to use one or more rationing devices to decide who will be accepted and who will be rejected.

In: Arnold, 2014, p.6.

Opportunity cost


Opportunity costs and behavior
Economist believe that a change in opportunity cost can change a person’s behavior. For example, Mandisa attends IPE classes every Tuesdays. Every time she chooses to go to class, she gives up the opportunity to do something else, such as earn R50 an hour working at a job. The opportunity cost of Mandisa spending an our in class is R50.
Now let’s raise the opportunity cost of attending class. On Tuesday we offer Mandisa R750 to skip her IPE class. She knows if she attends the class she will forfeit R750. What will Mandisa do? An economist would predict that as the opportunity cost of attending IPE class increase relative to its benefits, Mandisa is less likely to go to class.
This is how economists think about behavior: the higher the opportunity cost of doing something is, the less likely it will be done.

Empty

Demand

Column

What is Demand?


  • The word demand has a precise meaning in economics. It is defined has the willingness and ability of buyers to purchase different quaantities of a good at different prices during a specific time period.

The Law of Demand

  • As the price of a good rises, the quantity demanded of the good falls, and as the price of good falls, the quantity demanded of the goods rises, ceteris paribus (PS:Class, provide examples to get points)

  • The law of demand can be represented in a demand schedule (the numerical representation of a demand) and as a demand curve (the graphical representation of the law of demand)


Column

1. Demand Schedule


Below is the demand schedule for milk.


Price(R/1 liter container) Qty demanded (million containers) Point
10 45 A
9 50 B
8 55 C
7 60 D
6 65 E
5 70 F
4 75 G

2.Demand curve

3. Shifts in the demand curve


Change in the quantity demanded versus change in demand

  • A quantity demanded is equivalent to the number of units of a good that individuals are willing and able to buy at a particular price

  • Change in quantity demanded is a movement from one point to another point on the same demand curve caused by a change in the price of the good.


  • Change in demand refers to a shift in the demand curve.

  • An increase in demand will case a right shift in the demand curve (see graph 1); and decrease in demand will cause the leftward shift in the demand curve (see graph 2).


Graph 1


Graph 2

4. What causes demand shifts


Here are some factors that cause the demand curve to shift:

  • Income: as a person’s income changes (increases or decreases). that individual’s demand for a particular good may rise, fall or remain constant.

  • Preferences: people’s preferences affect the amount of a good they are willing to buy at a particular price

  • Prices of related goods: two goods that are, for example, substitutes (coca-cola and pepsi-cola) as the price of one one rises (falls) the demand for other rises (falls).

  • Number of buyers: more buyers higher demand; fewer buyers lower demand.

  • Expectation of future prices: buyers who expect the price of a good to be higher next wee may buy it now, thus increasing the current demand for the good. Buyers who expect the the price of a good to be lower next week, may wait until next week to buy it , thus decreasing the current demand for that good.

Empty

Supply

Column

What is Supply?


  • Supply refers to the willingness and ability of sellers to produce and offer to sell different quantities of a good at different prices during a specific time period.

The Law of Supply

  • As the price of a good rises, the quantity supplied of the good rises, and as the price of a good falls, the quantity supplied of the good falls, ceteris paribus (PS:Class, provide examples to get points)

  • The law of supply can be represented in a supply schedule (the numerical tabulation of the quantity supplied of a good at different prices) and as a supply curve (the graphical representation of the law of supply)


Column

1. Supply Schedule




Below is the supply schedule for milk


Price(R/1 liter container) Qty supplied (million containers) Point
10 90 A
9 80 B
8 70 C
7 60 D
6 50 E
5 40 F
4 30 G

2. Supply curve

3. Shifts in the supply curve


Change in the quantity supplied versus change in supply

  • Change in supply is not the same as a change in the quantity supplied

  • Change in quantity supplied refers to a movement along a given supply curve (price driven)

  • A change in supply refers to a shift in the supply curve

  • An increase in supply will cause a rightward shift in the demand curve (see graph 1); Conversely, a decrease in supply will cause a leftward shift in the supply curve (see graph 2)


Graph 1


Graph 2

4. What causes supply shifts



There are many factors that cause the demand curve to shift. Some of them are:


  • Prices of relevant resources: Resources needed to produce goods.

  • Technology: if advance in technology reduces per-unit production costs, we expect the quantity supplied of the good at each price to increase

  • Number of sellers: if more sellers begi to produce a good, the supply curve will shift rightward

  • Expectation of future price: if a price of a good is expected to be higher in the future, producers may hold back some of the products today, then they will have more to sell at a higher future price

  • Taxes in Subsidies: a rough rule of thumb is that we get more of what we subsidize and less of what we tax.

Empty

Market equilibrium

Column

Law of supply and demand

  • In a free market, the forces of supply and demand tend to push the price toward the level at which quantity supplied and quantity demanded are equal. So demand and supply together establish the equilibrium price (market-clearing price) and equilibrium quantity

  • Graphically the equilibrium is the intersection point of the demand and supply curves (see graph 1)

  • Any price at which quantity demanded is not equal to quantity supplied result in either surplus (excess supply) or shortage (excess demand)

  • Equilibrium price and quantity are determined by supply and demand. Whenever demand changes, supply changes, or both change equilibrium price and quantity change (see graph 2 and 3)

Column

Graph 1

Graph 2

Graph 3

Graph 4

Empty

:::

---
title: "**Demand & Supply**"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed 
editor_options: 
  markdown: 
    wrap: 72
---

```{r setup, message= FALSE, warning=FALSE, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(econocharts)
library(tidyr)
library(plotly)
library(grid) 
library(patchwork)
```

# Overview {.sidebar data-width="150"}

::: {style="text-align: center;"}

![](images/Wits logo.png){width="50"} <br>
**INTR2007**<br> IPE_Block III <br>
2024

|
|

[[Celso Monjane](mailto:celso.monjane@wits.ac.za)]{style="color: blue;"}

:::

# **Overview**

Column {data-width=350}
-------------------------------------

|
|
|

::: {style="text-align: center;"}
**YOUR LIFE IN THE NEXT TEN YEARS**
:::

|
|

::: {style="text-align: justify;"}
What will your life be like in the next 10 years? What kind of work will
you do after 'Varsity'? How much will you ear in your first job after
graduating? Where will you be living,and who will your friends be? How
many friends will yu have? Who might you marry? Will you buy a house in
the next few years? If so, how much will you pay for it? And, maybe most
importantly, will you be happy?

Well, you may be surprised but according to Arnold (2014) the answers to
these questions and many more have to do with economics. He goes on to
explain, for example, the salary your earn has to do wih the concept of
[**opportunity cost**]{style="color: #FF6347;"}. What you do in your
first job after Varsity has to do with the *state of the economy* when
you graduate. Whom you marry has to do with the [**costs and
benefits**]{style="color: #FF6347;"} connected to the people you date.
The price you pay for a house has to do with the state of the *housing
market*. How many friends you have has to do with the economy concept of
[**scarcity**]{style="color: #FF6347;"}. Whether you are happy depends
on such things as the [**net benefits**]{style="color:#FF6347;"} you
receive in various activities, the [**utility**]{style="color:#FF6347;"}
you gain by doing certain things, and other circumstances.

As you can see, economics provides significant insights into your
present and future at an individual level. This perspective can be
extended to other levels of analysis, such as national and international
contexts. Hence, economics plays a crucial role in explaining various
aspects of everyday life. This importance has led some economists to
refer to economics as the "Queen of Social Sciences." Political
scientists, however, have labeled their field as the "Master Science" --
long story!

In this course, we adopt the view that economics and political science
are two sides of the same coin and should therefore be considered
together for analytically purposes. Importantly, before proceeding
further and introducing the topic of demand and supply, in the following
clickable 'tab' key concepts in economics are defined.

:::



# **Key concepts**

## Column {.tabset}

### [**Concepts**]{style="color: red;"}

::: {style="text-align: justify;"}

|
|

[**Goods, Bads and Resources**]{style="color: blue;"}: a **good** is
anything that gives a person *utility*, or satisfaction (e.g. car,
computer, love, etc.). A **bad** is something that gives a person
*disutility* or dissatisfaction (e.g. flu).  <br>
Goods do not appear before us when we snap our fingers -- it takes resources to produce goods.
Oftentimes resources are referred to as *inputs or factors of
production*. Generally economist divide resources in 4 categories,
namely: land, labor, capital and entrepreneurship.

|
|

[**Scarcity**]{style="color: blue;"}: is the condition in which our
wants (for goods) are greater than the limited resources available to
satisfy those wants. Scarcity has a number of effects, for example, **(1)**
the need to make choices; **(2)** the need for a rationing device; and **(3)**
competition.

|
|

[**Opportunity cost**]{style="color: blue;"}: is the most highly valued
opportunity or alternative forfeited when a choice is made. So every
time you make a choice you incur an opportunity cost. Importantly, *the
higher the opportunity cost of doing something is, the less likely it
will be done*. In short, a change in opportunity cost can change a
persons' behavior.

|
|

[**Costs and Benefits**]{style="color: blue;"}: Economists think in
terms of both *costs* and *benefits*. Asked what benefits of taking a
walk may be, an economist will also mention the related costs.

|
|

[**Incentive**]{style="color: blue;"}: is something that encourages or
motivates a person to undertake an action. For example, individuals have
incentives to undertake an action if the benefits are greater than the
costs, that is, they expect to receive some *net benefits* (benefits
greater than costs).

|
|

[***Ceteris Paribus***]{style="color: blue;"}: is a Latin term that
means "all other things constant" or "nothing else changes". The term is
used to designate what we believe is is the correct relationship between
two variables.
:::

## Column {.tabset}

[**Examples**]{style="color: red;"}

### [**Scarcity**]{style="color:blue"}

|
|

::: {style="text-align: justify;"}
**Low admission rates at Yale** <br>
Each year Yale University receives more applications for admission to the freshmen class than spots available. Im most years, for ever 100applications that Yale receives, it can accept only seven applications for admissions. What Yale has to do, then, is ration its available admission spots. But how does it do that? <br>
One way is imply to use money as a rationing device. In other words, raise the dollar amount of attending Yale to a high enough level so that the number equals the number of students willing and available to pay for admission. <br>
As you may know, Yale does not ration its available spots this way. If fact, it uses numerous rationing devices in an attempt to whittle down the number of applicants to the number of available spots. For example, it might use the rationing device of high school grades. If after doing this Yale still has too many applicants, then it might then make use of the rationing device of standardized test scores.  If there are still too many applicants, other rationing devices may be used to whittle down the number of applicants to the number of available spots. <br>
In the first week of April each year, Yale sends out more rejection letters than acceptance letters. The point here is simple: with scarcity comes the need for a rationing device. More people want a spot at Yale than there are spots available. Yale has to use one or more rationing devices to decide who will be accepted and who will be rejected.

*In: Arnold, 2014, p.6*.


:::

### [**Opportunity cost **]{style="color:blue"}

|
|

::: {style="text-align: justify;"}
**Opportunity costs and behavior** <br>
Economist believe that a change in opportunity cost can change a person's behavior. For example, Mandisa attends IPE classes every Tuesdays. Every time she chooses to go to class, she gives up the opportunity to do something else, such as earn R50 an hour working at a job. The opportunity cost of Mandisa spending an our in class is R50. <br>
Now let's raise the opportunity cost of attending class. On Tuesday we offer Mandisa R750 to skip her IPE class. She knows if she attends the class she will forfeit R750. What will Mandisa do? An economist would predict that as the opportunity cost of attending IPE class increase relative to its benefits, Mandisa is less likely to go to class. <br>
This is how economists think about behavior: the higher the opportunity cost of doing something is, the less likely it will be done.

:::


### Empty


# **Demand**

## Column {.tabset data-width=250}

### [**What is Demand?**]{style="color: red;"}

|
|

::: {style="text-align: justify;"}
-   The word [**demand**]{style="color: blue;"} has a precise meaning in
    economics. It is defined has the willingness and ability of buyers
    to purchase different quaantities of a good at different prices
    during a specific time period.

| 
| 

[**The Law of Demand**]{style="color: red;"}

-   As the price of a good rises, the quantity demanded of the good
    falls, and as the price of good falls, the quantity demanded of the
    goods rises, *ceteris paribus* (PS:Class, provide examples to get
    points)

-   The law of demand can be represented in a [**demand
    schedule**]{style="color: blue;"} (the numerical representation of a
    demand) and as a [**demand curve**]{style="color: blue;"} (the
    graphical representation of the law of demand)
:::

| 
| 


## Column {.tabset}

### [**1. Demand Schedule**]{style="color: darkgreen;"}

|
|

Below is the demand schedule for milk.

|
|

| **Price**(R/1 liter container) | Qty demanded (million containers) | Point |
|:------------------------------:|:---------------------------------:|:-----:|
|               10               |                45                 |   A   |
|               9                |                50                 |   B   |
|               8                |                55                 |   C   |
|               7                |                60                 |   D   |
|               6                |                65                 |   E   |
|               5                |                70                 |   F   |
|               4                |                75                 |   G   |

| 
| 

### [**2.Demand curve**]{style="color: darkgreen;"}

```{r}
demand_i <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(75, 70, 65, 60, 55, 50, 45),
  Point = c("A", "B", "C", "D", "E", "F", "G")
)

# Plot demand curves with dotted lines
p1 <- ggplot() +
  geom_path(data =  demand_i, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand_i, aes(y = Price, x = Quantity), color = "blue") +
  theme_bw()+
  ggtitle(" Demand Curve")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
     scale_x_continuous(breaks = seq(45, 75,5))+
  scale_y_continuous(breaks = seq(4, 10, 1))+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
ggplotly(p1)
 
  

  #geom_segment(data = demand, aes(x = Price, xend = Price, y = 0, yend = Quantity), linetype = "dotted", color = "blue") +geom_segment(data = demand, aes(x = 0, xend = Price, y = Quantity, yend = Quantity), linetype = "dotted", color = "blue") +
```


### [**3. Shifts in the demand curve**]{style="color: darkgreen"}

|
|

::: {style="text-align: centre;"}
[**Change in the quantity demanded *versus* change in demand**]{style="color: red;"}
:::

|

::: {style="text-align: justify;"}
-   A quantity demanded is equivalent to the number of units of a good
    that individuals are willing and able to buy at a particular price

-   Change in quantity demanded is a **movement** from one point to another
    point on the same demand curve caused by a change in the price of
    the good.
    
|
|

-   Change in demand refers to a **shift** in the demand curve.

-   An increase in demand will case a right shift in the demand curve
    (**see graph 1**); and decrease in demand will cause the leftward
    shift in the demand curve (see **graph 2**).
:::

| 
| 

#### [***Graph 1***]{style="color: red"}

```{r}
demand <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(75, 70, 65, 60, 55, 50, 45),
  Quantity2= c(85, 80, 75, 70, 65, 60, 55),
  Quantity3= c(65, 60, 55, 50, 45, 40, 35),
  Point = c("A", "B", "C", "D", "E", "F", "G"),
  Point2 = c("A1", "B1", "C1", "D1", "E1", "F1", "G1"),
  Point3 = c("A0", "B0", "C0", "D0", "E0", "F0", "G0")
)

 ggplot() +
  geom_path(data =  demand, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand, aes(y = Price, x = Quantity), color = "blue") +
   geom_text(data = demand,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "blue")+
   geom_path(data =  demand, aes(y = Price, x = Quantity2), color = "red", size = 1, linetype="dashed") +
  geom_point(data = demand, aes(y = Price, x = Quantity2), color = "red") +
    geom_text(data = demand,aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size= 2.5, color = "red")+
  annotate("segment", x = 49, xend = 56,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 73, xend = 79,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("text", x = max(demand$Quantity) +1.5, y = max(demand$Price) - 6, 
           label = "D1", color = "blue", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) + 1.5, y = max(demand$Price) - 6,
           label = "D2", color = "red", size = 5, fontface = "bold")+
  theme_bw()+
  ggtitle("Graph 1: Rightward shift in the Demand Curve")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
    scale_x_continuous(breaks = seq(35, 75,5))+
  scale_y_continuous(breaks = seq(4, 10, 1))+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
  
```

| 
| 

#### [***Graph 2***]{style="color: red"}

```{r}
ggplot() +
  geom_path(data =  demand, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand, aes(y = Price, x = Quantity), color = "blue") +
   geom_text(data = demand,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "blue")+
    
   geom_path(data =  demand, aes(y = Price, x = Quantity3), color = "red", size = 1, linetype="dashed") +
  geom_point(data = demand, aes(y = Price, x = Quantity3), color = "red") +
    geom_text(data = demand,aes(y = Price, x = Quantity3, label = Point3), vjust = -1, size= 2.5, color = "red")+
  annotate("segment", x = 46, xend = 42,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 68, xend = 65,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("text", x = max(demand$Quantity) +1.5, y = max(demand$Price) - 6, 
           label = "D1", color = "blue", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) -18.7, y = max(demand$Price) - 6,
           label = "D0", color = "red", size = 5, fontface = "bold")+
  theme_bw()+
  ggtitle(" Graph 2: Lefttward shift in the Demand Curve")+
  labs(y=" Price (R/1 liter container)", x="Quantity demanded (million containers)")+
       scale_x_continuous(breaks = seq(35, 75,5))+
  scale_y_continuous(breaks = seq(4, 10, 1))+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
```

### [**4. What causes demand shifts**]{style="color:darkgreen"}

::: {style="text-align: justify;"}

|
|

Here are some factors that cause the demand curve to shift:

-   **Income:** as a person's income changes (increases or decreases).
    that individual's demand for a particular good may rise, fall or
    remain constant.

| 
| 

-   **Preferences:** people's preferences affect the amount of a good
    they are willing to buy at a particular price

| 
| 

-   **Prices of related goods:** two goods that are, for example,
    substitutes (coca-cola and pepsi-cola) as the price of one one rises
    (falls) the demand for other rises (falls). 

| 
| 

-   **Number of buyers:** more buyers higher demand; fewer buyers lower
    demand.

| 
| 

-   **Expectation of future prices:** buyers who expect the price of a
    good to be higher next wee may buy it now, thus increasing the
    current demand for the good. Buyers who expect the the price of a
    good to be lower next week, may wait until next week to buy it ,
    thus decreasing the current demand for that good.
:::


### Empty


# **Supply**

## Column {.tabset data-width=250}


### [**What is Supply?**]{style="color: red"}

|
|

::: {style="text-align: justify;"}
-   [**Supply**]{style="color: blue;"} refers to the willingness and
    ability of sellers to produce and offer to sell different quantities
    of a good at different prices during a specific time period.

| 
| 

[**The Law of Supply**]{style="color: red;"}

-   As the price of a good rises, the quantity supplied of the good
    rises, and as the price of a good falls, the quantity supplied of
    the good falls, *ceteris paribus* (PS:Class, provide examples to
    get points)

-   The law of supply can be represented in a [**supply
    schedule**]{style="color: blue;"} (the numerical tabulation of the
    quantity supplied of a good at different prices) and as a [**supply
    curve**]{style="color: blue;"} (the graphical representation of the
    law of supply)
:::

| 
| 

## Column {.tabset}

### [**1. Supply Schedule**]{style="color: darkgreen;"}

|
|
|
|

 Below is the supply schedule for milk
 
|
|

| **Price**(R/1 liter container) | Qty supplied (million containers) | Point |
|:------------------------------:|:---------------------------------:|:-----:|
|               10               |                90                 |   A   |
|               9                |                80                 |   B   |
|               8                |                70                 |   C   |
|               7                |                60                 |   D   |
|               6                |                50                 |   E   |
|               5                |                40                 |   F   |
|               4                |                30                 |   G   |

| 
| 

### [**2. Supply curve**]{style="color: darkgreen;"}

```{r}
supply_i<- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(30, 40, 50, 60, 70, 80, 90),
  Point = c("A", "B", "C", "D", "E", "F", "G")
)

# Plot supply curves with dotted lines
s1 <- ggplot() +
  geom_path(data =  supply_i, aes(y = Price, x = Quantity), color = "darkgreen", size = 1) +
  geom_point(data = supply_i, aes(y = Price, x = Quantity), color = "darkgreen") +
  theme_bw()+
  ggtitle(" Supply Curve")+
  labs(y="Price (R/1 liter container)", x="Qty supplied (million containers)")+
   scale_x_continuous(breaks = seq(30, 90,10))+
  scale_y_continuous(breaks = seq(4, 10, 1))+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
ggplotly(s1)
 
  

  #geom_segment(data = demand, aes(x = Price, xend = Price, y = 0, yend = Quantity), linetype = "dotted", color = "blue") +
 # geom_segment(data = demand, aes(x = 0, xend = Price, y = Quantity, yend = Quantity), linetype = "dotted", color = "blue")
  
    
```

### [**3. Shifts in the supply curve**]{style="color: darkgreen;"}

|
|

[**Change in the quantity supplied *versus* change in supply**
]{style="color: red;"}

::: {style="text-align: justify;"}
-   Change in supply is not the same as a change in the quantity
    supplied
    
* Change in quantity supplied refers to a **movement along** a given
supply curve (price driven)

|

-   A change in supply refers to a **shift** in the supply curve

-   An increase in supply will cause a rightward shift in the demand
    curve (**see graph 1**); Conversely, a decrease in supply will cause
    a leftward shift in the supply curve (see **graph 2**)
:::

| 
| 

#### [***Graph 1***]{style="color: red"}

```{r}
supply<- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
 Quantity = c(30, 40, 50, 60, 70, 80, 90),
 Quantity2= c(40, 50, 60, 70, 80, 90, 100),
  Quantity3= c(20,30, 40, 50, 60, 70, 80),
 Point = c("A", "B", "C", "D", "E", "F", "G"),
  Point2 = c("A1", "B1", "C1", "D1", "E1", "F1", "G1"),
  Point3 = c("A0", "B0", "C0", "D0", "E0", "F0", "G0")
)

 ggplot() +
  geom_path(data =  supply, aes(y = Price, x = Quantity), color = "#006600", size = 1) +
  geom_point(data = supply, aes(y = Price, x = Quantity), color = "#006600") +
   geom_text(data = supply,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "#006600")+
   geom_path(data =  supply, aes(y = Price, x = Quantity2), color = "orange", size = 1, linetype="dashed")+
  geom_point(data = supply, aes(y = Price, x = Quantity2), color = "orange") +
    geom_text(data = supply,aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size= 2.5, color = "orange")+
  annotate("segment", x = 87, xend = 92,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 38, xend = 43,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("text", x = max(demand$Quantity) -42.5, y = max(demand$Price) -6, 
           label = "S1", color = "#006600", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) -42, y = max(demand$Price) -6,
           label = "S2", color = "orange", size = 5, fontface = "bold")+
  theme_bw()+
   scale_x_continuous(breaks = seq(20, 100,5))+
  scale_y_continuous(breaks = seq(4, 12, 1))+
  ggtitle("Rightward shift in the Supply Curve")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
  
```

| 
| 

#### [***Graph 2***]{style="color: red"}

```{r}
 ggplot() +
  geom_path(data =  supply, aes(y = Price, x = Quantity), color = "#006600", size = 1) +
  geom_point(data = supply, aes(y = Price, x = Quantity), color = "#006600") +
   geom_text(data = supply,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "#006600")+
   geom_path(data =  supply, aes(y = Price, x = Quantity3), color = "orange", size = 1, linetype = "dashed") +
  geom_point(data = supply, aes(y = Price, x = Quantity3), color = "orange") +
    geom_text(data = supply,aes(y = Price, x = Quantity3, label = Point3), vjust = -1, size= 2.5, color = "orange")+
  theme_bw()+
  annotate("segment", x = 83, xend = 78,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 33, xend = 28,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
  annotate("text", x = max(demand$Quantity) -42.5, y = max(demand$Price) - 6, 
           label = "S1", color = "#006600", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) -62, y = max(demand$Price) - 6,
           label = "S0", color = "orange", size = 5, fontface = "bold")+
   scale_x_continuous(breaks = seq(20, 100,5))+
  scale_y_continuous(breaks = seq(4, 12, 1))+
  ggtitle("Lefttward shift in the Supply Curve")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
```



### [**4. What causes supply shifts**]{style="color:darkgreen"}

|
|
|

::: {style="text-align: justify;"}
There are many factors that cause the demand curve to shift. Some of
them are:

| 
| 

-   **Prices of relevant resources:** Resources needed to produce goods.

| 
| 

-   **Technology:** if advance in technology reduces per-unit production
    costs, we expect the quantity supplied of the good at each price to
    increase

| 
| 

-   **Number of sellers:** if more sellers begi to produce a good, the
    supply curve will shift rightward

| 
| 

-   **Expectation of future price:** if a price of a good is expected to
    be higher in the future, producers may hold back some of the
    products today, then they will have more to sell at a higher future
    price

| 
| 

-   **Taxes in Subsidies:** a rough rule of thumb is that we get more of
    what we subsidize and less of what we tax.
:::


### Empty


# **Market equilibrium**


## Column {.tabset data-width=250}

### [**Law of supply and demand**]{style="color: red;"}

::: {style="text-align: justify;"}
* In a free market, the forces of supply and demand tend to push the price toward the level at which quantity supplied and quantity demanded are equal. So demand and supply together establish the equilibrium price (market-clearing price) and equilibrium quantity 

|
|

* Graphically the equilibrium is the intersection point of the demand and supply curves (**see graph 1**)

|
|

* Any price at which quantity demanded is not equal to quantity supplied result in either surplus (excess supply) or shortage (excess demand)

|
|

* Equilibrium price and quantity are determined by supply and demand. Whenever demand changes, supply changes, or both change equilibrium price and quantity change (**see graph 2 and 3**)

:::


## Column {.tabset }

### **Graph 1**

```{r}
# Load necessary libraries
library(ggplot2)
library(dplyr)


# Demand data
demand_i <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(75, 70, 65, 60, 55, 50, 45),
  Point = c("A", "B", "C", "D", "E", "F", "G")
)

# Supply data
supply_i <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(30, 40, 50, 60, 70, 80, 90),
  Point = c("A", "B", "C", "D", "E", "F", "G")
)

# Add type column
demand_i$type <- "Demand"
supply_i$type <- "Supply"

# Combine data
combined_data <- rbind(demand_i, supply_i)

# Plot the data
 ggplot(combined_data, aes(x = Quantity, y = Price, color = type, linetype = type)) +
  geom_line(size = 1) +
  geom_point(size = 3) +
  ggtitle("Demand and supply curves") +
  labs(y = "Price (R/1 liter container)", 
       x = "Quantity demanded (million containers)",
       color = "Legend",          # Update legend title for color
       linetype = "Legend") +    # Update legend title for linetype
  theme_minimal() +
  scale_x_continuous(breaks = seq(20, 90, 10)) +
  scale_y_continuous(breaks = seq(4, 10, 1)) +
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust = 0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust = 1),
        axis.title.y = element_text(size = rel(1), color = "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color = "grey10")) +
  scale_color_manual(values = c("blue", "darkgreen")) +
  scale_linetype_manual(values = c("solid", "solid")) +
  scale_shape_manual(values = c(16, 17))
```



### **Graph 2**


```{r}
ggplot() +
  geom_path(data =  demand, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand, aes(y = Price, x = Quantity), color = "blue") +
   geom_text(data = demand,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "blue")+
   geom_path(data =  demand, aes(y = Price, x = Quantity2), color = "red", size = 1, linetype="dashed") +
  geom_point(data = demand, aes(y = Price, x = Quantity2), color = "red") +
    geom_text(data = demand,aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size= 2.5, color = "red")+
   geom_path(data =  supply_i, aes(y = Price, x = Quantity), color = "darkgreen", size = 1) +
  geom_point(data = supply_i, aes(y = Price, x = Quantity), color = "darkgreen")+
  annotate("segment", x = 49, xend = 56,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 73, xend = 79,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("text", x = max(demand$Quantity) +1.5, y = max(demand$Price) - 6, 
           label = "D1", color = "blue", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) + 1.5, y = max(demand$Price) - 6,
           label = "D2", color = "red", size = 5, fontface = "bold")+
  theme_bw()+
  ggtitle("Supply and shifting demand curves")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
    scale_x_continuous(breaks = seq(35, 75,5))+
  scale_y_continuous(breaks = seq(4, 10, 1))+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
  
 
```



### **Graph 3**

```{r}
 ggplot() +
  geom_path(data =  supply, aes(y = Price, x = Quantity), color = "#006600", size = 1) +
  geom_point(data = supply, aes(y = Price, x = Quantity), color = "#006600") +
   geom_text(data = supply,aes(y = Price, x = Quantity, label = Point), vjust = -1, size= 2.5, color = "#006600")+
   geom_path(data =  supply, aes(y = Price, x = Quantity2), color = "orange", size = 1, linetype="dashed")+
  geom_point(data = supply, aes(y = Price, x = Quantity2), color = "orange") +
    geom_text(data = supply,aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size= 2.5, color = "orange")+
  geom_path(data =  demand_i, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand_i, aes(y = Price, x = Quantity), color = "blue") +
  annotate("segment", x = 87, xend = 92,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("segment", x = 38, xend = 43,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round")+
   annotate("text", x = max(demand$Quantity) -42.5, y = max(demand$Price) -6, 
           label = "S1", color = "#006600", size = 5, fontface = "bold")+
  annotate("text", x = max(demand$Quantity2) -42, y = max(demand$Price) -6,
           label = "S2", color = "orange", size = 5, fontface = "bold")+
  theme_bw()+
   scale_x_continuous(breaks = seq(20, 100,5))+
  scale_y_continuous(breaks = seq(4, 12, 1))+
  ggtitle("Demand and shifting supply curves")+
  labs(y="Price (R/1 liter container)", x="Quantity demanded (million containers)")+
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust=0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust=1),
        axis.title.y = element_text(size = rel(1), color= "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color= "grey10"))
  
```

### **Graph 4**
```{r}
library(ggplot2)

# Create combined data
supply <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(30, 40, 50, 60, 70, 80, 90),
  Quantity2 = c(40, 50, 60, 70, 80, 90, 100),
  Quantity3 = c(20, 30, 40, 50, 60, 70, 80),
  Point = c("A", "B", "C", "D", "E", "F", "G"),
  Point2 = c("A1", "B1", "C1", "D1", "E1", "F1", "G1"),
  Point3 = c("A0", "B0", "C0", "D0", "E0", "F0", "G0")
)

demand <- data.frame(
  Price = c(4, 5, 6, 7, 8, 9, 10),
  Quantity = c(75, 70, 65, 60, 55, 50, 45),
  Quantity2 = c(85, 80, 75, 70, 65, 60, 55),
  Quantity3 = c(65, 60, 55, 50, 45, 40, 35),
  Point = c("A", "B", "C", "D", "E", "F", "G"),
  Point2 = c("A1", "B1", "C1", "D1", "E1", "F1", "G1"),
  Point3 = c("A0", "B0", "C0", "D0", "E0", "F0", "G0")
)

# Create ggplot
ggplot() +
  # Supply curves
  geom_path(data = supply, aes(y = Price, x = Quantity), color = "#006600", size = 1) +
  geom_point(data = supply, aes(y = Price, x = Quantity), color = "#006600") +
  geom_text(data = supply, aes(y = Price, x = Quantity, label = Point), vjust = -1, size = 2.5, color = "#006600") +
  geom_path(data = supply, aes(y = Price, x = Quantity2), color = "orange", size = 1, linetype = "dashed") +
  geom_point(data = supply, aes(y = Price, x = Quantity2), color = "orange") +
  geom_text(data = supply, aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size = 2.5, color = "orange") +
  
  # Demand curves
  geom_path(data = demand, aes(y = Price, x = Quantity), color = "blue", size = 1) +
  geom_point(data = demand, aes(y = Price, x = Quantity), color = "blue") +
  geom_text(data = demand, aes(y = Price, x = Quantity, label = Point), vjust = -1, size = 2.5, color = "blue") +
  geom_path(data = demand, aes(y = Price, x = Quantity2), color = "red", size = 1, linetype = "dashed") +
  geom_point(data = demand, aes(y = Price, x = Quantity2), color = "red") +
  geom_text(data = demand, aes(y = Price, x = Quantity2, label = Point2), vjust = -1, size = 2.5, color = "red") +
  
  # Annotations for the supply curves
  annotate("segment", x = 87, xend = 92,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round") +
  annotate("segment", x = 38, xend = 43,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round") +
  annotate("text", x = max(supply$Quantity) - 58, y = max(supply$Price) - 6,
           label = "S1", color = "#006600", size = 5, fontface = "bold") +
  annotate("text", x = max(supply$Quantity2) - 58, y = max(supply$Price) - 6,
           label = "S2", color = "orange", size = 5, fontface = "bold") +
  
  # Annotations for the demand curves
  annotate("segment", x = 49, xend = 56,
           y = 9.5, yend = 9.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round") +
  annotate("segment", x = 73, xend = 79,
           y = 4.5, yend = 4.5, # Adjusted to be more specific
           arrow = arrow(type = "closed", length = unit(0.1, "inches")),
           color = "grey50", size = 0.9, lineend = "round") +
  annotate("text", x = max(demand$Quantity) + 1.5, y = max(demand$Price) - 6,
           label = "D1", color = "blue", size = 5, fontface = "bold") +
  annotate("text", x = max(demand$Quantity2) + 1.5, y = max(demand$Price) - 6,
           label = "D2", color = "red", size = 5, fontface = "bold") +
  
  # Theme and labels
  theme_bw() +
  scale_x_continuous(breaks = seq(20, 100, 5)) +
  scale_y_continuous(breaks = seq(4, 12, 1)) +
  ggtitle("Demand and supply curves with shifts") +
  labs(y = "Price (R/1 liter container)", x = "Quantity demanded (million containers)", color = "Legend", linetype = "Legend") +
  theme(plot.title = element_text(size = 12, face = "bold", color = "Black", hjust = 0.5),
        axis.text = element_text(colour = "grey10", size = 10, vjust = 1, hjust = 1),
        axis.title.y = element_text(size = rel(1), color = "grey10", angle = 90),
        axis.title.x = element_text(size = rel(1), color = "grey10"))

```


### Empty

:::