Articles by Economics and R - R posts

Analyzing Relational Contracts with R: Part 2

March 2, 2020 | Economics and R - R posts

This post continues my first post on game theoretic analysis with the package RelationalContacts in R. Here we look at more complex infinite horizon games with endogenous states. I also illustrate how one can explicitly combine relational contracting and hold-up concerns. The following code specifies a game with 3 states:
<span class="n">library</span><span class="p">(</span><span class="n">RelationalContracts</span><span class="p">)</span><span class="w">
</span><span class="n">g</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rel_game</span><span class="p">(</span><span class="s2">"Mutual Gift Game with Endogenous Vulnerability"</span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_param</span><span class="p">(</span><span class="n">vul</span><span class="o">=</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="n">delta</span><span class="o">=</span><span class="m">0.3</span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_state</span><span class="p">(</span><span class="s2">"x_0"</span><span class="p">,</span><span class="w">
    </span><span class="n">A1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">list</span><span class="p">(</span><span class="n">move</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="s2">"vul"</span><span class="p">,</span><span class="s2">"not"</span><span class="p">)),</span><span class="w">
    </span><span class="n">pi1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="p">,</span><span class="w">
    </span><span class="n">pi2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="w">
  </span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_transition</span><span class="p">(</span><span class="s2">"x_0"</span><span class="p">,</span><span class="s2">"x_not"</span><span class="p">,</span><span class="n">move</span><span class="o">=</span><span class="s2">"not"</span><span class="p">,</span><span class="n">prob</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1</span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_transition</span><span class="p">(</span><span class="s2">"x_0"</span><span class="p">,</span><span class="s2">"x_vul"</span><span class="p">,</span><span class="n">move</span><span class="o">=</span><span class="s2">"vul"</span><span class="p">,</span><span class="n">prob</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1</span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_state</span><span class="p">(</span><span class="s2">"x_not"</span><span class="p">,</span><span class="w">
    </span><span class="n">A1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">list</span><span class="p">(</span><span class="n">e1</span><span class="o">=</span><span class="n">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="m">0.1</span><span class="p">)),</span><span class="w">
    </span><span class="n">A2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">list</span><span class="p">(</span><span class="n">e2</span><span class="o">=</span><span class="n">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="m">0.1</span><span class="p">)),</span><span class="w">
    </span><span class="n">pi1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">e2</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="m">0.5</span><span class="o">*</span><span class="n">e1</span><span class="o">^</span><span class="m">2</span><span class="p">,</span><span class="w">
    </span><span class="n">pi2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">e1</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="m">0.5</span><span class="o">*</span><span class="n">e2</span><span class="o">^</span><span class="m">2</span><span class="w">
  </span><span class="p">)</span><span class="w"> </span><span class="o">%>%</span><span class="w">
  </span><span class="n">rel_state</span><span class="p">(</span><span class="s2">"x_vul"</span><span class="p">,</span><span class="w">
    </span><span class="n">A1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">list</span><span class="p">(</span><span class="n">e1</span><span class="o">=</span><span class="n">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="m">0.1</span><span class="p">)),</span><span class="w">
    </span><span class="n">A2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">list</span><span class="p">(</span><span class="n">e2</span><span class="o">=~</span><span class="nf">c</span><span class="p">(</span><span class="o">-</span><span class="n">vul</span><span class="p">,</span><span class="n">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="m">0.1</span><span class="p">))),</span><span class="w">
    </span><span class="n">pi1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">e2</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="m">0.5</span><span class="o">*</span><span class="n">e1</span><span class="o">^</span><span class="m">2</span><span class="p">,</span><span class="w">
    </span><span class="n">pi2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">e1</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="m">0.5</span><span class="o">*</span><span class="n">pmax</span><span class="p">(</span><span class="n">e2</span><span class="p">,</span><span class="m">0</span><span class="p">)</span><span class="o">^</span><span class="m">2</span><span class="w">
  </span><span class="p">)</span><span class="w">
</span>
... [Read more...]

Exploring the tightened EU CO2 emission standards for cars in 2020 – Why now selling an electric car can be worth an extra 18000€ for producers.

January 14, 2020 | Economics and R - R posts

In this blog post I want to explore the EU regulation for average CO2 emissions of manufacturer’s car fleets using the EU data set of newly registered cars. The data was already studied on an aggregate level in my earlier post. Here we explore, in particular, the monetary implications ...
[Read more...]

Analyzing Relational Contracts with R: Part I

December 10, 2019 | Economics and R - R posts

One goal of game theory is to understand how effective cooperation can be sustained in relationships. You may have heard of Axelrod’s famous tournaments that studied how effective different submitted strategies are in sustaining cooperation in repeated Prisoners’ dilemma games. A related approach to understand the scope for cooperation ... [Read more...]

Finding Economic Articles With Data

February 22, 2019 | Economics and R - R posts

In my view, one of the greatest developments during the last decade in economics is that the Journals of the American Economic Association and some other leading journals require authors to upload the replication code and data sets of accepted articles. I wrote a Shiny app that allows to search ... [Read more...]

Finding Economic Articles With Data

February 20, 2019 | Economics and R - R posts

In my view, one of the greatest developments during the last decade in economics is that the Journals of the American Economic Association and some other leading journals require authors to upload the replication code and data sets of accepted articles. I wrote a Shiny app that allows to search ... [Read more...]
1 2 3 4

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)