Section #:01

Students must abide by UVic academic regulations and observe standards of scholarly integrity (i.e. no plagiarism or cheating). Therefore, this assignment must be taken individually and not with a friend, classmate, or group. You are also prohibited from sharing any information about the assignment with others. I affirm that I will not give or receive any aid on this assignment and that all work will be my own. name here

When externalities are present but government intervention is not, competitive markets typically fail to maximize social welfare. This is true even though production is efficient (good produced by lowest cost producers) and the goods end up in the hands of the consumers willing and able to make the largest sacrifice to attain. The problem is that the wrong quantity of the good is produced: Efficiency also requires that the opportunity cost of producing the last unit of the good is equal to marginal value. With negative externalities, marginal social cost exceeds marginal value because buyers and sellers fail to account for this negative impact. In theory a per unit tax equal to the marginal external damage can restore social optimality.

In experiment 2 we investigated two treatments: A laissez-faire treatment where the per unit tax is zero, and a government intervention where a per unit tax of $10 (paid by sellers) is imposed. Note that this tax is not optimal, because it is set without knowledge of the damages per unit. However the tax should still increase welfare when compared to what would occur in the absence of a tax.

The point of experiment 2 is to show a simple way governments can increase social welfare when a negative externality is present.

1 (0 marks)

For round 7, plot the Demand, production cost, and Supply with thick lines, bids and asks with thin lines, and mark the observed price and quantity with a dot.

Figure 1: Buyers in Red, Sellers in Blue.  Cost of Production, Supply and Demand (thick), Bids and asks (thin). Price and quantity dot.

Figure 1: Buyers in Red, Sellers in Blue. Cost of Production, Supply and Demand (thick), Bids and asks (thin). Price and quantity dot.

2 (10 marks)

Copy and paste (in your assignment2.R file) the code that created first_plot and rename the copied code second_plot. Add mapping=aes(frame=round_of_ten) to the call to ggplot(). Remove all the filtering of the data used in all of the geoms. e.g. in the first geom_step(), instead of data=filter(supply_and_demand, round_of_ten==7), you would have data=supply_and_demand. Put a copy of your code that creates second_plot in the chunk below.

second_plot <- ggplot(mapping=aes(frame=round_of_ten))+
  geom_step(data=supply_and_demand, 
            mapping=aes(x=q, y=variable, colour=role), 
            direction="vh", lwd=1.25, alpha=.5)+
  geom_step(data=supply_and_demand, 
            mapping=aes(x=q, y=net_of_tax, colour=role),
            direction="vh", lwd=1.25, alpha=.5)+
  geom_step(data=bid_and_ask, 
            mapping=aes(x=q, y=variable, colour=role), 
            direction="vh", alpha=.25)+
  geom_point(data=outcomes,mapping=aes(x=q,y=price),
             colour="black", size=2, alpha=.2)+ 
  facet_grid(treatment~Rounds)+
  theme(axis.title.y = element_text(angle = 0))+
  labs(x=" \n Quantity",y="Price")

Make sure your code runs without error (control enter in your .R file). Then copy and paste the following code into your assignment2.R file, and run it (control enter).

(second_plot <- ggplotly(second_plot)%>%
  animation_opts(1000,transition = 100)%>%
  hide_legend()%>% 
  config(displayModeBar = F))

3 (10 marks)

Insert your animation second_plot below:

Figure 2: Buyers in Red, Sellers in Blue. Cost of Production, Supply and Demand (thick), Bids and asks (thin). Price and quantity dot.

4 (10 marks)

Describe the difference between the prediction (as determined by the intersection of the supply and demand functions) and the results of the experiments (as summarized by the dot at the price and quantity.)

The competitive model does a good job of predicting behaviour in both treatments, perhaps a bit better at predicting price rather than quantity.

5 (5 marks)

Create dataframe realized_welfare by taking dataframe mydf THEN group_by() treatment, Rounds, round_of_ten THEN summarize(realized_mean = mean(profit), realized_sd=sd(profit)). Reading https://r4ds.had.co.nz/transform.html will be helpful for this question.

realized_welfare <- mydf%>%
  group_by(treatment, Rounds, round_of_ten)%>%
  summarise(realized_mean=mean(profit),
            realized_sd=sd(profit))

6 (5 marks)

What is a boxplot? What does it mean to be robust (in the statistical sense?)

A boxplot gives a visual representation of the distribution of a variable. The size of the box gives a measure of how spread out the data is: dispersion. The size of the box is determined by the 25th and 75th percentiles of the data. The line in the middle of the box indicates a “typical” realization of the variable: the median aka 50th percentile. Robust statistics (like percentiles) are not affected by outliers in the data, unlike mean and standard deviation (which are not robust.)

7 (5 marks)

Using data=realized_welfare, ggplot(), geom_jitter() and geom_boxplot() create a boxplot where aes(x=treatment,y=realized_mean). Set alpha=.25 for both geoms, and outlier.shape = NA,fill="red" for geom_boxplot().

8 (5 marks)

Using data=realized_welfare, ggplot(), geom_jitter() and geom_boxplot() create a boxplot where aes(x=treatment,y=realized_sd). Set alpha=.25 for both geoms, and outlier.shape = NA,fill="red" for geom_boxplot().

9 (10 marks)

Create a new dataframe called maximal_welfare by using function get_maximal_welfare() with argument mydf. The function get_maximal_welfare() calculates the maximal welfare that is attainable for each simulation, given the supply, demand in that simulation.

maximal_welfare <- get_maximal_welfare(mydf)

10 (10 marks)

Create a new dataframe all_welfare by performing a full_join() of realized_welfare and maximal_welfare. Using the function mutate() create a new variable \(relative\_efficiency=\frac{realized\_mean}{maximal\_mean}\times 100\).

all_welfare <- full_join(realized_welfare, maximal_welfare)%>%
  mutate(relative_efficiency =realize_mean/maximal_mean*100)

11 (10 marks)

Using dataframe all_welfare create boxplots similar to question 6, but put relative_efficiency on the y axis rather than realized_mean.

12 (10 marks)

Why is relative_efficiency a better measure of the effect of the tax than realized_mean?

Note that each of the markets/simulations differed in terms of the demand, supply, and the number of people. Because of these differences the total amount of surplus that the market would differ, even if we were not looking at the issue of an emissions tax. So we are not really making an “apples to apples” comparison when we look at the realized welfare between the tax and no tax treatments. In contrast, relative efficiency tells us how close the tax got us to the socially optimal outcome, which sidesteps the issue that the the treatments differed beyond the treatment difference.

13 (10 marks)

How would an ideal experiment differ from this experiment? i.e. What limitations hamper our ability to say “emission taxes cause social welfare to increase.”

An ideal experiment would involve the use of parallel universes: every person in the experiment would be in both treatments simultaneously, playing the same role in both treatments. The absolutely only difference between the treatments would be the treatment itself (the tax.) Obviously we do not have access to parallel universes. The next best alternative would be random allocation of subjects into roles in each treatment, where the demand, supply and number of subjects would be identical between treatments. The major limitations we face in these experiments is that 1) I have no idea what number of students will start the experiment and 2) how many will be kicked out along the way because they did not keep up.