You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h1><spanclass="header-section-number">1</span> Introduction<ahref="1-introduction.html#introduction" class="anchor-section" aria-label="Anchor link to header"></a></h1>
461
461
<hrstyle="background-color:#3C6690;height:2px">
462
-
<p>The interest in the freely available statistical programming language and software environment <tt>R</tt><spanclass="citation">(<ahref="#ref-R-base" role="doc-biblioref">R Core Team 2021</a>)</span> is soaring. By the time we wrote first drafts for this project, more than 11000 add-ons (many of them providing cutting-edge methods) were made available on the Comprehensive <tt>R</tt> Archive Network (<ahref="https://cran.r-project.org/">CRAN</a>), an extensive network of FTP servers around the world that store identical and up-to-date versions of <tt>R</tt> code and its documentation. <tt>R</tt> dominates other (commercial) software for statistical computing in most fields of research in applied statistics. The benefits of it being freely available, open source and having a large and constantly growing community of users that contribute to CRAN render <tt>R</tt> more and more appealing for empirical economists and econometricians alike.</p>
462
+
<p>The interest in the freely available statistical programming language and software environment <tt>R</tt><spanclass="citation">(<ahref="#ref-R-base" role="doc-biblioref">R Core Team 2023</a>)</span> is soaring. By the time we wrote first drafts for this project, more than 11000 add-ons (many of them providing cutting-edge methods) were made available on the Comprehensive <tt>R</tt> Archive Network (<ahref="https://cran.r-project.org/">CRAN</a>), an extensive network of FTP servers around the world that store identical and up-to-date versions of <tt>R</tt> code and its documentation. <tt>R</tt> dominates other (commercial) software for statistical computing in most fields of research in applied statistics. The benefits of it being freely available, open source and having a large and constantly growing community of users that contribute to CRAN render <tt>R</tt> more and more appealing for empirical economists and econometricians alike.</p>
463
463
<p>A striking advantage of using <tt>R</tt> in econometrics is that it enables students to explicitly document their analysis step-by-step such that it is easy to update and to expand. This allows to re-use code for similar applications with different data. Furthermore, <tt>R</tt> programs are fully reproducible, which makes it straightforward for others to comprehend and validate results.</p>
464
-
<p>Over the recent years, <tt>R</tt> has thus become an integral part of the curricula of econometrics classes we teach at the University of Duisburg-Essen. In some sense, learning to code is comparable to learning a foreign language and continuous practice is essential for the learning success. Needless to say, presenting bare <tt>R</tt> code on slides does not encourage the students to engage with hands-on experience on their own. This is why <tt>R</tt> is crucial. As for accompanying literature, there are some excellent books that deal with <tt>R</tt> and its applications to econometrics, e.g., <spanclass="citation">Kleiber and Zeileis (<ahref="#ref-kleiber2008" role="doc-biblioref">2008</a>)</span>. However, such sources may be somewhat beyond the scope of undergraduate students in economics having little understanding of econometric methods and barely any experience in programming at all. Consequently, we started to compile a collection of reproducible reports for use in class. These reports provide guidance on how to implement selected applications from the textbook <em>Introduction to Econometrics</em><spanclass="citation">(<ahref="#ref-stock2015" role="doc-biblioref">Stock and Watson 2015</a>)</span> which serves as a basis for the lecture and the accompanying tutorials. This process was facilitated considerably by <tt>knitr</tt><spanclass="citation">(<ahref="#ref-R-knitr" role="doc-biblioref">Xie 2022</a>)</span> and <tt>R markdown</tt><spanclass="citation">(<ahref="#ref-R-rmarkdown" role="doc-biblioref">Allaire et al. 2022</a>)</span>. In conjunction, both <tt>R</tt> packages provide powerful functionalities for dynamic report generation which allow to seamlessly combine pure text, LaTeX, <tt>R</tt> code and its output in a variety of formats, including PDF and HTML. Moreover, writing and distributing reproducible reports for use in academia has been enriched tremendously by the <tt>bookdown</tt> package <spanclass="citation">(<ahref="#ref-R-bookdown" role="doc-biblioref">Xie 2023</a>)</span> which has become our main tool for this project. <tt>bookdown</tt> builds on top of <tt>R markdown</tt> and allows to create appealing HTML pages like this one, among other things.
464
+
<p>Over the recent years, <tt>R</tt> has thus become an integral part of the curricula of econometrics classes we teach at the University of Duisburg-Essen. In some sense, learning to code is comparable to learning a foreign language and continuous practice is essential for the learning success. Needless to say, presenting bare <tt>R</tt> code on slides does not encourage the students to engage with hands-on experience on their own. This is why <tt>R</tt> is crucial. As for accompanying literature, there are some excellent books that deal with <tt>R</tt> and its applications to econometrics, e.g., <spanclass="citation">Kleiber and Zeileis (<ahref="#ref-kleiber2008" role="doc-biblioref">2008</a>)</span>. However, such sources may be somewhat beyond the scope of undergraduate students in economics having little understanding of econometric methods and barely any experience in programming at all. Consequently, we started to compile a collection of reproducible reports for use in class. These reports provide guidance on how to implement selected applications from the textbook <em>Introduction to Econometrics</em><spanclass="citation">(<ahref="#ref-stock2015" role="doc-biblioref">Stock and Watson 2015</a>)</span> which serves as a basis for the lecture and the accompanying tutorials. This process was facilitated considerably by <tt>knitr</tt><spanclass="citation">(<ahref="#ref-R-knitr" role="doc-biblioref">Xie 2023b</a>)</span> and <tt>R markdown</tt><spanclass="citation">(<ahref="#ref-R-rmarkdown" role="doc-biblioref">Allaire et al. 2023</a>)</span>. In conjunction, both <tt>R</tt> packages provide powerful functionalities for dynamic report generation which allow to seamlessly combine pure text, LaTeX, <tt>R</tt> code and its output in a variety of formats, including PDF and HTML. Moreover, writing and distributing reproducible reports for use in academia has been enriched tremendously by the <tt>bookdown</tt> package <spanclass="citation">(<ahref="#ref-R-bookdown" role="doc-biblioref">Xie 2023a</a>)</span> which has become our main tool for this project. <tt>bookdown</tt> builds on top of <tt>R markdown</tt> and allows to create appealing HTML pages like this one, among other things.
465
465
Being inspired by <em>Using R for Introductory Econometrics</em><spanclass="citation">(<ahref="#ref-heiss2016" role="doc-biblioref">Heiss 2016</a>)</span><ahref="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a> and with this powerful toolkit at hand we wrote up our own empirical companion to <spanclass="citation">Stock and Watson (<ahref="#ref-stock2015" role="doc-biblioref">2015</a>)</span>. The result, which you started to look at, is <em>Introduction to Econometrics with R</em>.</p>
466
466
<p>Similarly to the book by <spanclass="citation">Heiss (<ahref="#ref-heiss2016" role="doc-biblioref">2016</a>)</span>, this project is neither a comprehensive econometrics textbook nor is it intended to be a general introduction to <tt>R</tt>. We feel that Stock and Watson do a great job at explaining the intuition and theory of econometrics, and at any rate better than we could in yet another introductory textbook! <em>Introduction to Econometrics with R</em> is best described as an interactive script in the style of a reproducible research report which aims to provide students with a platform-independent e-learning arrangement by seamlessly intertwining theoretical core knowledge and empirical skills in undergraduate econometrics. Of course, the focus is on empirical applications with <tt>R</tt>. We leave out derivations and proofs wherever we can. Our goal is to enable students not only to learn how results of case studies can be replicated with <tt>R</tt> but we also intend to strengthen their ability in using the newly acquired skills in other empirical applications — immediately within <em>Introduction to Econometrics with R</em>.</p>
467
467
<p>To realize this, each chapter contains interactive <tt>R</tt> programming exercises. These exercises are used as supplements to code chunks that display how previously discussed techniques can be implemented within <tt>R</tt>. They are generated using the <ahref="https://github.com/datacamp/datacamp-light">DataCamp light widget</a> and are backed by an <tt>R</tt> session which is maintained on <ahref="https://www.datacamp.com/home">DataCamp</a>’s servers. You may play around with the example exercise presented below.</p>
<p>Most commonly we display R code together with the generated output in code chunks. As an example, consider the following line of code presented in chunk below. It tells <tt>R</tt> to compute the number of packages available on <tt>CRAN</tt>. The code chunk is followed by the output produced.</p>
473
473
<divclass="sourceCode" id="cb1"><preclass="sourceCode r"><codeclass="sourceCode r"><spanid="cb1-1"><ahref="1-introduction.html#cb1-1" aria-hidden="true" tabindex="-1"></a><spanclass="co"># check the number of R packages available on CRAN</span></span>
<p>Each code chunk is equipped with a button on the outer right hand side which copies the code to your clipboard. This makes it convenient to work with larger code segments in your version of <tt>R</tt>/<em>RStudio</em> or in the widgets presented throughout the book. In the widget above, you may click on <tt>R Console</tt> and type <code>nrow(available.packages(repos = "http://cran.us.r-project.org"))</code> (the command from the code chunk above) and execute it by hitting <em>Enter</em> on your keyboard.<ahref="#fn2" class="footnote-ref" id="fnref2"><sup>2</sup></a></p>
477
477
<p>Note that some lines in the widget are out-commented which ask you to assign a numeric value to a variable and then to print the variable’s content to the console. You may enter your solution approach to <tt>script.R</tt> and hit the button <em>Run</em> in order to get the feedback described further above. In case you do not know how to solve this sample exercise (don’t panic, that is probably why you are reading this), a click on <em>Hint</em> will provide you with some advice. If you still can’t find a solution, a click on <em>Solution</em> will provide you with another tab, <tt>Solution.R</tt> which contains sample solution code. It will often be the case that exercises can be solved in many different ways and <tt>Solution.R</tt> presents what we consider as comprehensible and idiomatic.</p>
478
478
</div>
479
479
<h3>References<ahref="references.html#references" class="anchor-section" aria-label="Anchor link to header"></a></h3>
Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2022. <em><spanclass="nocase">rmarkdown: Dynamic Documents for R</span></em> (version 2.17). <ahref="https://CRAN.R-project.org/package=rmarkdown">https://CRAN.R-project.org/package=rmarkdown</a>.
482
+
Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2023. <em><spanclass="nocase">rmarkdown: Dynamic Documents for R</span></em> (version 2.20). <ahref="https://CRAN.R-project.org/package=rmarkdown">https://CRAN.R-project.org/package=rmarkdown</a>.
Kleiber, C., and A. Zeileis. 2008. <em><span>A</span>pplied <span>E</span>conometrics with <span>R</span></em>. <span>S</span>pringer.
489
489
</div>
490
490
<divid="ref-R-base" class="csl-entry">
491
-
R Core Team. 2021. <em><spanclass="nocase">R: A Language and Environment for Statistical Computing</span></em>. Vienna, Austria: R Foundation for Statistical Computing. <ahref="https://www.R-project.org/">https://www.R-project.org/</a>.
491
+
R Core Team. 2023. <em><spanclass="nocase">R: A Language and Environment for Statistical Computing</span></em>. Vienna, Austria: R Foundation for Statistical Computing. <ahref="https://www.R-project.org/">https://www.R-project.org/</a>.
492
492
</div>
493
493
<divid="ref-stock2015" class="csl-entry">
494
494
Stock, J. H., and M. W. Watson. 2015. <em><span>I</span>ntroduction to <span>E</span>conometrics, <span>T</span>hird <span>U</span>pdate, <span>G</span>lobal <span>E</span>dition</em>. <span>P</span>earson <span>E</span>ducation <span>L</span>imited.
Xie, Yihui. 2022. <em><spanclass="nocase">knitr: A General-Purpose Package for Dynamic Report Generation in R</span></em> (version 1.40). <ahref="https://yihui.org/knitr/">https://yihui.org/knitr/</a>.
501
-
</div>
502
499
<divid="ref-R-bookdown" class="csl-entry">
503
-
———. 2023. <em><spanclass="nocase">bookdown: Authoring Books and Technical Documents with R Markdown</span></em> (version 0.33). <ahref="https://CRAN.R-project.org/package=bookdown">https://CRAN.R-project.org/package=bookdown</a>.
500
+
Xie, Yihui. 2023a. <em><spanclass="nocase">bookdown: Authoring Books and Technical Documents with R Markdown</span></em> (version 0.33). <ahref="https://CRAN.R-project.org/package=bookdown">https://CRAN.R-project.org/package=bookdown</a>.
501
+
</div>
502
+
<divid="ref-R-knitr" class="csl-entry">
503
+
———. 2023b. <em><spanclass="nocase">knitr: A General-Purpose Package for Dynamic Report Generation in R</span></em> (version 1.42). <ahref="https://yihui.org/knitr/">https://yihui.org/knitr/</a>.
0 commit comments