Articles by Economics and R - R posts

Puzzling Regression Anatomy

July 1, 2020 | Economics and R - R posts

Consider a regression model with the following causal structure: The variable x1 affects y directly and also indirectly via x2. The following R code implements the model and simulates a corresponding data set. set.seed(1) n = 10000 beta1 = 1; bet... [Read more...]

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...]
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)