<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>R | William Brasic</title><link>https://williambrasic.com/tags/r/</link><atom:link href="https://williambrasic.com/tags/r/index.xml" rel="self" type="application/rss+xml"/><description>R</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Fri, 13 Dec 2024 00:00:00 +0000</lastBuildDate><image><url>https://williambrasic.com/media/icon_hu78c25ba02d6ba5bd1874b4343a6a876d_24431_512x512_fill_lanczos_center_3.png</url><title>R</title><link>https://williambrasic.com/tags/r/</link></image><item><title>Introduction to Econometrics (Fall 2024)</title><link>https://williambrasic.com/teaching/econ_418-518_fall_2024/</link><pubDate>Fri, 13 Dec 2024 00:00:00 +0000</pubDate><guid>https://williambrasic.com/teaching/econ_418-518_fall_2024/</guid><description>&lt;h2 id="course-evaluations">Course Evaluations&lt;/h2>
&lt;p>For the full course evaluations, click here: &lt;a href="https://williambrasic.com/ECON_418-518_Course_Evaluations/ECON_418-518_Course_Evaluations.pdf" target="_blank">Course Evaluations&lt;/a>. Here are a few selected student evaluations:&lt;/p>
&lt;ol>
&lt;li>This was the hardest class I have taken, but the most interesting and relevant to the industry in which I want to pursue a career. The professor was also very understanding and flexible and helped us learn the content in the best way possible.&lt;/li>
&lt;li>I started this course in tears but it ended up becoming one of my favorite classes! It wouldn&amp;rsquo;t have been possible without the professor&amp;rsquo;s support.&lt;/li>
&lt;li>I have never had an instructor grade as quickly or have as much availability to assist students outside of class. Will replied via Slack incredibly fast and always addressed concerns in-class, via D2L announcements, and Slack. All the materials were super well organized, and the syllabus and class schedule was actually true to the class. Deadlines and expectations were very clear.&lt;/li>
&lt;li>Brasic has a lot of promise to become a very strong lecturer and already demonstrates his potential as an academic and professional.&lt;/li>
&lt;li>The professor had a very helpful nature and kind attitude that helped foster a fantastic learning environment.&lt;/li>
&lt;li>Great instructor that genuinely knows and cares about the material and his students.&lt;/li>
&lt;li>I liked how there were so many practical aspects to this course. It is definitely something I brag about to recruiters.&lt;/li>
&lt;li>I liked the difficulty of the class. This was the hardest class I have taken, but the most interesting and relevant to the industry in which I want to pursue a career. The professor was also very understanding and flexible and helped us learn the content in the best way possible.&lt;/li>
&lt;/ol>
&lt;h2 id="welcome">Welcome!&lt;/h2>
&lt;p>This is the course website for &lt;strong>ECON 418-518: Introduction to Econometrics&lt;/strong> at &lt;strong>The University of Arizona&lt;/strong> in-person during the &lt;strong>Fall 2024&lt;/strong> semester. Here, you will be able to access the &lt;strong>lecture slides&lt;/strong>, &lt;strong>homeworks&lt;/strong>, and &lt;strong>exams&lt;/strong> for the entire course along with &lt;strong>R code&lt;/strong> used to teach the language. For the syllabus, click here: &lt;a href="https://williambrasic.com/ECON_418-518_Syllabus/ECON_418-518_Syllabus_20250723.pdf" target="_blank">Syllabus&lt;/a>. For the welcome letter, click here: &lt;a href="https://williambrasic.com/ECON_418-518_Syllabus/ECON_418-518_Welcome_Letter.pdf" target="_blank">Welcome Letter&lt;/a>.&lt;/p>
&lt;p>This course will provide you with a comprehensive introduction to &lt;strong>econometrics&lt;/strong>, a crucial tool for identifying causal effects. We will start by understanding the basics of econometrics and reviewing the essential mathematical concepts necessary for success in this course. Following this, we will delve into the fundamental building blocks of econometrics, focusing on simple and multiple linear regression using ordinary least squares. We will explore the assumptions underlying the linear model, discuss the consequences of violating these assumptions, and learn techniques to address these issues. Additionally, we will go beyond linear regression to cover more advanced econometric estimators.&lt;/p>
&lt;p>In the final third of the course, we will transition to &lt;strong>machine learning&lt;/strong>, a rapidly evolving field that is increasingly influencing econometrics and economics as a whole. We will begin by understanding the core principles and comparing them to traditional econometrics. The remainder of the course will be dedicated to learning some of the most prominent machine learning algorithms.&lt;/p>
&lt;p>Moreover, you will gain proficiency in &lt;strong>R&lt;/strong>, a powerful language and environment for statistical computing and graphics. R is widely used by economists and statisticians, and developing expertise in it will be a valuable asset for your resume and career prospects. I strongly encourage you to invest time in mastering R.&lt;/p>
&lt;!-- [Hugo Blox Builder](https://hugoblox.com) is designed to give technical content creators a seamless experience. You can focus on the content and the Hugo Blox Builder which this template is built upon handles the rest. -->
&lt;!-- **Embed videos, podcasts, code, LaTeX math, and even test students!**
On this page, you'll find some examples of the types of technical content that can be rendered with Hugo Blox. -->
&lt;h2 id="lecture-slides">Lecture Slides&lt;/h2>
&lt;p>Below are the &lt;strong>lecture slides&lt;/strong> associated with &lt;em>&lt;strong>Introductory Econometrics: A Modern Approach&lt;/strong>&lt;/em> by Jeffrey M. Wooldridge.&lt;/p>
&lt;ol>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_01_Intro_to_Econometrics.pdf" target="_blank">Introduction to Econometrics&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_Math_Review.pdf" target="_blank">Math Review&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_02_SLR_1.pdf" target="_blank">Simple Linear Regression (SLR)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_Matrix_Algebra_1.pdf" target="_blank">Matrix Algebra&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_03_MLR.pdf" target="_blank">Multiple Linear Regression (MLR)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_04_Inference.pdf" target="_blank">Inference&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_05_Asymptotics.pdf" target="_blank">Asymptotics&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_06_MLR_Model.pdf" target="_blank">MLR Model Selection&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_07_Qual_Info.pdf" target="_blank">Qualitative Information&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_08_Hetero.pdf" target="_blank">Heteroskedasticity&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_09_MLR_Issues.pdf" target="_blank">MLR Issues&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_13_14_Panel.pdf" target="_blank">Panel Data Estimators&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_E/ECON_418-518_E_17_BRM.pdf" target="_blank">Binary Response Models&lt;/a>&lt;/li>
&lt;/ol>
&lt;p>Below are the lecture slides associated with &lt;em>&lt;strong>Introduction to Statistical Learning with Applications in R&lt;/strong>&lt;/em> by Gareth James, Daniela Witten, Trevor Hastie, and Robert Tibshirani.&lt;/p>
&lt;ol>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_ISL/ECON_418-518_ISL_02_Intro_to_ML.pdf" target="_blank">Introduction to Machine Learning&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_ISL/ECON_418-518_ISL_05_RM.pdf" target="_blank">Resampling Methods&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_ISL/ECON_418-518_ISL_06_SE.pdf" target="_blank">Shrinkage Estimators&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Lecture_Slides/ECON_418-518_Lecture_Slides_ISL/ECON_418-518_ISL_08_RF.pdf" target="_blank">Random Forests&lt;/a>&lt;/li>
&lt;/ol>
&lt;h2 id="homeworks">Homeworks&lt;/h2>
&lt;p>Below are the &lt;strong>homeworks&lt;/strong> associated with the course.&lt;/p>
&lt;ol>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_HW/ECON_418-518_HW1_Instructions.pdf" target="_blank">Homework 1 Instructions&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_HW/ECON_418-518_HW2_Instructions.pdf" target="_blank">Homework 2 Instructions&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_HW/ECON_418-518_HW3_Instructions.pdf" target="_blank">Homework 3 Instructions&lt;/a>&lt;/li>
&lt;/ol>
&lt;h2 id="exams">Exams&lt;/h2>
&lt;p>Below are the &lt;strong>exams&lt;/strong> associated with the course.&lt;/p>
&lt;ol>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Exams/ECON_418-518_Exam_1.pdf" target="_blank">Exam 1&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Exams/ECON_418-518_Exam_2.pdf" target="_blank">Exam 2&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_Exams/ECON_418-518_Exam_3.pdf" target="_blank">Exam 3&lt;/a>&lt;/li>
&lt;/ol>
&lt;h2 id="r-code">R Code&lt;/h2>
&lt;p>Below are the &lt;strong>R codes&lt;/strong> associated with the course.&lt;/p>
&lt;ol>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_R_Tutorial_1.html" target="_blank">R Tutorial&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_Math_Review_Code.html" target="_blank">Math Review&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_02_SLR_Code.html" target="_blank">Simple Linear Regression (SLR)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_Matrix_Algebra_Code.html" target="_blank">Matrix Algebra&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_03_MLR_Code.html" target="_blank">Multiple Linear Regression (MLR)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_04_Inference_Code.html" target="_blank">Inference&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_05_Asymptotics_Code.html" target="_blank">Asymptotics&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_06_MLR_Model_Code.html" target="_blank">MLR Model Selection&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_07_Qual_Info_Code.html" target="_blank">Qualitative Information&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_08_Hetero_Code.html" target="_blank">Heteroskedasticity&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_09_MLR_Issues_Code.html" target="_blank">MLR Issues&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_13_14_Panel_Code_1.html" target="_blank">Panel Data Estimators&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_E_17_BRM_Code.html" target="_blank">Binary Response Models&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_ISL_05_RM_Code.html" target="_blank">Resampling Methods&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_ISL_06_SE_Code.html" target="_blank">Shrinkage Estimators&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://williambrasic.com/ECON_418-518_R_Code/ECON_418-518_ISL_08_RF_Code.html" target="_blank">Random Forests&lt;/a>&lt;/li>
&lt;/ol>
&lt;!--
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
&lt;iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/D2vj0WcvH5c?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
>&lt;/iframe>
&lt;/div>
**Youtube**:
{{&lt; youtube w7Ft2ymGmfc >}}
**Bilibili**:
{{&lt; bilibili id="BV1WV4y1r7DF" >}}
**Video file**
Videos may be added to a page by either placing them in your `assets/media/` media library or in your [page's folder](https://gohugo.io/content-management/page-bundles/), and then embedding them with the _video_ shortcode:
{{&lt; video src="my_video.mp4" controls="yes" >}}
## Podcast
You can add a podcast or music to a page by placing the MP3 file in the page's folder or the media library folder and then embedding the audio on your page with the _audio_ shortcode:
{{&lt; audio src="ambient-piano.mp3" >}}
Try it out:
&lt;audio controls >
&lt;source src="ambient-piano.mp3" type="audio/mpeg">
&lt;/audio>
## Test students
Provide a simple yet fun self-assessment by revealing the solutions to challenges with the `spoiler` shortcode:
```markdown
{{&lt; spoiler text="👉 Click to view the solution" >}}
You found me!
{{&lt; /spoiler >}}
```
renders as
&lt;details class="spoiler " id="spoiler-2">
&lt;summary class="cursor-pointer">👉 Click to view the solution&lt;/summary>
&lt;div class="rounded-lg bg-neutral-50 dark:bg-neutral-800 p-2">
You found me 🎉
&lt;/div>
&lt;/details>
## Math
Hugo Blox Builder supports a Markdown extension for $\LaTeX$ math. You can enable this feature by toggling the `math` option in your `config/_default/params.yaml` file.
To render _inline_ or _block_ math, wrap your LaTeX math with `{{&lt; math >}}$...${{&lt; /math >}}` or `{{&lt; math >}}$$...$${{&lt; /math >}}`, respectively.
&lt;div class="flex px-4 py-3 mb-6 rounded-md bg-primary-100 dark:bg-primary-900">
&lt;span class="pr-3 pt-1 text-primary-600 dark:text-primary-300">
&lt;svg height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">&lt;path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m11.25 11.25l.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0a9 9 0 0 1 18 0m-9-3.75h.008v.008H12z"/>&lt;/svg>
&lt;/span>
&lt;span class="dark:text-neutral-300">We wrap the LaTeX math in the Hugo Blox &lt;em>math&lt;/em> shortcode to prevent Hugo rendering our math as Markdown.&lt;/span>
&lt;/div>
Example **math block**:
```latex
{{&lt; math >}}
$$
\gamma_{n} = \frac{ \left | \left (\mathbf x_{n} - \mathbf x_{n-1} \right )^T \left [\nabla F (\mathbf x_{n}) - \nabla F (\mathbf x_{n-1}) \right ] \right |}{\left \|\nabla F(\mathbf{x}_{n}) - \nabla F(\mathbf{x}_{n-1}) \right \|^2}
$$
{{&lt; /math >}}
```
renders as
$$\gamma_{n} = \frac{ \left | \left (\mathbf x_{n} - \mathbf x_{n-1} \right )^T \left [\nabla F (\mathbf x_{n}) - \nabla F (\mathbf x_{n-1}) \right ] \right |}{\left \|\nabla F(\mathbf{x}_{n}) - \nabla F(\mathbf{x}_{n-1}) \right \|^2}$$
Example **inline math** `{{&lt; math >}}$\nabla F(\mathbf{x}_{n})${{&lt; /math >}}` renders as $\nabla F(\mathbf{x}_{n})$
.
Example **multi-line math** using the math linebreak (`\\`):
```latex
{{&lt; math >}}
$$f(k;p_{0}^{*}) = \begin{cases}p_{0}^{*} &amp; \text{if }k=1, \\
1-p_{0}^{*} &amp; \text{if }k=0.\end{cases}$$
{{&lt; /math >}}
```
renders as
$$
f(k;p_{0}^{*}) = \begin{cases}p_{0}^{*} &amp; \text{if }k=1, \\
1-p_{0}^{*} &amp; \text{if }k=0.\end{cases}
$$
## Code
Hugo Blox Builder utilises Hugo's Markdown extension for highlighting code syntax. The code theme can be selected in the `config/_default/params.yaml` file.
```python
import pandas as pd
data = pd.read_csv("data.csv")
data.head()
```
renders as
```python
import pandas as pd
data = pd.read_csv("data.csv")
data.head()
```
## Inline Images
```go
{{&lt; icon name="python" >}} Python
```
renders as
&lt;span class="inline-block pr-1">
&lt;svg style="height: 1em; transform: translateY(0.1em);" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512" fill="currentColor">&lt;path d="M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"/>&lt;/svg>
&lt;/span> Python
## Did you find this page helpful? Consider sharing it 🙌 --></description></item></channel></rss>