PageSourceSearch

https://eco-exp2.netlify.app/

html eco-exp2.netlify.app collected 2026-10-03 10:40:38 UTC 301,289 bytes, 2,017 lines download raw bytes

1<!DOCTYPE html>
2<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
3
4<meta charset="utf-8">
5<!-- This site is hosted on Netlify. Anyone can build and deploy a site
6     like this one for free: https://netlify.new/?utm_campaign=loops&utm_source=ai-legible&utm_medium=owned&utm_content=comment&utm_id=9b701030-9d79-47e4-bd90-b1205ad043c0
7     Netlify hosting facts for this site: static/SSR served via Netlify Edge. -->
8<meta name="generator" content="quarto-1.3.313">
9
10<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
11
12<meta name="author" content="Yuan">
13<meta name="dcterms.date" content="2023-04-21">
14
15<title>Experiment 2</title>
16<style>
17code{white-space: pre-wrap;}
18span.smallcaps{font-variant: small-caps;}
19div.columns{display: flex; gap: min(4vw, 1.5em);}
20div.column{flex: auto; overflow-x: auto;}
21div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
22ul.task-list{list-style: none;}
23ul.task-list li input[type="checkbox"] {
24  width: 0.8em;
25  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
26  vertical-align: middle;
27}
28/* CSS for syntax highlighting */
29pre > code.sourceCode { white-space: pre; position: relative; }
30pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
31pre > code.sourceCode > span:empty { height: 1.2em; }
32.sourceCode { overflow: visible; }
33code.sourceCode > span { color: inherit; text-decoration: inherit; }
34div.sourceCode { margin: 1em 0; }
35pre.sourceCode { margin: 0; }
36@media screen {
37div.sourceCode { overflow: auto; }
38}
39@media print {
40pre > code.sourceCode { white-space: pre-wrap; }
41pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
42}
43pre.numberSource code
44  { counter-reset: source-line 0; }
45pre.numberSource code > span
46  { position: relative; left: -4em; counter-increment: source-line; }
47pre.numberSource code > span > a:first-child::before
48  { content: counter(source-line);
49    position: relative; left: -1em; text-align: right; vertical-align: baseline;
50    border: none; display: inline-block;
51    -webkit-touch-callout: none; -webkit-user-select: none;
52    -khtml-user-select: none; -moz-user-select: none;
53    -ms-user-select: none; user-select: none;
54    padding: 0 4px; width: 4em;
55  }
56pre.numberSource { margin-left: 3em;  padding-left: 4px; }
57div.sourceCode
58  {   }
59@media screen {
60pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
61}
62</style>
63
64
65<script src="exp2_files/libs/clipboard/clipboard.min.js"></script>
vendor: 1 bytes, line 65
65
66<script src="exp2_files/libs/quarto-html/quarto.js"></script>
vendor: 1 bytes, line 66
66
67<script src="exp2_files/libs/quarto-html/popper.min.js"></script>
vendor: 1 bytes, line 67
67
68<script src="exp2_files/libs/quarto-html/tippy.umd.min.js"></script>
vendor: 1 bytes, line 68
68
69<script src="exp2_files/libs/quarto-html/anchor.min.js"></script>
69
70<link href="exp2_files/libs/quarto-html/tippy.css" rel="stylesheet">
71<link href="exp2_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
72<script src="exp2_files/libs/bootstrap/bootstrap.min.js"></script>
72
73<link href="exp2_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
74<link href="exp2_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
75<script async="" src="https://hypothes.is/embed.js"></script>
vendor: 1 bytes, line 75
75
76<script type="module" src="exp2_files/libs/quarto-ojs/quarto-ojs-runtime.js"></script>
76
77<link href="exp2_files/libs/quarto-ojs/quarto-ojs.css" rel="stylesheet">
78
79  
79<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
79
80  
80<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
80
81
82<link rel="stylesheet" href="cactus.css">
83</head>
84
85<body>
86
87<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
88<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
89  <nav id="TOC" role="doc-toc" class="toc-active">
90    <h2 id="toc-title">Table of contents</h2>
91   
92  <ul class="collapse">
93  <li><a href="#更新日志" id="toc-更新日志" class="nav-link active" data-scroll-target="#更新日志">更新日志</a></li>
94  <li><a href="#写在前面" id="toc-写在前面" class="nav-link" data-scroll-target="#写在前面">写在前面</a></li>
95  <li><a href="#导入依赖包" id="toc-导入依赖包" class="nav-link" data-scroll-target="#导入依赖包">导入依赖包</a></li>
96  <li><a href="#problem-1likelihood-function" id="toc-problem-1likelihood-function" class="nav-link" data-scroll-target="#problem-1likelihood-function">Problem 1(Likelihood Function)</a>
97  <ul class="collapse">
98  <li><a href="#data-read-and-manipulation" id="toc-data-read-and-manipulation" class="nav-link" data-scroll-target="#data-read-and-manipulation">Data Read and Manipulation</a></li>
99  <li><a href="#ols-estimator" id="toc-ols-estimator" class="nav-link" data-scroll-target="#ols-estimator">OLS Estimator</a></li>
100  <li><a href="#probit-model" id="toc-probit-model" class="nav-link" data-scroll-target="#probit-model">Probit Model</a></li>
101  <li><a href="#logit-model" id="toc-logit-model" class="nav-link" data-scroll-target="#logit-model">Logit Model</a></li>
102  </ul></li>
103  <li><a href="#problem-2seatbelts" id="toc-problem-2seatbelts" class="nav-link" data-scroll-target="#problem-2seatbelts">Problem 2(Seatbelts)</a>
104  <ul class="collapse">
105  <li><a href="#a." id="toc-a." class="nav-link" data-scroll-target="#a.">a.</a></li>
106  <li><a href="#b." id="toc-b." class="nav-link" data-scroll-target="#b.">b.</a></li>
107  <li><a href="#c." id="toc-c." class="nav-link" data-scroll-target="#c.">c.&nbsp;</a></li>
108  <li><a href="#d." id="toc-d." class="nav-link" data-scroll-target="#d.">d.&nbsp;</a></li>
109  <li><a href="#e." id="toc-e." class="nav-link" data-scroll-target="#e.">e.</a></li>
110  <li><a href="#f." id="toc-f." class="nav-link" data-scroll-target="#f.">f.&nbsp;</a></li>
111  <li><a href="#g." id="toc-g." class="nav-link" data-scroll-target="#g.">g.</a></li>
112  </ul></li>
113  <li><a href="#problem-3jec" id="toc-problem-3jec" class="nav-link" data-scroll-target="#problem-3jec">Problem 3(JEC)</a>
114  <ul class="collapse">
115  <li><a href="#a.-1" id="toc-a.-1" class="nav-link" data-scroll-target="#a.-1">a.</a></li>
116  <li><a href="#b.-1" id="toc-b.-1" class="nav-link" data-scroll-target="#b.-1">b.</a></li>
117  <li><a href="#c.-1" id="toc-c.-1" class="nav-link" data-scroll-target="#c.-1">c.&nbsp;</a></li>
118  <li><a href="#d.-1" id="toc-d.-1" class="nav-link" data-scroll-target="#d.-1">d.&nbsp;</a></li>
119  <li><a href="#e.-1" id="toc-e.-1" class="nav-link" data-scroll-target="#e.-1">e.</a></li>
120  <li><a href="#f.-1" id="toc-f.-1" class="nav-link" data-scroll-target="#f.-1">f.&nbsp;</a></li>
121  </ul></li>
122  <li><a href="#problem-4movies" id="toc-problem-4movies" class="nav-link" data-scroll-target="#problem-4movies">Problem 4(Movies)</a>
123  <ul class="collapse">
124  <li><a href="#a.-2" id="toc-a.-2" class="nav-link" data-scroll-target="#a.-2">a.</a></li>
125  <li><a href="#b.-2" id="toc-b.-2" class="nav-link" data-scroll-target="#b.-2">b.</a></li>
126  <li><a href="#c.-2" id="toc-c.-2" class="nav-link" data-scroll-target="#c.-2">c.&nbsp;</a></li>
127  <li><a href="#d.-2" id="toc-d.-2" class="nav-link" data-scroll-target="#d.-2">d.&nbsp;</a></li>
128  <li><a href="#e.-2" id="toc-e.-2" class="nav-link" data-scroll-target="#e.-2">e.</a></li>
129  <li><a href="#f.-2" id="toc-f.-2" class="nav-link" data-scroll-target="#f.-2">f.&nbsp;</a></li>
130  </ul></li>
131  <li><a href="#problem-5fertility" id="toc-problem-5fertility" class="nav-link" data-scroll-target="#problem-5fertility">Problem 5(Fertility)</a>
132  <ul class="collapse">
133  <li><a href="#a.-3" id="toc-a.-3" class="nav-link" data-scroll-target="#a.-3">a.</a></li>
134  <li><a href="#b.-3" id="toc-b.-3" class="nav-link" data-scroll-target="#b.-3">b.</a></li>
135  <li><a href="#c.-3" id="toc-c.-3" class="nav-link" data-scroll-target="#c.-3">c.&nbsp;</a></li>
136  <li><a href="#d.-3" id="toc-d.-3" class="nav-link" data-scroll-target="#d.-3">d.&nbsp;</a></li>
137  <li><a href="#e.-3" id="toc-e.-3" class="nav-link" data-scroll-target="#e.-3">e.</a></li>
138  <li><a href="#f.-3" id="toc-f.-3" class="nav-link" data-scroll-target="#f.-3">f.&nbsp;</a></li>
139  <li><a href="#g.-1" id="toc-g.-1" class="nav-link" data-scroll-target="#g.-1">g.</a></li>
140  </ul></li>
141  <li><a href="#problem-6weakiv" id="toc-problem-6weakiv" class="nav-link" data-scroll-target="#problem-6weakiv">Problem 6(WeakIV)</a>
142  <ul class="collapse">
143  <li><a href="#a.-4" id="toc-a.-4" class="nav-link" data-scroll-target="#a.-4">a.</a></li>
144  <li><a href="#b.-4" id="toc-b.-4" class="nav-link" data-scroll-target="#b.-4">b.</a></li>
145  <li><a href="#c.-4" id="toc-c.-4" class="nav-link" data-scroll-target="#c.-4">c.&nbsp;</a></li>
146  <li><a href="#d.-4" id="toc-d.-4" class="nav-link" data-scroll-target="#d.-4">d.&nbsp;</a></li>
147  </ul></li>
148  <li><a href="#problem-7names" id="toc-problem-7names" class="nav-link" data-scroll-target="#problem-7names">Problem 7(Names)</a>
149  <ul class="collapse">
150  <li><a href="#附加说明" id="toc-附加说明" class="nav-link" data-scroll-target="#附加说明">附加说明</a></li>
151  <li><a href="#a.-5" id="toc-a.-5" class="nav-link" data-scroll-target="#a.-5">a.</a></li>
152  <li><a href="#b.-5" id="toc-b.-5" class="nav-link" data-scroll-target="#b.-5">b.</a></li>
153  <li><a href="#c.-5" id="toc-c.-5" class="nav-link" data-scroll-target="#c.-5">c.&nbsp;</a></li>
154  <li><a href="#d.-5" id="toc-d.-5" class="nav-link" data-scroll-target="#d.-5">d.&nbsp;</a></li>
155  </ul></li>
156  <li><a href="#结语" id="toc-结语" class="nav-link" data-scroll-target="#结语">结语</a></li>
157  </ul>
158</nav>
159</div>
160<main class="content" id="quarto-document-content">
161<script type="text/javascript" src="https://latest.cactus.chat/cactus.js"></script>
161
162
163<link rel="stylesheet" href="https://latest.cactus.chat/style.css" type="text/css">
164
165<script>
166initComments({
167  node: document.getElementById('comment-section'),
168  defaultHomeserverUrl: 'https://matrix.cactus.chat:8448',
169  serverName: 'cactus.chat',
170  siteName: 'zzzzorange-eco-exp2',
171  commentSectionId: 'section1'
172})
173</script>
173
174
175
176<header id="title-block-header" class="quarto-title-block default">
177<div class="quarto-title">
178<h1 class="title">Experiment 2</h1>
179</div>
180
181
182
183<div class="quarto-title-meta">
184
185    <div>
186    <div class="quarto-title-meta-heading">Author</div>
187    <div class="quarto-title-meta-contents">
188             <p>Yuan </p>
189          </div>
190  </div>
191    
192    <div>
193    <div class="quarto-title-meta-heading">Published</div>
194    <div class="quarto-title-meta-contents">
195      <p class="date">April 21, 2023</p>
196    </div>
197  </div>
198  
199    <div>
200    <div class="quarto-title-meta-heading">Modified</div>
201    <div class="quarto-title-meta-contents">
202      <p class="date-modified">May 20, 2023</p>
203    </div>
204  </div>
205    
206  </div>
207  
208
209</header>
210
211<section id="更新日志" class="level1">
212<h1>更新日志</h1>
213<ul>
214<li>2023-4-26: 修改第七题</li>
215</ul>
216</section>
217<section id="写在前面" class="level1">
218<h1>写在前面</h1>
219<section id="介绍" class="level2 unnumbered unlisted">
220<h2 class="unnumbered unlisted anchored" data-anchor-id="介绍">介绍</h2>
221<p>同学们好,以下是中级计量经济学第二次实验的参考,完全由本人制作。其中除了第一题以外,涉及统计学、计量经济学知识的部分,由于本人水平有限,无法保证完全正确。仅供同学们学习参考。如果你有任何问题或者发现了哪里有错,可以在右边用<em>Hypothesis</em>标注并评论,与大家一同讨论,或者私下联系我。我会在看到的第一时间回复你的!</p>
222</section>
223<section id="感受" class="level2 unnumbered unlisted">
224<h2 class="unnumbered unlisted anchored" data-anchor-id="感受">感受</h2>
225<p>写完一遍这次实验下来,感觉还是收获颇多。还是有很多细节需要多多琢磨,从R语言,到统计学、计量经济学的知识,不管是假设检验部分,logit/probit 部分,TSLS部分,还是作图、做表方面都有很多考究,日后还是要多多研究。希望同学们可以抱着多多学习交流,认真仔细钻研每道题的心态来做这次的实验内容。</p>
226<p>关于需要耗费的时间。如果是单纯分析问题,可能2-7题每道题需要两个小时左右,加上思考代码结构、思考如何作图作表,我个人花了两周的时间(几乎每天的主要精力都在研究本次实验),在无聊时拿起来想一想这些问题,也是趣味颇多的一件事情(相比于我的室友那令人痛苦的<em>信号与系统</em>云云,我觉得思考计量问题还是挺怡然自得的)。</p>
227<p>日后我还会对内容稍加修改,包括纠错、增加讲解之类的。还是那句话,希望同学们多多交流!</p>
228</section>
229</section>
230<section id="导入依赖包" class="level1">
231<h1>导入依赖包</h1>
232<div class="cell">
233<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># input libraries</span></span>
234<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(gmodels)</span>
235<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(officedown)</span>
236<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(car)</span>
237<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr)</span>
238<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
239<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(readxl)</span>
240<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(flextable)</span>
241<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(stats4)</span>
242<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(plm)</span>
243<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(patchwork)</span>
244<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sjPlot)</span>
245<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(AER)</span>
246<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(magrittr)</span>
247<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(infer)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
248</div>
249<div class="cell">
250
251<style type="text/css">
252table {
253    margin-right: auto;
254    margin-left: auto;
255}
256</style>
257</div>
258</section>
259<section id="problem-1likelihood-function" class="level1">
260<h1>Problem 1(Likelihood Function)</h1>
261<section id="data-read-and-manipulation" class="level2">
262<h2 class="anchored" data-anchor-id="data-read-and-manipulation">Data Read and Manipulation</h2>
263<p>The <code>xlsx</code> data can be read with <code>readxl</code> library. Then it is convert to matrix, split by x and y,</p>
264<div class="cell">
265<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>hmda <span class="ot">&lt;-</span> <span class="fu">read_xlsx</span>(<span class="st">"data/hmda_sw.xlsx"</span>)</span>
266<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>hmda <span class="ot">&lt;-</span> hmda <span class="sc">%&gt;%</span></span>
267<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(</span>
268<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>    <span class="at">black =</span> <span class="fu">ifelse</span>(s13 <span class="sc">==</span> <span class="dv">3</span>, <span class="dv">1</span>, <span class="dv">0</span>),</span>
269<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>    <span class="at">deny =</span> <span class="fu">ifelse</span>(s7 <span class="sc">==</span> <span class="dv">3</span>, <span class="dv">1</span>, <span class="dv">0</span>),</span>
270<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>    <span class="at">PI =</span> s46 <span class="sc">/</span> <span class="dv">100</span>,</span>
271<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>    <span class="at">hse_inc =</span> s45 <span class="sc">/</span> <span class="dv">100</span>,</span>
272<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>    <span class="at">loan_val =</span> s6 <span class="sc">/</span> s50,</span>
273<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a>    <span class="at">ccred =</span> s43,</span>
274<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>    <span class="at">mcred =</span> s42,</span>
275<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a>    <span class="at">pubrec =</span> <span class="dv">1</span> <span class="sc">*</span> (s44 <span class="sc">&gt;</span> <span class="dv">0</span>),</span>
276<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a>    <span class="at">denpmi =</span> <span class="dv">1</span> <span class="sc">*</span> (s53 <span class="sc">==</span> <span class="dv">1</span>),</span>
277<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a>    <span class="at">selfemp =</span> <span class="dv">1</span> <span class="sc">*</span> (s27a <span class="sc">==</span> <span class="dv">1</span>),</span>
278<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a>    <span class="at">married =</span> <span class="dv">1</span> <span class="sc">*</span> (s23a <span class="sc">==</span> <span class="st">"M"</span>),</span>
279<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a>    <span class="at">single =</span> <span class="dv">1</span> <span class="sc">*</span> (married <span class="sc">==</span> <span class="dv">0</span>),</span>
280<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a>    <span class="at">hischl =</span> <span class="dv">1</span> <span class="sc">*</span> (school <span class="sc">&gt;=</span> <span class="dv">12</span>),</span>
281<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a>    <span class="at">probunmp =</span> uria,</span>
282<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a>    <span class="at">condo =</span> <span class="dv">1</span> <span class="sc">*</span> (s51 <span class="sc">==</span> <span class="dv">1</span>)</span>
283<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a>  )</span>
284<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a></span>
285<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a><span class="co">#   deop the unused colomns</span></span>
286<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a>hmda <span class="ot">&lt;-</span> hmda <span class="sc">%&gt;%</span></span>
287<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(</span>
288<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a>    black, deny, PI, hse_inc,</span>
289<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a>
289    loan_val, ccred, mcred, pubrec,</span>
290<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a>    denpmi, selfemp, married, single,</span>
291<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a>    hischl, probunmp, condo</span>
292<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a>  )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
293</div>
294<p>Gene rate loan-to-value ration with 3 levels(<em>high</em> if <em>loan_val</em> &gt; 0.95, <em>low</em> if <em>loan_val</em> &lt; 0.8, <em>medium</em> otherwise)</p>
295<div class="cell">
296<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>hmda <span class="ot">&lt;-</span> hmda <span class="sc">%&gt;%</span></span>
297<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(</span>
298<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>    <span class="at">lvratmedium =</span> <span class="fu">ifelse</span>(loan_val <span class="sc">&gt;=</span> <span class="fl">0.8</span> <span class="sc">&amp;</span> loan_val <span class="sc">&lt;=</span> <span class="fl">0.95</span>, <span class="dv">1</span>, <span class="dv">0</span>),</span>
299<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>    <span class="at">lvrathigh =</span> <span class="fu">ifelse</span>(loan_val <span class="sc">&gt;</span> <span class="fl">0.95</span>, <span class="dv">1</span>, <span class="dv">0</span>)</span>
300<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>  )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
301</div>
302</section>
303<section id="ols-estimator" class="level2">
304<h2 class="anchored" data-anchor-id="ols-estimator">OLS Estimator</h2>
305<div class="cell">
306<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(hmda)</span>
307<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>mod.deny <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
308<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>  deny <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> black <span class="sc">+</span> PI <span class="sc">+</span> hse_inc <span class="sc">+</span> lvratmedium <span class="sc">+</span> lvrathigh <span class="sc">+</span></span>
309<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>    ccred <span class="sc">+</span> mcred <span class="sc">+</span> pubrec <span class="sc">+</span> denpmi <span class="sc">+</span> selfemp</span>
310<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a>)</span>
311<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(hmda)</span>
312<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a>coef <span class="ot">&lt;-</span> mod.deny<span class="sc">$</span>coefficients</span>
313<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a>coef_from_textbook <span class="ot">&lt;-</span> <span class="fu">c</span>(</span>
314<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>  <span class="sc">-</span><span class="fl">0.183</span>, <span class="fl">0.084</span>, <span class="fl">0.449</span>, <span class="sc">-</span><span class="fl">0.048</span>, <span class="fl">0.031</span>, <span class="fl">0.189</span>, <span class="fl">0.031</span>,</span>
315<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a>  <span class="fl">0.021</span>, <span class="fl">0.197</span>, <span class="fl">0.702</span>, <span class="fl">0.060</span></span>
316<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a>)</span>
317<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a>coef_comp <span class="ot">&lt;-</span> <span class="fu">tibble</span>(<span class="at">name =</span> <span class="fu">names</span>(coef), <span class="at">coef =</span> coef, <span class="at">coef_book =</span> coef_from_textbook) <span class="sc">%&gt;%</span></span>
318<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">coef =</span> <span class="fu">round</span>(coef, <span class="dv">3</span>))</span>
319<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a>coef_comp <span class="sc">%&gt;%</span></span>
320<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a>  <span class="fu">flextable</span>() <span class="sc">%&gt;%</span></span>
321<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a>  <span class="fu">align</span>(<span class="at">part =</span> <span class="st">"header"</span>, <span class="at">align =</span> <span class="st">"center"</span>) <span class="sc">%&gt;%</span></span>
322<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a>  <span class="fu">bold</span>(<span class="at">part =</span> <span class="st">"header"</span>) <span class="sc">%&gt;%</span></span>
323<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a>  <span class="fu">autofit</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
324<div class="cell-output-display">
325<div id="tbl-hmda_ols" class="anchored">
326
327<div class="tabwid"><style>.cl-1622e8d8{}.cl-161ac784{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}
327.cl-161ac798{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-161e04da{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-161e04e4{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-161e04e5{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-161e1a92{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1a93{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1a9c{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1a9d{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1aa6{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1aa7{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1aa8{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ab0{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1aba{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1abb{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1abc{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1abd{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ac4{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ace{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1acf{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ad0{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ad8{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ad9{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ada{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ae2{width:0.718in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-161e1ae3{width:1.049in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1622e8d8"><caption>Table&nbsp;1:  <p>
327HMDA coefficients of OLS comparison</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-161e1a92"><p class="cl-161e04da"><span class="cl-161ac784">name</span></p></th><th class="cl-161e1a93"><p class="cl-161e04da"><span class="cl-161ac784">coef</span></p></th><th class="cl-161e1a9c"><p class="cl-161e04da"><span class="cl-161ac784">coef_book</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-161e1a9d"><p class="cl-161e04e4"><span class="cl-161ac798">(Intercept)</span></p></td><td class="cl-161e1aa6"><p class="cl-161e04e5"><span class="cl-161ac798">-0.183</span></p></td><td class="cl-161e1aa7"><p class="cl-161e04e5"><span class="cl-161ac798">-0.183</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1aa8"><p class="cl-161e04e4"><span class="cl-161ac798">black</span></p></td><td class="cl-161e1ab0"><p class="cl-161e04e5"><span class="cl-161ac798">0.084</span></p></td><td class="cl-161e1aba"><p class="cl-161e04e5"><span class="cl-161ac798">0.084</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1aa8"><p class="cl-161e04e4"><span class="cl-161ac798">PI</span></p></td><td class="cl-161e1ab0"><p class="cl-161e04e5"><span class="cl-161ac798">0.449</span></p></td><td class="cl-161e1aba"><p class="cl-161e04e5"><span class="cl-161ac798">0.449</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1abb"><p class="cl-161e04e4"><span class="cl-161ac798">hse_inc</span></p></td><td class="cl-161e1abc"><p class="cl-161e04e5"><span class="cl-161ac798">-0.048</span></p></td><td class="cl-161e1abd"><p class="cl-161e04e5"><span class="cl-161ac798">-0.048</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1ac4"><p class="cl-161e04e4"><span class="cl-161ac798">lvratmedium</span></p></td><td class="cl-161e1ace"><p class="cl-161e04e5"><span class="cl-161ac798">0.031</span></p></td><td class="cl-161e1acf"><p class="cl-161e04e5"><span class="cl-161ac798">0.031</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1ad0"><p class="cl-161e04e4"><span class="cl-161ac798">lvrathigh</span></p></td><td class="cl-161e1ad8"><p class="cl-161e04e5"><span class="cl-161ac798">0.189</span></p></td><td class="cl-161e1ad9"><p class="cl-161e04e5"><span class="cl-161ac798">0.189</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1ac4"><p class="cl-161e04e4"><span class="cl-161ac798">ccred</span></p></td><td class="cl-161e1ace"><p class="cl-161e04e5"><span class="cl-161ac798">0.031</span></p></td><td class="cl-161e1acf"><p class="cl-161e04e5"><span class="cl-161ac798">0.031</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1aa8"><p class="cl-161e04e4"><span class="cl-161ac798">mcred</span></p></td><td class="cl-161e1ab0"><p class="cl-161e04e5"><span class="cl-161ac798">0.021</span></p></td><td class="cl-161e1aba"><p class="cl-161e04e5"><span class="cl-161ac798">0.021</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1abb"><p class="cl-161e04e4"><span class="cl-161ac798">pubrec</span></p></td><td class="cl-161e1abc"><p class="cl-161e04e5"><span class="cl-161ac798">0.197</span></p></td><td class="cl-161e1abd"><p class="cl-161e04e5"><span class="cl-161ac798">0.197</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1abb"><p class="cl-161e04e4"><span class="cl-161ac798">denpmi</span></p></td><td class="cl-161e1abc"><p class="cl-161e04e5"><span class="cl-161ac798">0.702</span></p></td><td class="cl-161e1abd"><p class="cl-161e04e5"><span class="cl-161ac798">0.702</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-161e1ada"><p class="cl-161e04e4"><span class="cl-161ac798">selfemp</span></p></td><td class="cl-161e1ae2"><p class="cl-161e04e5"><span class="cl-161ac798">0.060</span></p></td><td class="cl-161e1ae3"><p class="cl-161e04e5"><span class="cl-161ac798">0.060</span></p></td></tr></tbody></table></div>
328</div>
329</div>
330</div>
331<p>The coefficients of above OLS regression result are same comparing to the table 11.2 on textbook.</p>
332</section>
333<section id="probit-model" class="level2">
334<h2 class="anchored" data-anchor-id="probit-model">Probit Model</h2>
335<section id="likelihood-function" class="level3">
336<h3 class="anchored" data-anchor-id="likelihood-function">Likelihood Function</h3>
337<p>Develop the likelihood function of MLE, following the textbook Ch11. Because there is only <span class="math inline">\(Y_1\)</span>, The likelihood function will be</p>
338<p><span class="math display">\[
339f(\beta_0,\beta_1,...,\beta_n;Y_1,...,Y_{m}|X_1,...,X_m)
340\]</span></p>
341<p><span class="math display">\[
342=\{\Theta(\beta_0+\beta_1X_{11}+...+\beta_nX_{1n})^{Y_1}[1-\Theta(\beta_0+\beta_1X_{11}+\beta_nX_{1n})]^{1-Y_1}
343\}\times
344\]</span></p>
345<p><span class="math display">\[
346...\times \{\Theta(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn})^{Y_m}[1-\Theta(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn})]^{1-Y_m}\}
347\]</span></p>
348<p>Where <span class="math inline">\(\hat{\beta}_0^{MLE}, ..., \hat{\beta}_n^{MLE}\)</span> maximize this likelihood function.</p>
349<p>Logarithm of the likelihood:</p>
350<p><span class="math display">\[
351ln(f(\beta_0,\beta_1,\beta_n;Y_1,...,Y_{m}|X_1,...,X_m))
352\]</span></p>
353<p><span class="math display">\[
354= Y_1ln(\Theta(
355\beta_0+\beta_1X_{11}+...+\beta_nX_{1n}))+(1-Y_1)ln
356(1-\Theta(\beta_0+\beta_1X_{11}+\beta_nX_{1n}))+
357\]</span></p>
358<p><span class="math display">\[
359...+
360Y_mln(\Theta(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn}))+
361(1-Y_m)ln(1-\Theta(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn}))
362\]</span></p>
363<div class="cell">
364<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co"># x is a matrix with n * n</span></span>
365<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co"># y is a matrix with n * 1</span></span>
366<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co"># beta is the vector to maximize</span></span>
367<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>likefunc_probit <span class="ot">&lt;-</span> <span class="cf">function</span>(beta, x, y) {</span>
368<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>  x <span class="ot">&lt;-</span> <span class="fu">cbind</span>(<span class="dv">1</span>, x)</span>
369<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a>  res <span class="ot">&lt;-</span> <span class="dv">0</span></span>
370<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>  beta <span class="ot">&lt;-</span> <span class="fu">c</span>(beta)</span>
371<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">nrow</span>(x)) {</span>
372<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>    theta <span class="ot">&lt;-</span> <span class="fu">pnorm</span>(x[i, ] <span class="sc">%*%</span> beta)</span>
373<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a>    res <span class="ot">&lt;-</span> res <span class="sc">+</span></span>
374<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a>      y[i, ] <span class="sc">*</span> <span class="fu">log</span>(theta) <span class="sc">+</span></span>
375<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a>      (<span class="dv">1</span> <span class="sc">-</span> y[i, ]) <span class="sc">*</span> <span class="fu">log</span>(<span class="dv">1</span> <span class="sc">-</span> theta)</span>
376<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a>  }</span>
377<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a>  <span class="fu">return</span>(<span class="sc">-</span>res)</span>
378<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
379</div>
380</section>
381<section id="beta-generation-and-comparison" class="level3">
382<h3 class="anchored" data-anchor-id="beta-generation-and-comparison">Beta Generation and Comparison</h3>
383<div class="cell">
384<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co">
384#| warning: false</span></span>
385<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="co">#| message: false</span></span>
386<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(hmda)</span>
387<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>x <span class="ot">&lt;-</span> hmda <span class="sc">%&gt;%</span></span>
388<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(</span>
389<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>    black, PI, hse_inc, lvratmedium, lvrathigh,</span>
390<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>    ccred, mcred, pubrec, denpmi, selfemp</span>
391<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>  ) <span class="sc">%&gt;%</span></span>
392<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.matrix</span>()</span>
393<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a>y <span class="ot">&lt;-</span> hmda <span class="sc">%&gt;%</span></span>
394<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(deny) <span class="sc">%&gt;%</span></span>
395<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.matrix</span>()</span>
396<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(hmda)</span>
397<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a></span>
398<span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a>res_probit <span class="ot">&lt;-</span> <span class="fu">optim</span>(<span class="fu">rep</span>(<span class="dv">0</span>, <span class="dv">11</span>),</span>
399<span id="cb6-16"><a href="#cb6-16" aria-hidden="true" tabindex="-1"></a>  likefunc_probit,</span>
400<span id="cb6-17"><a href="#cb6-17" aria-hidden="true" tabindex="-1"></a>  <span class="at">x =</span> x, <span class="at">y =</span> y, <span class="at">method =</span> <span class="st">"BFGS"</span></span>
401<span id="cb6-18"><a href="#cb6-18" aria-hidden="true" tabindex="-1"></a>)</span>
402<span id="cb6-19"><a href="#cb6-19" aria-hidden="true" tabindex="-1"></a>res_probit_book <span class="ot">&lt;-</span> <span class="fu">c</span>(</span>
403<span id="cb6-20"><a href="#cb6-20" aria-hidden="true" tabindex="-1"></a>  <span class="sc">-</span><span class="fl">3.04</span>, <span class="fl">0.389</span>, <span class="fl">2.44</span>, <span class="sc">-</span><span class="fl">0.18</span>, <span class="fl">0.21</span>, <span class="fl">0.79</span>,</span>
404<span id="cb6-21"><a href="#cb6-21" aria-hidden="true" tabindex="-1"></a>  <span class="fl">0.15</span>, <span class="fl">0.15</span>, <span class="fl">0.7</span>, <span class="fl">2.56</span>, <span class="fl">0.36</span></span>
405<span id="cb6-22"><a href="#cb6-22" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
406</div>
407<div class="cell">
408<div class="cell-output-display">
409<div id="tbl-hmda_probit" class="anchored">
410
411<div class="tabwid"><style>.cl-1930bc62{}.cl-1929314a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1929315e{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-192c2f12{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-192c2f26{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}
411.cl-192c42e0{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c42f4{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c42f5{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c42fe{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c42ff{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4308{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4309{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c430a{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4312{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4313{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c431c{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c431d{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4326{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4327{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4328{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4330{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4331{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4332{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c433a{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c433b{width:1.711in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-192c4344{width:1.856in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1930bc62"><caption>Table&nbsp;
4112:  <p>HMDA probit model results comparison</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-192c42e0"><p class="cl-192c2f12"><span class="cl-1929314a">Name</span></p></th><th class="cl-192c42f4"><p class="cl-192c2f26"><span class="cl-1929314a">Probit Implemented</span></p></th><th class="cl-192c42f5"><p class="cl-192c2f26"><span class="cl-1929314a">Result from Textbook</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-192c42fe"><p class="cl-192c2f12"><span class="cl-1929315e">(Intercept)</span></p></td><td class="cl-192c42ff"><p class="cl-192c2f26"><span class="cl-1929315e">-3.041</span></p></td><td class="cl-192c4308"><p class="cl-192c2f26"><span class="cl-1929315e">-3.040</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4309"><p class="cl-192c2f12"><span class="cl-1929315e">black</span></p></td><td class="cl-192c430a"><p class="cl-192c2f26"><span class="cl-1929315e">0.389</span></p></td><td class="cl-192c4312"><p class="cl-192c2f26"><span class="cl-1929315e">0.389</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4313"><p class="cl-192c2f12"><span class="cl-1929315e">PI</span></p></td><td class="cl-192c431c"><p class="cl-192c2f26"><span class="cl-1929315e">2.442</span></p></td><td class="cl-192c431d"><p class="cl-192c2f26"><span class="cl-1929315e">2.440</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4326"><p class="cl-192c2f12"><span class="cl-1929315e">hse_inc</span></p></td><td class="cl-192c4327"><p class="cl-192c2f26"><span class="cl-1929315e">-0.185</span></p></td><td class="cl-192c4328"><p class="cl-192c2f26"><span class="cl-1929315e">-0.180</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4313"><p class="cl-192c2f12"><span class="cl-1929315e">lvratmedium</span></p></td><td class="cl-192c431c"><p class="cl-192c2f26"><span class="cl-1929315e">0.214</span></p></td><td class="cl-192c431d"><p class="cl-192c2f26"><span class="cl-1929315e">0.210</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4330"><p class="cl-192c2f12"><span class="cl-1929315e">lvrathigh</span></p></td><td class="cl-192c4331"><p class="cl-192c2f26"><span class="cl-1929315e">0.791</span></p></td><td class="cl-192c4332"><p class="cl-192c2f26"><span class="cl-1929315e">0.790</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4313"><p class="cl-192c2f12"><span class="cl-1929315e">ccred</span></p></td><td class="cl-192c431c"><p class="cl-192c2f26"><span class="cl-1929315e">0.155</span></p></td><td class="cl-192c431d"><p class="cl-192c2f26"><span class="cl-1929315e">0.150</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4313"><p class="cl-192c2f12"><span class="cl-1929315e">mcred</span></p></td><td class="cl-192c431c"><p class="cl-192c2f26"><span class="cl-1929315e">0.148</span></p></td><td class="cl-192c431d"><p class="cl-192c2f26"><span class="cl-1929315e">0.150</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4326"><p class="cl-192c2f12"><span class="cl-1929315e">pubrec</span></p></td><td class="cl-192c4327"><p class="cl-192c2f26"><span class="cl-1929315e">0.697</span></p></td><td class="cl-192c4328"><p class="cl-192c2f26"><span class="cl-1929315e">0.700</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c4326"><p class="cl-192c2f12"><span class="cl-1929315e">denpmi</span></p></td><td class="cl-192c4327"><p class="cl-192c2f26"><span class="cl-1929315e">2.557</span></p></td><td class="cl-192c4328"><p class="cl-192c2f26"><span class="cl-1929315e">2.560</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-192c433a"><p class="cl-192c2f12"><span class="cl-1929315e">selfemp</span></p></td><td class="cl-192c433b"><p class="cl-192c2f26"><span class="cl-1929315e">0.359</span></p></td><td class="cl-192c4344"><p class="cl-192c2f26"><span class="cl-1929315e">0.360</span></p></td></tr></tbody></table></div>
412</div>
413</div>
414</div>
415</section>
416</section>
417<section id="logit-model" class="level2">
418<h2 class="anchored" data-anchor-id="logit-model">Logit Model</h2>
419<section id="likelihood-function-1" class="level3">
420<h3 class="anchored" data-anchor-id="likelihood-function-1">Likelihood Function</h3>
421<p>The difference between Logit and Probit model is the cumulative distribution function. The CDF of Logit model is</p>
422<p><span class="math display">\[
423F(\beta_0+\beta_1X_1+...+\beta_nX_n)=\frac{1}{1+e^{-(\beta_0+\beta_1X_1+...+\beta_nX_n)}}
424\]</span></p>
425<p>So the likelihood function is</p>
426<p><span class="math display">\[
427f(\beta_0,\beta_1,...,\beta_n;Y_1,...,Y_{m}|X_1,...,X_m)
428\]</span></p>
429<p><span class="math display">\[
430=\{F(\beta_0+\beta_1X_{11}+...+\beta_nX_{1n})^{Y_1}[1-F(\beta_0+\beta_1X_{11}+\beta_nX_{1n})]^{1-Y_1}
431\}\times
432\]</span></p>
433<p><span class="math display">\[
434...\times \{F(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn})^{Y_m}[1-F(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn})]^{1-Y_m}\}
435\]</span></p>
436<p>the log form is:</p>
437<p><span class="math display">\[
438ln(f(\beta_0,\beta_1,\beta_n;Y_1,...,Y_{m}|X_1,...,X_m))
439\]</span></p>
440<p><span class="math display">\[
441= Y_1ln(F(
442\beta_0+\beta_1X_{11}+...+\beta_nX_{1n}))+(1-Y_1)ln
443(1-F(\beta_0+\beta_1X_{11}+\beta_nX_{1n}))+
444\]</span></p>
445<p><span class="math display">\[
446...+
447Y_mln(F(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn}))+
448(1-Y_m)ln(1-F(\beta_0+\beta_1X_{m1}+...+\beta_nX_{mn}))
449\]</span></p>
450<p>Implement it in r:</p>
451<div class="cell">
452<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># x is a matrix with n * n</span></span>
453<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># y is a matrix with n * 1</span></span>
454<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="co"># beta is the vector to maximize</span></span>
455<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>logit <span class="ot">&lt;-</span> <span class="cf">function</span>(x) {</span>
456<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a>  res <span class="ot">&lt;-</span> <span class="dv">1</span> <span class="sc">/</span> (<span class="dv">1</span> <span class="sc">+</span> <span class="fu">exp</span>(<span class="sc">-</span>x))</span>
457<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a>  <span class="fu">return</span>(res)</span>
458<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>}</span>
459<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a></span>
460<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a>likefunc_logit <span class="ot">&lt;-</span> <span class="cf">function</span>(beta, x, y) {</span>
461<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a>  x <span class="ot">&lt;-</span> <span class="fu">cbind</span>(<span class="dv">1</span>, x)</span>
462<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a>  res <span class="ot">&lt;-</span> <span class="dv">0</span></span>
463<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a>  beta <span class="ot">&lt;-</span> <span class="fu">c</span>(beta)</span>
464<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">nrow</span>(x)) {</span>
465<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a>    f <span class="ot">&lt;-</span> <span class="fu">logit</span>(x[i, ] <span class="sc">%*%</span> beta)</span>
466<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a>    res <span class="ot">&lt;-</span> res <span class="sc">+</span></span>
467<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a>      y[i, ] <span class="sc">*</span> <span class="fu">log</span>(f) <span class="sc">+</span></span>
468<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a>      (<span class="dv">1</span> <span class="sc">-</span> y[i, ]) <span class="sc">*</span> <span class="fu">log</span>(<span class="dv">1</span> <span class="sc">-</span> f)</span>
469<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a>  }</span>
470<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a>  <span class="fu">return</span>(<span class="sc">-</span>res)</span>
471<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
472</div>
473</section>
474<section id="beta-generation-and-comparison-1" class="level3">
475<h3 class="anchored" data-anchor-id="beta-generation-and-comparison-1">Beta Generation and Comparison</h3>
476<div class="cell">
477<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>res_logit <span class="ot">&lt;-</span> <span class="fu">
477optim</span>(<span class="fu">rep</span>(<span class="dv">0</span>, <span class="dv">11</span>), likefunc_logit, <span class="at">x =</span> x, <span class="at">y =</span> y, <span class="at">method =</span> <span class="st">"BFGS"</span>)</span>
478<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>res_logit_book <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="sc">-</span><span class="fl">5.71</span>, <span class="fl">0.688</span>, <span class="fl">4.76</span>, <span class="sc">-</span><span class="fl">0.11</span>, <span class="fl">0.46</span>, <span class="fl">1.49</span>, <span class="fl">0.29</span>, <span class="fl">0.28</span>, <span class="fl">1.23</span>, <span class="fl">4.55</span>, <span class="fl">0.67</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
479</div>
480<div class="cell">
481<div class="cell-output-display">
482<div id="tbl-hmda_logit" class="anchored">
483
484<div class="tabwid"><style>.cl-1c11bddc{}.cl-1c0a41a6{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1c0a41b0{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1c0d392e{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1c0d3938{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1c0d4ba8{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4ba9{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bb2{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bb3{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bb4{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bbc{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bbd{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bc6{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bc7{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bd0{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bd1{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bda{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bdb{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bdc{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4be4{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bee{width:1.117in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bef{width:1.643in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1c0d4bf8{width:1.601in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1c11bddc"><caption>Table&nbsp;3:  <p>HMDA logit model results comparison</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1c0d4ba8"><p class="cl-1c0d392e"><span class="cl-1c0a41a6">Name</span></p></th><th class="cl-1c0d4ba9"><p class="cl-1c0d3938"><span class="cl-1c0a41a6">Logit Implemented</span></p></th><th class="cl-1c0d4bb2"><p class="cl-1c0d3938"><span class="cl-1c0a41a6">Result From Book</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bb3"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">(Intercept)</span></p></td><td class="cl-1c0d4bb4"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">-5.707</span></p></td><td class="cl-1c0d4bbc"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">-5.710</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bbd"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">black</span></p></td><td class="cl-1c0d4bc6"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.688</span></p></td><td class="cl-1c0d4bc7"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.688</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bbd"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">PI</span></p></td><td class="cl-1c0d4bc6"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">4.764</span></p></td><td class="cl-1c0d4bc7"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">4.760</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bd0"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">hse_inc</span></p></td><td class="cl-1c0d4bd1"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">
484-0.109</span></p></td><td class="cl-1c0d4bda"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">-0.110</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bbd"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">lvratmedium</span></p></td><td class="cl-1c0d4bc6"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.464</span></p></td><td class="cl-1c0d4bc7"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.460</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bdb"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">lvrathigh</span></p></td><td class="cl-1c0d4bdc"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">1.495</span></p></td><td class="cl-1c0d4be4"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">1.490</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bbd"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">ccred</span></p></td><td class="cl-1c0d4bc6"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.290</span></p></td><td class="cl-1c0d4bc7"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.290</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bbd"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">mcred</span></p></td><td class="cl-1c0d4bc6"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.279</span></p></td><td class="cl-1c0d4bc7"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.280</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bd0"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">pubrec</span></p></td><td class="cl-1c0d4bd1"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">1.226</span></p></td><td class="cl-1c0d4bda"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">1.230</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bd0"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">denpmi</span></p></td><td class="cl-1c0d4bd1"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">4.548</span></p></td><td class="cl-1c0d4bda"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">4.550</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1c0d4bee"><p class="cl-1c0d392e"><span class="cl-1c0a41b0">selfemp</span></p></td><td class="cl-1c0d4bef"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.666</span></p></td><td class="cl-1c0d4bf8"><p class="cl-1c0d3938"><span class="cl-1c0a41b0">0.670</span></p></td></tr></tbody></table></div>
485</div>
486</div>
487</div>
488<p>The above comparisons show that the likelihood functions are developed, and coefficients are estimated, successfully.</p>
489</section>
490</section>
491</section>
492<section id="problem-2seatbelts" class="level1">
493<h1>Problem 2(Seatbelts)</h1>
494<section id="a." class="level2 unnumbered">
495<h2 class="unnumbered anchored" data-anchor-id="a.">a.</h2>
496<div class="cell">
497<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>seatbelts <span class="ot">&lt;-</span> <span class="fu">read_xls</span>(<span class="st">"data/SeatBelts.xls"</span>)</span>
498<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(seatbelts)</span>
499<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a>mod.seat1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
500<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a>
500  fatalityrate <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> sb_useage <span class="sc">+</span> speed65 <span class="sc">+</span> speed70 <span class="sc">+</span> ba08 <span class="sc">+</span> drinkage21 <span class="sc">+</span> <span class="fu">log</span>(income) <span class="sc">+</span> age</span>
501<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a>)</span>
502<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(seatbelts)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
503</div>
504<p>From the regression, increased seat belt use enlarges fatalities.</p>
505</section>
506<section id="b." class="level2 unnumbered">
507<h2 class="unnumbered anchored" data-anchor-id="b.">b.</h2>
508<p>Compare the coefficients between two models. The coefficient of <em>sb_useage</em> changed from positive to negative. There may be some properties of states caused the bias. After fixing <em>state</em>, it becomes more reasonable.</p>
509</section>
510<section id="c." class="level2 unnumbered">
511<h2 class="unnumbered anchored" data-anchor-id="c.">c.&nbsp;</h2>
512<p>After adding time fixed effects plus state fixed effects, the coefficient of <em>sb_useage</em> is still negative when fixing state and year, which indicates that <strong>higher seat belt use rate reduces fatalities</strong>.</p>
513<div class="cell">
514<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(seatbelts)</span>
515<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>mod.seat3 <span class="ot">&lt;-</span> seatbelts <span class="sc">%&gt;%</span> <span class="fu">plm</span>(</span>
516<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>
516  fatalityrate <span class="sc">~</span> sb_useage <span class="sc">+</span> speed65 <span class="sc">+</span> speed70 <span class="sc">+</span> ba08 <span class="sc">+</span> drinkage21 <span class="sc">+</span> <span class="fu">log</span>(income) <span class="sc">+</span> age,</span>
517<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">effect =</span> <span class="st">"twoway"</span>,</span>
518<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a>  <span class="at">index =</span> <span class="fu">c</span>(<span class="st">"state"</span>, <span class="st">"year"</span>),</span>
519<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> .</span>
520<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a>)</span>
521<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(seatbelts)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
522</div>
523<div class="cell">
524<div class="cell-output-display">
525<div id="tbl-fix_year_state" class="anchored">
526<table data-quarto-postprocess="true" class="table table-sm table-striped small">
527<caption>Table&nbsp;4: Coef.: no fixing, fix state, fix state plus year</caption>
528<colgroup>
529<col style="width: 25%">
530<col style="width: 25%">
531<col style="width: 25%">
532<col style="width: 25%">
533</colgroup>
534<tbody>
535<tr class="odd">
536<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">&nbsp;</td>
537<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">without fixing</td>
538<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">fix state</td>
539<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">fix state plus year</td>
540</tr>
541<tr class="even">
542<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Predictors</td>
543<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
544<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
545<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
546</tr>
547<tr class="odd">
548<td style="text-align: center;">(Intercept)</td>
549<td style="text-align: center;">0.1965 <sup>***</sup><br>
550(0.0082)</td>
551<td style="text-align: center;"></td>
552<td style="text-align: center;"></td>
553</tr>
554<tr class="even">
555<td style="text-align: center;">sb_useage</td>
556<td style="text-align: center;">0.0041 <sup>***</sup><br>
557(0.0012)</td>
558<td style="text-align: center;">-0.0058 <sup>***</sup><br>
559(0.0012)</td>
560<td style="text-align: center;">-0.0037 <sup>**</sup><br>
561(0.0011)</td>
562</tr>
563<tr class="odd">
564<td style="text-align: center;">speed65</td>
565<td style="text-align: center;">0.0001 <sup></sup><br>
566(0.0004)</td>
567<td style="text-align: center;">-0.0004 <sup></sup><br>
568(0.0003)</td>
569<td style="text-align: center;">-0.0008 <sup></sup><br>
570(0.0004)</td>
571</tr>
572<tr class="even">
573<td style="text-align: center;">speed70</td>
574<td style="text-align: center;">0.0024 <sup>***</sup><br>
575(0.0005)</td>
576<td style="text-align: center;">0.0012 <sup>***</sup><br>
577(0.0003)</td>
578<td style="text-align: center;">0.0008 <sup>*</sup><br>
579(0.0003)</td>
580</tr>
581<tr class="odd">
582<td style="text-align: center;">ba08</td>
583<td style="text-align: center;">-0.0019 <sup>***</sup><br>
584(0.0004)</td>
585<td style="text-align: center;">-0.0014 <sup>***</sup><br>
586(0.0004)</td>
587<td style="text-align: center;">-0.0008 <sup>*</sup><br>
588(0.0004)</td>
589</tr>
590<tr class="even">
591<td style="text-align: center;">drinkage21</td>
592<td style="text-align: center;">0.0001 <sup></sup><br>
593(0.0009)</td>
594<td style="text-align: center;">0.0007 <sup></sup><br>
595(0.0005)</td>
596<td style="text-align: center;">-0.0011 <sup>*</sup><br>
597(0.0005)</td>
598</tr>
599<tr class="odd">
600<td style="text-align: center;">log(income)</td>
601<td style="text-align: center;">-0.0181 <sup>***</sup><br>
602(0.0009)</td>
603<td style="text-align: center;">-0.0135 <sup>***</sup><br>
604(0.0014)</td>
605<td style="text-align: center;">0.0063 <sup></sup><br>
606(0.0039)</td>
607</tr>
608<tr class="even">
609<td style="text-align: center;">age</td>
610<td style="text-align: center;">-0.0000 <sup></sup><br>
611(0.0001)</td>
612<td style="text-align: center;">0.0010 <sup>*</sup><br>
613(0.0004)</td>
614<td style="text-align: center;">0.0013 <sup>***</sup><br>
615(0.0004)</td>
616</tr>
617<tr class="odd">
618<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">Observations</td>
619<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">556</td>
620<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">556</td>
621<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">556</td>
622</tr>
623<tr class="even">
624<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">R<sup>2</sup> / R<sup>2</sup> adjusted</td>
625<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.549 / 0.544</td>
626<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.687 / 0.651</td>
627<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.083 / -0.052</td>
628</tr>
629<tr class="odd">
630<td colspan="4" style="text-align: right; font-style: italic; border-top: double black;">* p&lt;0.05&nbsp;&nbsp;&nbsp;** p&lt;0.01&nbsp;&nbsp;&nbsp;*** p&lt;0.001</td>
631</tr>
632</tbody>
633</table>
634</div>
635
636
637</div>
638</div>
639</section>
640<section id="d." class="level2 unnumbered">
641<h2 class="unnumbered anchored" data-anchor-id="d.">d.&nbsp;</h2>
642<p>Regression in (c), with state and year fixed is most reliable. Because it fixes the effects of different years and states, of which the coefficient of <em>sb_useage</em> is most precise.</p>
643</section>
644<section id="e." class="level2 unnumbered">
645<h2 class="unnumbered anchored" data-anchor-id="e.">e.</h2>
646<p>Th e coefficient of <em>sb_useage</em> is -0.0037, indicating that with 1% seat belt use increased, fatalities will reduce by 0.37%. It is a large number. It means that if seat belt use increase from 52% to 90%, about 58 lives will be saved(counted by average <code>millions of traffic miles per year</code>).</p>
647</section>
648<section id="f." class="level2 unnumbered">
649<h2 class="unnumbered anchored" data-anchor-id="f.">f.&nbsp;</h2>
650<div class="cell">
651<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(seatbelts)</span>
652<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>mod.seat4 <span class="ot">&lt;-</span> seatbelts <span class="sc">%&gt;%</span> <span class="fu">plm</span>(</span>
653<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>
653  sb_useage <span class="sc">~</span> primary <span class="sc">+</span> secondary <span class="sc">+</span> speed65 <span class="sc">+</span> speed70 <span class="sc">+</span> ba08 <span class="sc">+</span> drinkage21 <span class="sc">+</span> <span class="fu">log</span>(income) <span class="sc">+</span> age,</span>
654<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> .,</span>
655<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>  <span class="at">index =</span> <span class="fu">c</span>(<span class="st">"state"</span>, <span class="st">"year"</span>),</span>
656<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a>  <span class="at">effect =</span> <span class="st">"twoway"</span></span>
657<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a>)</span>
658<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(seatbelts)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
659</div>
660<div class="cell">
661<div class="cell-output-display">
662<div id="tbl-mod.seat4" class="anchored">
663<table data-quarto-postprocess="true" class="table table-sm table-striped small">
664<caption>Table&nbsp;5: Primary and Secondary, Fixed Years and States</caption>
665<tbody>
666<tr class="odd">
667<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">&nbsp;</td>
668<td colspan="3" data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">sb_useage</td>
669</tr>
670<tr class="even">
671<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Predictors</td>
672<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
673<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">std. Error</td>
674<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">CI</td>
675</tr>
676<tr class="odd">
677<td style="text-align: center;">primary</td>
678<td style="text-align: center;">0.2056 <sup>***</sup></td>
679<td style="text-align: center;">0.0281</td>
680<td style="text-align: center;">0.1503&nbsp;–&nbsp;0.2609</td>
681</tr>
682<tr class="even">
683<td style="text-align: center;">secondary</td>
684<td style="text-align: center;">0.1085 <sup>***</sup></td>
685<td style="text-align: center;">0.0104</td>
686<td style="text-align: center;">0.0880&nbsp;–&nbsp;0.1290</td>
687</tr>
688<tr class="odd">
689<td style="text-align: center;">speed65</td>
690<td style="text-align: center;">0.0228 <sup></sup></td>
691<td style="text-align: center;">0.0153</td>
692<td style="text-align: center;">-0.0071&nbsp;–&nbsp;0.0528</td>
693</tr>
694<tr class="even">
695<td style="text-align: center;">speed70</td>
696<td style="text-align: center;">0.0120 <sup></sup></td>
697<td style="text-align: center;">0.0121</td>
698<td style="text-align: center;">-0.0116&nbsp;–&nbsp;0.0357</td>
699</tr>
700<tr class="odd">
701<td style="text-align: center;">ba08</td>
702<td style="text-align: center;">0.0038 <sup></sup></td>
703<td style="text-align: center;">0.0125</td>
704<td style="text-align: center;">-0.0208&nbsp;–&nbsp;0.0283</td>
705</tr>
706<tr class="even">
707<td style="text-align: center;">drinkage21</td>
708<td style="text-align: center;">0.0107 <sup></sup></td>
709<td style="text-align: center;">0.0197</td>
710<td style="text-align: center;">-0.0280&nbsp;–&nbsp;0.0494</td>
711</tr>
712<tr class="odd">
713<td style="text-align: center;">log(income)</td>
714<td style="text-align: center;">0.0583 <sup></sup></td>
715<td style="text-align: center;">0.1372</td>
716<td style="text-align: center;">-0.2114&nbsp;–&nbsp;0.3279</td>
717</tr>
718<tr class="even">
719<td style="text-align: center;">age</td>
720<td style="text-align: center;">0.0138 <sup></sup></td>
721<td style="text-align: center;">0.0136</td>
722<td style="text-align: center;">-0.0129&nbsp;–&nbsp;0.0406</td>
723</tr>
724<tr class="odd">
725<td style="text-align: center; font-weight: bold; border-top: 1px solid;">Observations</td>
726<td colspan="3" style="text-align: center; font-weight: bold; border-top: 1px solid;">556</td>
727</tr>
728<tr class="even">
729<td style="text-align: center; font-weight: bold;">R<sup>2</sup> / R<sup>2</sup> adjusted</td>
730<td colspan="3" style="text-align: center; font-weight: bold;">0.249 / 0.138</td>
731</tr>
732<tr class="odd">
733<td colspan="4" style="text-align: right; font-style: italic; border-top: double black;">* p&lt;0.05&nbsp;&nbsp;&nbsp;** p&lt;0.01&nbsp;&nbsp;&nbsp;*** p&lt;0.001</td>
734</tr>
735</tbody>
736</table>
737</div>
738
739
740</div>
741</div>
742<p>The regression result shows that primary enforcement leads to more seat belt use. Secondary enforcement, too, leads to more seat belt use.</p>
743</section>
744<section id="g." class="level2 unnumbered">
745<h2 class="unnumbered anchored" data-anchor-id="g.">g.</h2>
746<p><span class="math display">\[
747sub\space useage=0.206\times primary+0.109\times secondary+...
748\]</span></p>
749<p>New Jersey changed from secondary enforcement to primary enforcement, which means:</p>
750<p><span class="math display">\[
751primary: 0 \rightarrow1, secondary:1\rightarrow0
752\]</span></p>
753<p><span class="math display">\[
754\Delta sb \space useage=0.206-0.109=0.097
755\]</span></p>
756<p>This is predicted to reduce the fatality rate by <span class="math inline">\(0.00372\times 0.097=0.00036\)</span> fatalities per million traffic mile.</p>
757<p><span class="math display">\[
758\Delta fatality\space rate=-0.00372\times \Delta sb\space useage=0.00372\times 0.097=0.00036
759\]</span></p>
760<p>The data set shows that there were 6300 million traffic miles in 1997 in New Jersey. Assuming that same number of traffic miles in 2000 yields <span class="math inline">\(0.00036\times 63,000=23\)</span> lives saved.</p>
761</section>
762</section>
763<section id="problem-3jec" class="level1">
764<h1>Problem 3(JEC)</h1>
765<section id="a.-1" class="level2 unnumbered">
766<h2 class="unnumbered anchored" data-anchor-id="a.-1">a.</h2>
767<p>The model is</p>
768<p><span class="math display">\[
769ln(Q_i)=\beta_0+\beta_1ln(P_i)+\beta_2Ice_i+\Sigma^{12}_{j=1}\beta Seas_{j,i}+u_i
770\]</span></p>
771<div class="cell">
772<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>jec <span class="ot">&lt;-</span> <span class="fu">read_xls</span>(<span class="st">"data/JEC.xls"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
773</div>
774<div class="cell">
775<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(jec)</span>
776<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>mod.jec1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
777<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(quantity) <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> <span class="fu">log</span>(price) <span class="sc">+</span> ice <span class="sc">+</span> seas1 <span class="sc">+</span> seas2 <span class="sc">+</span> seas3 <span class="sc">+</span> seas4 <span class="sc">+</span></span>
778<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a>    seas5 <span class="sc">+</span> seas6 <span class="sc">+</span> seas7 <span class="sc">+</span> seas8 <span class="sc">+</span> seas9 <span class="sc">+</span> seas10 <span class="sc">+</span> seas11 <span class="sc">+</span> seas12</span>
779<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a>)</span>
780<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(jec)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
781</div>
782<p>The regression result shows that the demand elasticity is -0.639 and its standard error is 0.082</p>
783</section>
784<section id="b.-1" class="level2 unnumbered">
785<h2 class="unnumbered anchored" data-anchor-id="b.-1">b.</h2>
786<p>There is simultaneous causality in the interaction of supply and demand, thus it makes the OLS estimator of the elasticity b
786iased.</p>
787</section>
788<section id="c.-1" class="level2 unnumbered">
789<h2 class="unnumbered anchored" data-anchor-id="c.-1">c.&nbsp;</h2>
790<p>The collusion of the cartel increases the price of grain what would have been the competitive price, i.e.&nbsp;<span class="math inline">\(Corr(cartel, ln(price))&gt;0\)</span>. But the cartel and change price do not influence the demand of grain, for grain is necessary, which means <span class="math inline">\(Corr(cartel, ln(Q))=0\)</span>. The two correlations above illustrate that <em>cartel</em> is a valid instrument.</p>
791</section>
792<section id="d.-1" class="level2 unnumbered">
793<h2 class="unnumbered anchored" data-anchor-id="d.-1">d.&nbsp;</h2>
794<p>Model of Stage 1:</p>
795<p><span class="math display">\[
796ln(P_i)=\beta_0+\beta_1 cartel+\beta_2Ice_i+\Sigma^{12}_{j=1}\beta Seas_{j,i}+u_i
797\]</span></p>
798<div class="cell">
799<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(jec)</span>
800<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>mod.jec_stage1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
801<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(price) <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> cartel <span class="sc">+</span> ice <span class="sc">+</span> seas1 <span class="sc">+</span> seas2 <span class="sc">+</span> seas3 <span class="sc">+</span> seas4 <span class="sc">+</span></span>
802<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a>    seas5 <span class="sc">+</span> seas6 <span class="sc">+</span> seas7 <span class="sc">+</span> seas8 <span class="sc">+</span> seas9 <span class="sc">+</span> seas10 <span class="sc">+</span> seas11 <span class="sc">+</span> seas12</span>
803<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>)</span>
804<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(jec)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
805</div>
806<p>The first state F-statistic, 21.3170209, which is &gt; 10, illustrates that the estimators in first stage are jointly significant. That means <em>cartel</em> is <strong>not a weak instrument</strong>.</p>
807</section>
808<section id="e.-1" class="level2 unnumbered">
809<h2 class="unnumbered anchored" data-anchor-id="e.-1">e.</h2>
810<p>The model of second stage:</p>
811<p><span class="math display">\[
812ln(Q_i)=\beta_0+\beta_1\widehat{ln(P_i)}+\beta_2Ice_i+\Sigma^{12}_{j=1}\beta Seas_{j,i}+w_i
813\]</span></p>
814<div class="cell">
815<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>pred_logp <span class="ot">&lt;-</span> <span class="fu">fitted.values</span>(mod.jec_stage1)</span>
816<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(jec)</span>
817<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a>mod.jec_stage2 <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
818<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(quantity) <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> <span class="fu">log</span>(price) <span class="sc">+</span> ice <span class="sc">+</span> seas1 <span class="sc">+</span> seas2 <span class="sc">+</span> seas3 <span class="sc">+</span> seas4 <span class="sc">+</span></span>
819<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a>    seas5 <span class="sc">+</span> seas6 <span class="sc">+</span> seas7 <span class="sc">+</span> seas8 <span class="sc">+</span> seas9 <span class="sc">+</span> seas10 <span class="sc">+</span> seas11 <span class="sc">+</span> seas12 <span class="sc">|</span></span>
820<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a>    cartel <span class="sc">+</span> ice <span class="sc">+</span> seas1 <span class="sc">+</span> seas2 <span class="sc">+</span> seas3 <span class="sc">+</span> seas4 <span class="sc">+</span></span>
821<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a>      seas5 <span class="sc">+</span> seas6 <span class="sc">+</span> seas7 <span class="sc">+</span> seas8 <span class="sc">+</span> seas9 <span class="sc">+</span> seas10 <span class="sc">+</span> seas11 <span class="sc">+</span> seas12</span>
822<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a>)</span>
823<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(jec)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
824</div>
825<p>The regression result shows that estimated demand elasticity is -0.867 and its standard error is 0.132.</p>
826<div class="cell">
827<div class="cell-output-display">
828<div id="tbl-jec_reg" class="anchored">
829<table data-quarto-postprocess="true" class="table table-sm table-striped small">
830<caption>Table&nbsp;6: JEC Regression Results(FE on Seasons)</caption>
831<colgroup>
832<col style="width: 25%">
833<col style="width: 25%">
834<col style="width: 25%">
835<col style="width: 25%">
836</colgroup>
837<tbody>
838<tr class="odd">
839<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">&nbsp;</td>
840<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">Elasticity</td>
841<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 1</td>
842<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 2</td>
843</tr>
844<tr class="even">
845<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Predictors</td>
846<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
847<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
848<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
849</tr>
850<tr class="odd">
851<td style="text-align: center;">(Intercept)</td>
852<td style="text-align: center;">8.8612 <sup>***</sup><br>
853(0.1714)</td>
854<td style="text-align: center;">-1.6937 <sup>***</sup><br>
855(0.0784)</td>
856<td style="text-align: center;">8.5735 <sup>***</sup><br>
857(0.2164)</td>
858</tr>
859<tr class="even">
860<td style="text-align: center;">price [log]</td>
861<td style="text-align: center;">-0.6389 <sup>***</sup><br>
862(0.0824)</td>
863<td style="text-align: center;"></td>
864<td style="text-align: center;">-0.8666 <sup>***</sup><br>
865(0.1321)</td>
866</tr>
867<tr class="odd">
868<td style="text-align: center;">cartel</td>
869<td style="text-align: center;"></td>
870<td style="text-align: center;">0.3579 <sup>***</sup><br>
871(0.0249)</td>
872<td style="text-align: center;"></td>
873</tr>
874<tr class="even">
875<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">Observations</td>
876<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">328</td>
877<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">328</td>
878<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">328</td>
879</tr>
880<tr class="odd">
881<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">R<sup>2</sup> / R<sup>2</sup> adjusted</td>
882<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.313 / 0.282</td>
883<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.488 / 0.465</td>
884<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.296 / 0.264</td>
885</tr>
886<tr class="even">
887<td colspan="4" style="text-align: right; font-style: italic; border-top: double black;">* p&lt;0.05&nbsp;&nbsp;&nbsp;** p&lt;0.01&nbsp;&nbsp;&nbsp;*** p&lt;0.001</td>
888</tr>
889</tbody>
890</table>
891</div>
892
893
894</div>
895</div>
896</section>
897<section id="f.-1" class="level2 unnumbered">
898<h2 class="unnumbered anchored" data-anchor-id="f.-1">f.&nbsp;</h2>
899<p>The absolute price elasticity is less than 1, so marginal profit is positive, which prompts the cartel to raise the price. So it suggests that the cartel was charging the profit-maximizing monopoly price.</p>
900</section>
901</section>
902<section id="problem-4movies" class="level1">
903<h1>Problem 4(Movies)</h1>
904<section id="a.-2" class="level2 unnumbered">
905<h2 class="unnumbered anchored" data-anchor-id="a.-2">a.</h2>
906<section id="i." class="level3 unnumbered unlisted">
907<h3 class="unnumbered unlisted anchored" data-anchor-id="i.">i.</h3>
908<div class="cell">
909<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>movies <span class="ot">&lt;-</span> <span class="fu">read_xlsx</span>(<span class="st">"data/Movies.xlsx"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
910</div>
911<p>The Model is as follows:</p>
912<p><span class="math display">\[
913log(assaults_i) = \beta_0 + \Sigma^{10}_{j=2}\beta year_{j,i}+\Sigma^{12}_{j=2}\beta month_{j,i} + u_i
914\]</span></p>
915<p>Choose year1, month1 as the basic group, to avoid the dummy variable trap. Then regress <em>log(assaults)</em> on <em>years</em> and <em>months</em></p>
916<div class="cell">
917<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(movies)</span>
918<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>mod.movies1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
919<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(assaults) <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span> year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
919 year8 <span class="sc">+</span> year9 <span class="sc">+</span></span>
920<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a>    year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span> month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span></span>
921<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a>    month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12</span>
922<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a>)</span>
923<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(movies)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
924</div>
925<div class="cell">
926<div class="cell-output-display">
927<div id="fig-movies1" class="quarto-figure quarto-figure-center anchored">
928<figure class="figure">
929<p><img src="exp2_files/figure-html/fig-movies1-1.png" class="img-fluid figure-img" width="672"></p>
930<p></p><figcaption class="figure-caption">Figure&nbsp;1: Reg assault: Effects of Years and Months on Assaults</figcaption><p></p>
931</figure>
932</div>
933</div>
934</div>
935<div class="cell">
936<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>mod.movies1_f <span class="ot">&lt;-</span> mod.movies1 <span class="sc">%&gt;%</span></span>
937<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>  <span class="fu">linearHypothesis</span>(<span class="fu">c</span>(</span>
938<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month3"</span>,</span>
939<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month4"</span>,</span>
940<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month5"</span>,</span>
941<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month6"</span>,</span>
942<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month7"</span>,</span>
943<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month8"</span>,</span>
944<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month9"</span>,</span>
945<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month10"</span>,</span>
946<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month11"</span>,</span>
947<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month12"</span></span>
948<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a>  )) <span class="sc">%&gt;%</span></span>
949<span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a>  .[<span class="st">"F"</span>] <span class="sc">%&gt;%</span></span>
950<span id="cb18-15"><a href="#cb18-15" aria-hidden="true" tabindex="-1"></a>  <span class="fu">pull</span>() <span class="sc">%&gt;%</span></span>
951<span id="cb18-16"><a href="#cb18-16" aria-hidden="true" tabindex="-1"></a>  .[<span class="dv">2</span>] <span class="sc">%&gt;%</span></span>
952<span id="cb18-17"><a href="#cb18-17" aria-hidden="true" tabindex="-1"></a>  <span class="fu">round</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
953</div>
954<p>The regression result shows that assaults increases with year. And there are more assaults in month 5-10, less in month 1, 12. And the F-statistic on the 11 monthly indicators is 67 with p-value that is essentially 0. So the seasonality in assaults exists.</p>
955</section>
956<section id="ii." class="level3 unnumbered unlisted">
957<h3 class="unnumbered unlisted anchored" data-anchor-id="ii.">ii.</h3>
958<div class="cell">
959<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate attend</span></span>
960<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>movies <span class="ot">&lt;-</span> movies <span class="sc">%&gt;%</span> <span class="fu">mutate</span>(<span class="at">attend =</span> attend_v <span class="sc">+</span> attend_m <span class="sc">+</span>
960 attend_n)</span>
961<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(movies)</span>
962<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a>mod.attend1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
963<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a>  attend <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span> year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span> year8 <span class="sc">+</span> year9 <span class="sc">+</span></span>
964<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a>    year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span> month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span></span>
965<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a>    month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12</span>
966<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a>)</span>
967<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(movies)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
968</div>
969<div class="cell">
970<div class="cell-output-display">
971<div id="fig-attend1" class="quarto-figure quarto-figure-center anchored">
972<figure class="figure">
973<p><img src="exp2_files/figure-html/fig-attend1-1.png" class="img-fluid figure-img" width="672"></p>
974<p></p><figcaption class="figure-caption">Figure&nbsp;2: Reg attend: Effects of Years and Months on Movie Attend</figcaption><p></p>
975</figure>
976</div>
977</div>
978</div>
979<div class="cell">
980<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>attend_months_f <span class="ot">&lt;-</span> mod.attend1 <span class="sc">%&gt;%</span></span>
981<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>  <span class="fu">linearHypothesis</span>(<span class="fu">c</span>(</span>
982<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month3"</span>,</span>
983<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month4"</span>,</span>
984<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month5"</span>,</span>
985<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month6"</span>,</span>
986<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month7"</span>,</span>
987<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month8"</span>,</span>
988<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month9"</span>,</span>
989<span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month10"</span>,</span>
990<span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month11"</span>,</span>
991<span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a>    <span class="st">"month2=month12"</span></span>
992<span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a>  )) <span class="sc">%&gt;%</span></span>
993<span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a>  .[<span class="st">"F"</span>] <span class="sc">%&gt;%</span></span>
994<span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a>  <span class="fu">pull</span>() <span class="sc">%&gt;%</span></span>
995<span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a>  .[<span class="dv">2</span>] <span class="sc">%&gt;%</span></span>
996<span id="cb20-17"><a href="#cb20-17" aria-hidden="true" tabindex="-1"></a>  <span class="fu">round</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
997</div>
998<p>From the figure, the difference of the coefficient among years is significant. The difference among months is significant, too. And the F-statistic on the 11 monthly indicators is 37 with p-value that is essentially 0. So there is seasonality in movie attendance.</p>
999</section>
1000</section>
1001<section id="b.-2" class="level2 unnumbered">
1002<h2 class="unnumbered anchored" data-anchor-id="b.-2">b.</h2>
1003<section id="i.-1" class="level3 unnumbered unlisted">
1004<h3 class="unnumbered unlisted anchored" data-anchor-id="i.-1">i.</h3>
1005<div class="cell">
1006<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(movies)</span>
1007<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>mod.ln_ass <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
1008<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(assaults) <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> attend_v <span class="sc">+</span> attend_m <span class="sc">+</span> attend_n <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1009<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a>    year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1009 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1010<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a>    month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1011<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a>    h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1012<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a>    w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc</span>
1013<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a>)</span>
1014<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(movies)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1015</div>
1016<div class="cell">
1017<div class="cell-output-display">
1018<div id="tbl-assaults_ymhw" class="anchored">
1019
1020<div class="tabwid"><style>.cl-1dc5c1b4{}.cl-1dbd9912{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1dbd991c{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1dbd991d{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(51, 51, 51, 1.00);background-color:transparent;}.cl-1dc09324{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1dc0932e{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1dc0ae18{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae22{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae23{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae2c{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae2d{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae36{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae37{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae38{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae39{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae40{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae41{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae42{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae4a{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae54{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae55{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae5e{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae5f{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae68{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae69{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae72{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae73{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae74{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae7c{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae7d{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dc0ae7e{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1dc5c1b4"><caption>Table&nbsp;7:  <p>Regress ln_assaults on v, n, m, year, month, weather, and holidy</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1dc0ae18"><p class="cl-1dc09324"><span class="cl-1dbd9912">Var.Name</span></p></th><th class="cl-1dc0ae22"><p class="cl-1dc0932e"><span class="cl-1dbd9912">Estimate</span></p></th><th class="cl-1dc0ae23"><p class="cl-1dc0932e"><span class="cl-1dbd9912">Std. Error</span></p></th><th class="cl-1dc0ae2c"><p class="cl-1dc0932e"><span class="cl-1dbd9912">t value</span></p></th><th class="cl-1dc0ae2d"><p class="cl-1dc0932e"><span class="cl-1dbd9912">Pr(&gt;|t|)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1dc0ae36"><p class="cl-1dc09324"><span class="cl-1dbd991c">(Intercept)</span></p></td><td class="cl-1dc0ae37"><p class="cl-1dc0932e"><span class="cl-1dbd991c">6.91432</span></p></td><td class="cl-1dc0ae38"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.01715</span></p></td><td class="cl-1dc0ae39"><p class="cl-1dc0932e"><span class="cl-1dbd991c">403.24547</span></p></td><td class="cl-1dc0ae40"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00000</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1dc0ae41"><p class="cl-1dc09324"><span class="cl-1dbd991c">attend_v</span></p></td><td class="cl-1dc0ae42"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-0.00317</span></p></td><td class="cl-1dc0ae4a"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00100</span></p></td><td class="cl-1dc0ae54"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-3.17102</span></p></td><td class="cl-1dc0ae55"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00162</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1dc0ae41"><p class="cl-1dc09324"><span class="cl-1dbd991c">attend_m</span></p></td><td class="cl-1dc0ae42"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-0.00314</span></p></td><td class="cl-1dc0ae4a"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00066</span></p></td><td class="cl-1dc0ae54"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-4.74238</span></p></td><td class="cl-1dc0ae55"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00000</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1dc0ae5e"><p class="cl-1dc09324"><span class="cl-1dbd991c">attend_n</span></p></td><td class="cl-1dc0ae5f"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-0.00211</span></p></td><td class="cl-1dc0ae68"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00066</span></p></td><td class="cl-1dc0ae69"><p class="cl-1dc0932e"><span class="cl-1dbd991c">-3.19400</span></p></td><td class="cl-1dc0ae72"><p class="cl-1dc0932e"><span class="cl-1dbd991c">0.00150</span></p></td></tr></tbody><tfoot><tr style="overflow-wrap:break-word;"><td colspan="5" class="cl-1dc0ae73"><p class="cl-1dc09324"><span class="cl-1dbd991d">Note. Fixed variables are hidden</span></p></td></tr></tfoot></table></div>
1021</div>
1022</div>
1023</div>
1024<p>The regression result shows that viewing a strongly violent movie decreases assaults by 0.32%. The estimated effect is statistically significant at 0.01 significant level.</p>
1025</section>
1026<section id="ii.-1" class="level3 unnumbered unlisted">
1027<h3 class="unnumbered unlisted anchored" data-anchor-id="ii.-1">ii.</h3>
1028<p>Make hypothesis that <span class="math inline">\(\beta_v = \beta_m\)</span> and <span class="math inline">\(\beta_v = \beta_n\)</span>. Then do F tests.</p>
1029<div class="cell">
1030<div class="cell-output-display">
1031<div id="tbl-vmn_diff" class="anchored">
1032
1033<div class="tabwid"><style>.cl-1ddeadc8{}.cl-1dd7785a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}
1033.cl-1dd77864{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1dda53fe{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1dda5408{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1dda6574{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dda6575{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dda657e{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dda657f{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dda6588{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dda6592{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1ddeadc8"><caption>Table&nbsp;8:  <p>F test of v=m, v=n</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1dda6574"><p class="cl-1dda53fe"><span class="cl-1dd7785a">Test</span></p></th><th class="cl-1dda6575"><p class="cl-1dda5408"><span class="cl-1dd7785a">F</span></p></th><th class="cl-1dda6575"><p class="cl-1dda5408"><span class="cl-1dd7785a">Pr(&gt;F)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1dda657e"><p class="cl-1dda53fe"><span class="cl-1dd77864">v=m</span></p></td><td class="cl-1dda657f"><p class="cl-1dda5408"><span class="cl-1dd77864">0.00113</span></p></td><td class="cl-1dda657f"><p class="cl-1dda5408"><span class="cl-1dd77864">0.97325</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1dda6588"><p class="cl-1dda53fe"><span class="cl-1dd77864">v=n</span></p></td><td class="cl-1dda6592"><p class="cl-1dda5408"><span class="cl-1dd77864">1.21960</span></p></td><td class="cl-1dda6592"><p class="cl-1dda5408"><span class="cl-1dd77864">0.27000</span></p></td></tr></tbody></table></div>
1034</div>
1035</div>
1036</div>
1037<p>The F-test result suggests that <span class="math inline">\(\beta_v\)</span> with <span class="math inline">\(\beta_m\)</span>, and <span class="math inline">\(beta_v\)</span> with <span class="math inline">\(\beta_n\)</span> have no statistically significant difference from one another.</p>
1038</section>
1039<section id="iii." class="level3 unnumbered unlisted">
1040<h3 class="unnumbered unlisted anchored" data-anchor-id="iii.">iii.</h3>
1041<p>Construct a new variable <em>
1041effect</em> and construct its 95% confidence interval.</p>
1042<p><span class="math display">\[
1043effect = 6*\beta_v * attend_v-2*\beta_m*attend_m-\beta_n*attend_n
1044\]</span></p>
1045<div class="cell">
1046<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>beta_v <span class="ot">&lt;-</span> mod.ln_ass<span class="sc">$</span>coefficients[<span class="st">"attend_v"</span>]</span>
1047<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>beta_m <span class="ot">&lt;-</span> mod.ln_ass<span class="sc">$</span>coefficients[<span class="st">"attend_m"</span>]</span>
1048<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a>beta_n <span class="ot">&lt;-</span> mod.ln_ass<span class="sc">$</span>coefficients[<span class="st">"attend_n"</span>]</span>
1049<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a>effect <span class="ot">&lt;-</span> movies <span class="sc">%&gt;%</span></span>
1050<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">effect =</span> <span class="dv">6</span> <span class="sc">*</span> beta_v <span class="sc">*</span> attend_v <span class="sc">-</span></span>
1051<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a>    <span class="dv">2</span> <span class="sc">*</span> beta_m <span class="sc">*</span> attend_m <span class="sc">-</span></span>
1052<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a>    beta_n <span class="sc">*</span> attend_n) <span class="sc">%&gt;%</span></span>
1053<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(effect) <span class="sc">%&gt;%</span></span>
1054<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">pull</span>()</span>
1055<span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a>ci_res <span class="ot">&lt;-</span> <span class="fu">ci</span>(effect) <span class="sc">%&gt;%</span></span>
1056<span id="cb22-11"><a href="#cb22-11" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1057<span id="cb22-12"><a href="#cb22-12" aria-hidden="true" tabindex="-1"></a>  <span class="fu">t</span>() <span class="sc">%&gt;%</span></span>
1058<span id="cb22-13"><a href="#cb22-13" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1059<span id="cb22-14"><a href="#cb22-14" aria-hidden="true" tabindex="-1"></a>  <span class="fu">round</span>(<span class="dv">5</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1060</div>
1061<p>The OLS estimate for this coefficient is 0.01553. It shows a decrease in assaults of 1.55%. The 95% confidence interval is (0.01056, 0.02051).</p>
1062<div class="cell">
1063<div class="cell-output-display">
1064<div id="tbl-movies_predic_ci" class="anchored">
1065
1066<div class="tabwid"><style>.cl-1e042c7e{}.cl-1df8168c{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1df81696{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1dfaf802{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1dfb084c{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb084d{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb084e{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb0856{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb0857{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb0860{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb0861{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1dfb0862{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1e042c7e"><caption>Table&nbsp;9:  <p>Confidence Interval of Prediction</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1dfb084c"><p class="cl-1dfaf802"><span class="cl-1df8168c">Estimate</span></p></th><th class="cl-1dfb084d"><p class="cl-1dfaf802"><span class="cl-1df8168c">CI lower</span></p></th><th class="cl-1dfb084e"><p class="cl-1dfaf802"><span class="cl-1df8168c">CI upper</span></p></th><th class="cl-1dfb0856"><p class="cl-1dfaf802"><span class="cl-1df8168c">Std. Error</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1dfb0857"><p class="cl-1dfaf802"><span class="cl-1df81696">0.01553</span></p></td><td class="cl-1dfb0860"><p class="cl-1dfaf802"><span class="cl-1df81696">0.01056</span></p></td><td class="cl-1dfb0861"><p class="cl-1dfaf802"><span class="cl-1df81696">0.02051</span></p></td><td class="cl-1dfb0862"><p class="cl-1dfaf802"><span class="cl-1df81696">0.00253</span></p></td></tr></tbody></table></div>
1067</div>
1068</div>
1069</div>
1070</section>
1071</section>
1072<section id="c.-2" class="level2 unnumbered">
1073<h2 class="unnumbered anchored" data-anchor-id="c.-2">c.&nbsp;</h2>
1074<p>Use <em>pr_attend_v</em>, <em>pr_attend_m</em>, and <em>pr_attend_n</em> as instruments for <em>attend_v</em>, <em>attend_m</em>, and <em>attend_n</em>. Run the regression.</p>
1075<div class="cell">
1076<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>mod.movies_tsls <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
1077<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> movies,</span>
1078<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(assaults) <span class="sc">~</span> attend_v <span class="sc">+</span> attend_m <span class="sc">+</span> attend_n <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1079<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a>    year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1079 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1080<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a>    month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1081<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a>    h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1082<span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a>    w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc <span class="sc">|</span></span>
1083<span id="cb23-8"><a href="#cb23-8" aria-hidden="true" tabindex="-1"></a>    pr_attend_v <span class="sc">+</span> pr_attend_m <span class="sc">+</span> pr_attend_n <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1084<span id="cb23-9"><a href="#cb23-9" aria-hidden="true" tabindex="-1"></a>      year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1084 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1085<span id="cb23-10"><a href="#cb23-10" aria-hidden="true" tabindex="-1"></a>      month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1086<span id="cb23-11"><a href="#cb23-11" aria-hidden="true" tabindex="-1"></a>      h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1087<span id="cb23-12"><a href="#cb23-12" aria-hidden="true" tabindex="-1"></a>      w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc</span>
1088<span id="cb23-13"><a href="#cb23-13" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1089</div>
1090<div class="cell">
1091<div class="cell-output-display">
1092<div id="tbl-movies_tsls" class="anchored">
1093
1094<div class="tabwid"><style>.cl-1e28761a{}.cl-1e21006a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e210074{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e21007e{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(51, 51, 51, 1.00);background-color:transparent;}.cl-1e23f004{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e23f018{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e2402b0{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402ba{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402bb{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402c4{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402c5{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402c6{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402ce{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402cf{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402d0{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402d8{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402d9{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402da{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402e2{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402e3{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402e4{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402ec{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402ed{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402f6{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402f7{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e2402f8{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e240300{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e240301{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e240302{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e24030a{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e24030b{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1e28761a"><caption>Table&nbsp;10:  <p>Movies TSLS Stage 2 Result</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1e2402b0"><p class="cl-1e23f004"><span class="cl-1e21006a">Var.Name</span></p></th><th class="cl-1e2402ba"><p class="cl-1e23f018"><span class="cl-1e21006a">Estimate</span></p></th><th class="cl-1e2402bb"><p class="cl-1e23f018"><span class="cl-1e21006a">Std. Error</span></p></th><th class="cl-1e2402c4"><p class="cl-1e23f018"><span class="cl-1e21006a">t value</span></p></th><th class="cl-1e2402c5"><p class="cl-1e23f018"><span class="cl-1e21006a">Pr(&gt;|t|)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1e2402c6"><p class="cl-1e23f004"><span class="cl-1e210074">(Intercept)</span></p></td><td class="cl-1e2402ce"><p class="cl-1e23f018"><span class="cl-1e210074">
10946.92418</span></p></td><td class="cl-1e2402cf"><p class="cl-1e23f018"><span class="cl-1e210074">0.01828</span></p></td><td class="cl-1e2402d0"><p class="cl-1e23f018"><span class="cl-1e210074">378.83439</span></p></td><td class="cl-1e2402d8"><p class="cl-1e23f018"><span class="cl-1e210074">0.00000</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e2402d9"><p class="cl-1e23f004"><span class="cl-1e210074">attend_v</span></p></td><td class="cl-1e2402da"><p class="cl-1e23f018"><span class="cl-1e210074">-0.00387</span></p></td><td class="cl-1e2402e2"><p class="cl-1e23f018"><span class="cl-1e210074">0.00111</span></p></td><td class="cl-1e2402e3"><p class="cl-1e23f018"><span class="cl-1e210074">-3.48016</span></p></td><td class="cl-1e2402e4"><p class="cl-1e23f018"><span class="cl-1e210074">0.00055</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e2402d9"><p class="cl-1e23f004"><span class="cl-1e210074">attend_m</span></p></td><td class="cl-1e2402da"><p class="cl-1e23f018"><span class="cl-1e210074">-0.00389</span></p></td><td class="cl-1e2402e2"><p class="cl-1e23f018"><span class="cl-1e210074">0.00077</span></p></td><td class="cl-1e2402e3"><p class="cl-1e23f018"><span class="cl-1e210074">-5.02473</span></p></td><td class="cl-1e2402e4"><p class="cl-1e23f018"><span class="cl-1e210074">0.00000</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e2402ec"><p class="cl-1e23f004"><span class="cl-1e210074">attend_n</span></p></td><td class="cl-1e2402ed"><p class="cl-1e23f018"><span class="cl-1e210074">-0.00272</span></p></td><td class="cl-1e2402f6"><p class="cl-1e23f018"><span class="cl-1e210074">0.00079</span></p></td><td class="cl-1e2402f7"><p class="cl-1e23f018"><span class="cl-1e210074">-3.44928</span></p></td><td class="cl-1e2402f8"><p class="cl-1e23f018"><span class="cl-1e210074">0.00061</span></p></td></tr></tbody><tfoot><tr style="overflow-wrap:break-word;"><td colspan="5" class="cl-1e240300"><p class="cl-1e23f004"><span class="cl-1e21007e">Note. Fixed variables are hidden</span></p></td></tr></tfoot></table></div>
1095</div>
1096</div>
1097</div>
1098<p>So based on this regression, viewing strongly violent movies leads to a small but significant decrease in assaults, rather than an increase.</p>
1099<p>Samely, make the linear hypothesis <code>attend_v=attend_m</code> and <code>attend_v=attend_n</code></p>
1100<div class="cell">
1101<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>movies_tsls_vm <span class="ot">&lt;-</span> mod.movies_tsls <span class="sc">%&gt;%</span> car<span class="sc">::</span><span class="fu">linearHypothesis</span>(</span>
1102<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_v=attend_m"</span></span>
1103<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a>)</span>
1104<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a>movies_tsls_vn <span class="ot">&lt;-</span> mod.movies_tsls <span class="sc">%&gt;%</span> car<span class="sc">::</span><span class="fu">linearHypothesis</span>(</span>
1105<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_v = attend_n"</span></span>
1106<span id="cb24-6"><a href="#cb24-6" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1107</div>
1108<div class="cell">
1109<div class="cell-output-display">
1110<div id="tbl-tsls_vmn_diff" class="anchored">
1111
1112<div class="tabwid"><style>.cl-1e462926{}.cl-1e3dcc68{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e3dcc72{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e40ad66{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}
1112.cl-1e40ad70{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e40bec8{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bed2{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bed3{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bedc{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bee6{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bee7{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bef0{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bef1{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e40bef2{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1e462926"><caption>Table&nbsp;11:  <p>TSLS F test of v=m, v=n</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1e40bec8"><p class="cl-1e40ad66"><span class="cl-1e3dcc68">Test</span></p></th><th class="cl-1e40bed2"><p class="cl-1e40ad70"><span class="cl-1e3dcc68">Chisq</span></p></th><th class="cl-1e40bed3"><p class="cl-1e40ad70"><span class="cl-1e3dcc68">Pr(&gt;Chisq)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1e40bedc"><p class="cl-1e40ad66"><span class="cl-1e3dcc72">v=m</span></p></td><td class="cl-1e40bee6"><p class="cl-1e40ad70"><span class="cl-1e3dcc72">0.00041</span></p></td><td class="cl-1e40bee7"><p class="cl-1e40ad70"><span class="cl-1e3dcc72">0.98377</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e40bef0"><p class="cl-1e40ad66"><span class="cl-1e3dcc72">v=n</span></p></td><td class="cl-1e40bef1"><p class="cl-1e40ad70"><span class="cl-1e3dcc72">1.34368</span></p></td><td class="cl-1e40bef2"><p class="cl-1e40ad70"><span class="cl-1e3dcc72">0.24639</span></p></td></tr></tbody></table></div>
1113</div>
1114</div>
1115</div>
1116<p>Too, the F-test result suggests that <span class="math inline">\(\beta_v\)</span>, <span class="math inline">\(\beta_m\)</span>, <span class="math inline">\(\beta_n\)</span> have no statistically significant difference from one another.</p>
1117<div class="cell">
1118<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>beta_v <span class="ot">&lt;-</span> mod.movies_tsls<span class="sc">$</span>coefficients[<span class="st">"attend_v"</span>]</span>
1119<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a>beta_m <span class="ot">&lt;-</span> mod.movies_tsls<span class="sc">$</span>coefficients[<span class="st">
1119"attend_m"</span>]</span>
1120<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a>beta_n <span class="ot">&lt;-</span> mod.movies_tsls<span class="sc">$</span>coefficients[<span class="st">"attend_n"</span>]</span>
1121<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a>effect <span class="ot">&lt;-</span> movies <span class="sc">%&gt;%</span></span>
1122<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">effect =</span> <span class="dv">6</span> <span class="sc">*</span> beta_v <span class="sc">*</span> attend_v <span class="sc">-</span></span>
1123<span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a>    <span class="dv">2</span> <span class="sc">*</span> beta_m <span class="sc">*</span> attend_m <span class="sc">-</span></span>
1124<span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a>    beta_n <span class="sc">*</span> attend_n) <span class="sc">%&gt;%</span></span>
1125<span id="cb25-8"><a href="#cb25-8" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(effect) <span class="sc">%&gt;%</span></span>
1126<span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">pull</span>()</span>
1127<span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a>ci_res_tsls <span class="ot">&lt;-</span> <span class="fu">ci</span>(effect) <span class="sc">%&gt;%</span></span>
1128<span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1129<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a>  <span class="fu">t</span>() <span class="sc">%&gt;%</span></span>
1130<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1131<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a>  <span class="fu">round</span>(<span class="dv">5</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1132</div>
1133<p>The OLS estimate for this coefficient is 0.02115. It shows a decrease in assaults of 2.11%. The 95% confidence interval is (0.01503, 0.02726).</p>
1134<div class="cell">
1135<div class="cell-output-display">
1136<div id="tbl-movies_tsls_ci" class="anchored">
1137
1138<div class="tabwid"><style>.cl-1e689b78{}.cl-1e6028c6{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e6028da{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e643b8c{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e644bfe{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c08{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c09{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c0a{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c12{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c13{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c1c{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e644c1d{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1e689b78"><caption>Table&nbsp;12:  <p>Change in Assaults 95% Confidence Interval</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1e644bfe"><p class="cl-1e643b8c"><span class="cl-1e6028c6">Estimate</span></p></th><th class="cl-1e644c08"><p class="cl-1e643b8c"><span class="cl-1e6028c6">CI lower</span></p></th><th class="cl-1e644c09"><p class="cl-1e643b8c"><span class="cl-1e6028c6">CI upper</span></p></th><th class="cl-1e644c0a"><p class="cl-1e643b8c"><span class="cl-1e6028c6">Std. Error</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1e644c12"><p class="cl-1e643b8c"><span class="cl-1e6028da">0.02115</span></p></td><td class="cl-1e644c13"><p class="cl-1e643b8c"><span class="cl-1e6028da">0.01503</span></p></td><td class="cl-1e644c1c"><p class="cl-1e643b8c"><span class="cl-1e6028da">0.02726</span></p></td><td class="cl-1e644c1d"><p class="cl-1e643b8c"><span class="cl-1e6028da">0.00311</span></p></td></tr></tbody></table></div>
1139</div>
1140</div>
1141</div>
1142</section>
1143<section id="d.-2" class="level2 unnumbered">
1144<h2 class="unnumbered anchored" data-anchor-id="d.-2">d.&nbsp;</h2>
1145<p>attend_v_f, attend_m_f, attend_n_f, attend_v_b, attend_m_b, and attend_n_b</p>
1146<div class="cell">
1147<div class="sourceCode cell-code" id="cb26"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a>mod.movies_tsls2 <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
1148<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> movies,</span>
1149<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">log</span>(assaults) <span class="sc">~</span> attend_v <span class="sc">+</span> attend_m <span class="sc">+</span> attend_n <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1150<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a>    year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1150 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1151<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a>    month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1152<span id="cb26-6"><a href="#cb26-6" aria-hidden="true" tabindex="-1"></a>    h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1153<span id="cb26-7"><a href="#cb26-7" aria-hidden="true" tabindex="-1"></a>    w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc <span class="sc">|</span></span>
1154<span id="cb26-8"><a href="#cb26-8" aria-hidden="true" tabindex="-1"></a>    attend_v_f <span class="sc">+</span> attend_m_f <span class="sc">+</span> attend_n_f <span class="sc">+</span> attend_v_b <span class="sc">+</span> attend_m_b <span class="sc">+</span> attend_n_b <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1155<span id="cb26-9"><a href="#cb26-9" aria-hidden="true" tabindex="-1"></a>      year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1155 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1156<span id="cb26-10"><a href="#cb26-10" aria-hidden="true" tabindex="-1"></a>      month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1157<span id="cb26-11"><a href="#cb26-11" aria-hidden="true" tabindex="-1"></a>      h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1158<span id="cb26-12"><a href="#cb26-12" aria-hidden="true" tabindex="-1"></a>      w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc</span>
1159<span id="cb26-13"><a href="#cb26-13" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1160</div>
1161<div class="cell">
1162<div class="cell-output-display">
1163<div id="tbl-movies_tsls2" class="anchored">
1164
1165<div class="tabwid"><style>.cl-1e8bfb22{}.cl-1e84af7a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e84af84{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1e84af8e{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(51, 51, 51, 1.00);background-color:transparent;}.cl-1e879a32{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e879a3c{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1e87ac52{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac5c{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac5d{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac5e{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac66{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac67{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac70{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac71{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac72{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac7a{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac84{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac85{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac86{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac8e{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac8f{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac98{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac99{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87ac9a{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87aca2{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acac{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acad{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acae{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acaf{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acb6{width:1.007in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1e87acb7{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(255, 255, 255, 0.00);border-top: 0 solid rgba(255, 255, 255, 0.00);border-left: 0 solid rgba(255, 255, 255, 0.00);border-right: 0 solid rgba(255, 255, 255, 0.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1e8bfb22"><caption>Table&nbsp;13:  <p>Movies TSLS(2) Stage 2 Result</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1e87ac52"><p class="cl-1e879a32"><span class="cl-1e84af7a">Var.Name</span></p></th><th class="cl-1e87ac5c"><p class="cl-1e879a3c"><span class="cl-1e84af7a">Estimate</span></p></th><th class="cl-1e87ac5d"><p class="cl-1e879a3c"><span class="cl-1e84af7a">Std. Error</span></p></th><th class="cl-1e87ac5e"><p class="cl-1e879a3c"><span class="cl-1e84af7a">t value</span></p></th><th class="cl-1e87ac66"><p class="cl-1e879a3c"><span class="cl-1e84af7a">Pr(&gt;|t|)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1e87ac67"><p class="cl-1e879a32"><span class="cl-1e84af84">(Intercept)</span></p></td><td class="cl-1e87ac70"><p class="cl-1e879a3c"><span class="cl-1e84af84">6.92252</span></p></td><td class="cl-1e87ac71"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.02644</span></p></td><td class="cl-1e87ac72"><p class="cl-1e879a3c"><span class="cl-1e84af84">261.85541</span></p></td><td class="cl-1e87ac7a"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.00000</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e87ac84"><p class="cl-1e879a32"><span class="cl-1e84af84">attend_v</span></p></td><td class="cl-1e87ac85"><p class="cl-1e879a3c"><span class="cl-1e84af84">-0.00317</span></p></td><td class="cl-1e87ac86"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.00205</span></p></td><td class="cl-1e87ac8e"><p class="cl-1e879a3c"><span class="cl-1e84af84">-1.54546</span></p></td><td class="cl-1e87ac8f"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.12290</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e87ac84"><p class="cl-1e879a32"><span class="cl-1e84af84">attend_m</span></p></td><td class="cl-1e87ac85"><p class="cl-1e879a3c"><span class="cl-1e84af84">-0.00412</span></p></td><td class="cl-1e87ac86"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.00151</span></p></td><td class="cl-1e87ac8e"><p class="cl-1e879a3c"><span class="cl-1e84af84">-2.72450</span></p></td><td class="cl-1e87ac8f"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.00668</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1e87ac98"><p class="cl-1e879a32"><span class="cl-1e84af84">attend_n</span></p></td><td class="cl-1e87ac99"><p class="cl-1e879a3c"><span class="cl-1e84af84">-0.00258</span></p></td><td class="cl-1e87ac9a"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.00154</span></p></td><td class="cl-1e87aca2"><p class="cl-1e879a3c"><span class="cl-1e84af84">-1.67705</span></p></td><td class="cl-1e87acac"><p class="cl-1e879a3c"><span class="cl-1e84af84">0.09419</span></p></td></tr></tbody><tfoot><tr style="overflow-wrap:break-word;"><td colspan="5" class="cl-1e87acad"><p class="cl-1e879a32"><span class="cl-1e84af8e">Note. Fixed variables are hidden</span></p></td></tr></tfoot></table></div>
1166</div>
1167</div>
1168</div>
1169<div class="cell">
1170<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>movies_tsls_vm <span class="ot">&lt;-</span> mod.movies_tsls2 <span class="sc">%&gt;%</span> car<span class="sc">::</span><span class="fu">linearHypothesis</span>(</span>
1171<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a>  <span class="st">
1171"attend_v=attend_m"</span></span>
1172<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a>)</span>
1173<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a>movies_tsls_vn <span class="ot">&lt;-</span> mod.movies_tsls2 <span class="sc">%&gt;%</span> car<span class="sc">::</span><span class="fu">linearHypothesis</span>(</span>
1174<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_v = attend_n"</span></span>
1175<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1176</div>
1177<div class="cell">
1178<div class="cell-output-display">
1179<div id="tbl-tsls2_vmn_diff" class="anchored">
1180
1181<div class="tabwid"><style>.cl-1ea8e502{}.cl-1ea073d6{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1ea073e0{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1ea49402{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1ea4940c{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1ea4a690{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a69a{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a69b{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6a4{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6a5{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6ae{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6af{width:0.599in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6b8{width:0.837in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ea4a6b9{width:1.062in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1ea8e502"><caption>Table&nbsp;14:  <p>TSLS F test of v=m, v=n</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1ea4a690"><p class="cl-1ea49402"><span class="cl-1ea073d6">Test</span></p></th><th class="cl-1ea4a69a"><p class="cl-1ea4940c"><span class="cl-1ea073d6">Chisq</span></p></th><th class="cl-1ea4a69b"><p class="cl-1ea4940c"><span class="cl-1ea073d6">Pr(&gt;Chisq)</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1ea4a6a4"><p class="cl-1ea49402"><span class="cl-1ea073e0">v=m</span></p></td><td class="cl-1ea4a6a5"><p class="cl-1ea4940c"><span class="cl-1ea073e0">0.37994</span></p></td><td class="cl-1ea4a6ae"><p class="cl-1ea4940c"><span class="cl-1ea073e0">0.53763</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-1ea4a6af"><p class="cl-1ea49402"><span class="cl-1ea073e0">v=n</span></p></td><td class="cl-1ea4a6b8"><p class="cl-1ea4940c"><span class="cl-1ea073e0">0.17518</span></p></td><td class="cl-1ea4a6b9"><p class="cl-1ea4940c"><span class="cl-1ea073e0">0.67555</span></p></td></tr></tbody></table></div>
1182</div>
1183</div>
1184</div>
1185<div class="cell">
1186<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a>beta_v <span class="ot">&lt;-</span>
1186 mod.movies_tsls2<span class="sc">$</span>coefficients[<span class="st">"attend_v"</span>]</span>
1187<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a>beta_m <span class="ot">&lt;-</span> mod.movies_tsls2<span class="sc">$</span>coefficients[<span class="st">"attend_m"</span>]</span>
1188<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a>beta_n <span class="ot">&lt;-</span> mod.movies_tsls2<span class="sc">$</span>coefficients[<span class="st">"attend_n"</span>]</span>
1189<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a>effect <span class="ot">&lt;-</span> movies <span class="sc">%&gt;%</span></span>
1190<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">effect =</span> <span class="dv">6</span> <span class="sc">*</span> beta_v <span class="sc">*</span> attend_v <span class="sc">-</span></span>
1191<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a>    <span class="dv">2</span> <span class="sc">*</span> beta_m <span class="sc">*</span> attend_m <span class="sc">-</span></span>
1192<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a>    beta_n <span class="sc">*</span> attend_n) <span class="sc">%&gt;%</span></span>
1193<span id="cb28-8"><a href="#cb28-8" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(effect) <span class="sc">%&gt;%</span></span>
1194<span id="cb28-9"><a href="#cb28-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">pull</span>()</span>
1195<span id="cb28-10"><a href="#cb28-10" aria-hidden="true" tabindex="-1"></a>ci_res_tsls2 <span class="ot">&lt;-</span> <span class="fu">ci</span>(effect) <span class="sc">%&gt;%</span></span>
1196<span id="cb28-11"><a href="#cb28-11" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1197<span id="cb28-12"><a href="#cb28-12" aria-hidden="true" tabindex="-1"></a>  <span class="fu">t</span>() <span class="sc">%&gt;%</span></span>
1198<span id="cb28-13"><a href="#cb28-13" aria-hidden="true" tabindex="-1"></a>  <span class="fu">as.data.frame</span>() <span class="sc">%&gt;%</span></span>
1199<span id="cb28-14"><a href="#cb28-14" aria-hidden="true" tabindex="-1"></a>  <span class="fu">round</span>(<span class="dv">5</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1200</div>
1201<div class="cell">
1202<div class="cell-output-display">
1203<div id="tbl-movies_tsls2_ci" class="anchored">
1204
1205<div class="tabwid"><style>.cl-1eca11a0{}.cl-1ec27800{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1ec2780a{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-1ec59058{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-1ec5b146{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b150{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b15a{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b15b{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b164{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b165{width:0.879in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b16e{width:0.905in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-1ec5b16f{width:0.99in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-1eca11a0"><caption>Table&nbsp;15:  <p>Change in Assaults 95% Confidence Interval</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-1ec5b146"><p class="cl-1ec59058"><span class="cl-1ec27800">Estimate</span></p></th><th class="cl-1ec5b150"><p class="cl-1ec59058"><span class="cl-1ec27800">CI lower</span></p></th><th class="cl-1ec5b15a"><p class="cl-1ec59058"><span class="cl-1ec27800">CI upper</span></p></th><th class="cl-1ec5b15b"><p class="cl-1ec59058"><span class="cl-1ec27800">Std. Error</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-1ec5b164"><p class="cl-1ec59058"><span class="cl-1ec2780a">0.03412</span></p></td><td class="cl-1ec5b165"><p class="cl-1ec59058"><span class="cl-1ec2780a">0.02863</span></p></td><td class="cl-1ec5b16e"><p class="cl-1ec59058"><span class="cl-1ec2780a">0.03961</span></p></td><td class="cl-1ec5b16f"><p class="cl-1ec59058"><span class="cl-1ec2780a">0.0028</span></p></td></tr></tbody></table></div>
1206</div>
1207</div>
1208</div>
1209<p>The results are same comparing to b, or c.</p>
1210</section>
1211<section id="e.-2" class="level2 unnumbered">
1212<h2 class="unnumbered anchored" data-anchor-id="e.-2">e.</h2>
1213<p>Use J-test to test the overidentifying restrictions</p>
1214<div class="cell">
1215<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="co"># TSLS </span></span>
1216<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a>model <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(<span class="fu">log</span>(assaults) <span class="sc">~</span> attend_v <span class="sc">+</span> attend_m <span class="sc">+</span> attend_n <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1217<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a>    year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1217 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1218<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a>    month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1219<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a>    h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1220<span id="cb29-6"><a href="#cb29-6" aria-hidden="true" tabindex="-1"></a>    w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc <span class="sc">|</span> </span>
1221<span id="cb29-7"><a href="#cb29-7" aria-hidden="true" tabindex="-1"></a>      pr_attend_v <span class="sc">+</span> pr_attend_m <span class="sc">+</span> pr_attend_n <span class="sc">+</span> attend_v_f <span class="sc">+</span> attend_m_f <span class="sc">+</span> </span>
1222<span id="cb29-8"><a href="#cb29-8" aria-hidden="true" tabindex="-1"></a>      attend_n_f <span class="sc">+</span> attend_v_b <span class="sc">+</span> attend_m_b <span class="sc">+</span> attend_n_b <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1223<span id="cb29-9"><a href="#cb29-9" aria-hidden="true" tabindex="-1"></a>      year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1223 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1224<span id="cb29-10"><a href="#cb29-10" aria-hidden="true" tabindex="-1"></a>      month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1225<span id="cb29-11"><a href="#cb29-11" aria-hidden="true" tabindex="-1"></a>      h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1226<span id="cb29-12"><a href="#cb29-12" aria-hidden="true" tabindex="-1"></a>      w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc, </span>
1227<span id="cb29-13"><a href="#cb29-13" aria-hidden="true" tabindex="-1"></a>
1227      <span class="at">data =</span> movies)</span>
1228<span id="cb29-14"><a href="#cb29-14" aria-hidden="true" tabindex="-1"></a></span>
1229<span id="cb29-15"><a href="#cb29-15" aria-hidden="true" tabindex="-1"></a><span class="co"># Predicted values </span></span>
1230<span id="cb29-16"><a href="#cb29-16" aria-hidden="true" tabindex="-1"></a>y_hat <span class="ot">&lt;-</span> <span class="fu">predict</span>(model)</span>
1231<span id="cb29-17"><a href="#cb29-17" aria-hidden="true" tabindex="-1"></a></span>
1232<span id="cb29-18"><a href="#cb29-18" aria-hidden="true" tabindex="-1"></a><span class="co"># Residuals</span></span>
1233<span id="cb29-19"><a href="#cb29-19" aria-hidden="true" tabindex="-1"></a>u_hat <span class="ot">&lt;-</span> <span class="fu">log</span>(movies<span class="sc">$</span>assaults) <span class="sc">-</span> y_hat</span>
1234<span id="cb29-20"><a href="#cb29-20" aria-hidden="true" tabindex="-1"></a></span>
1235<span id="cb29-21"><a href="#cb29-21" aria-hidden="true" tabindex="-1"></a><span class="co"># Regress residuals on instruments and exog. vars</span></span>
1236<span id="cb29-22"><a href="#cb29-22" aria-hidden="true" tabindex="-1"></a>resid_model <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
1237<span id="cb29-23"><a href="#cb29-23" aria-hidden="true" tabindex="-1"></a>  u_hat <span class="sc">~</span> pr_attend_v <span class="sc">+</span> pr_attend_m <span class="sc">+</span> pr_attend_n <span class="sc">+</span> attend_v_f <span class="sc">+</span> attend_m_f <span class="sc">+</span> </span>
1238<span id="cb29-24"><a href="#cb29-24" aria-hidden="true" tabindex="-1"></a>      attend_n_f <span class="sc">+</span> attend_v_b <span class="sc">+</span> attend_m_b <span class="sc">+</span> attend_n_b <span class="sc">+</span> year2 <span class="sc">+</span> year3 <span class="sc">+</span> year4 <span class="sc">+</span></span>
1239<span id="cb29-25"><a href="#cb29-25" aria-hidden="true" tabindex="-1"></a>      year5 <span class="sc">+</span> year6 <span class="sc">+</span> year7 <span class="sc">+</span>
1239 year8 <span class="sc">+</span> year9 <span class="sc">+</span> year10 <span class="sc">+</span> month2 <span class="sc">+</span> month3 <span class="sc">+</span> month4 <span class="sc">+</span></span>
1240<span id="cb29-26"><a href="#cb29-26" aria-hidden="true" tabindex="-1"></a>      month5 <span class="sc">+</span> month6 <span class="sc">+</span> month7 <span class="sc">+</span> month8 <span class="sc">+</span> month9 <span class="sc">+</span> month10 <span class="sc">+</span> month11 <span class="sc">+</span> month12 <span class="sc">+</span></span>
1241<span id="cb29-27"><a href="#cb29-27" aria-hidden="true" tabindex="-1"></a>      h_chris <span class="sc">+</span> h_newyr <span class="sc">+</span> h_easter <span class="sc">+</span> h_july4 <span class="sc">+</span> h_mem <span class="sc">+</span> h_labor <span class="sc">+</span></span>
1242<span id="cb29-28"><a href="#cb29-28" aria-hidden="true" tabindex="-1"></a>      w_rain <span class="sc">+</span> w_snow <span class="sc">+</span> w_maxa <span class="sc">+</span> w_maxb <span class="sc">+</span> w_maxc <span class="sc">+</span> w_mina <span class="sc">+</span> w_minb <span class="sc">+</span> w_minc, <span class="at">data =</span> movies</span>
1243<span id="cb29-29"><a href="#cb29-29" aria-hidden="true" tabindex="-1"></a>)  </span>
1244<span id="cb29-30"><a href="#cb29-30" aria-hidden="true" tabindex="-1"></a></span>
1245<span id="cb29-31"><a href="#cb29-31" aria-hidden="true" tabindex="-1"></a><span class="co"># F-statistic</span></span>
1246<span id="cb29-32"><a href="#cb29-32" aria-hidden="true" tabindex="-1"></a>f_stat <span class="ot">&lt;-</span> resid_model <span class="sc">%&gt;%</span> car<span class="sc">::</span><span class="fu">linearHypothesis</span>(</span>
1247<span id="cb29-33"><a href="#cb29-33" aria-hidden="true" tabindex="-1"></a>  <span class="fu">c</span>(<span class="st">"pr_attend_v=0"</span>,</span>
1248<span id="cb29-34"><a href="#cb29-34" aria-hidden="true" tabindex="-1"></a>  <span class="st">"pr_attend_v=pr_attend_m"</span>,</span>
1249<span id="cb29-35"><a href="#cb29-35" aria-hidden="true" tabindex="-1"></a>  <span class="st">"pr_attend_m=pr_attend_n"</span>,</span>
1250<span id="cb29-36"><a href="#cb29-36" aria-hidden="true" tabindex="-1"></a>  <span class="st">"pr_attend_n=attend_v_f"</span>,</span>
1251<span id="cb29-37"><a href="#cb29-37" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_v_f=attend_m_f"</span>,</span>
1252<span id="cb29-38"><a href="#cb29-38" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_m_f=attend_n_f"</span>,</span>
1253<span id="cb29-39"><a href="#cb29-39" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_n_f=attend_v_b"</span>,</span>
1254<span id="cb29-40"><a href="#cb29-40" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_v_b=attend_m_b"</span>,</span>
1255<span id="cb29-41"><a href="#cb29-41" aria-hidden="true" tabindex="-1"></a>  <span class="st">"attend_m_b=attend_n_b"</span>)</span>
1256<span id="cb29-42"><a href="#cb29-42" aria-hidden="true" tabindex="-1"></a>) <span class="sc">%&gt;%</span> .[<span class="st">"F"</span>] <span class="sc">%&gt;%</span> <span class="fu">pull</span>() <span class="sc">%&gt;%</span> .[<span class="dv">2</span>]</span>
1257<span id="cb29-43"><a href="#cb29-43" aria-hidden="true" tabindex="-1"></a></span>
1258<span id="cb29-44"><a href="#cb29-44" aria-hidden="true" tabindex="-1"></a><span class="co"># J-statistic </span></span>
1259<span id="cb29-45"><a href="#cb29-45" aria-hidden="true" tabindex="-1"></a>j_stat <span class="ot">&lt;-</span> <span class="dv">9</span> <span class="sc">*</span> f_stat  </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1260</div>
1261<p>The J-stat is 8.5937298. We failed to reject the hypothesis that all instruments are exogenous, which means that some of the instruments are invalid.</p>
1262</section>
1263<section id="f.-2" class="level2 unnumbered">
1264<h2 class="unnumbered anchored" data-anchor-id="f.-2">f.&nbsp;</h2>
1265<p>The violent movies won’t affect, or will slightly decrease violent behavior.</p>
1266</section>
1267</section>
1268<section id="problem-5fertility" class="level1">
1269<h1>Problem 5(Fertility)</h1>
1270<div class="cell">
1271<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a>fertility <span class="ot">&lt;-</span> <span class="fu">read_xlsx</span>(<span class="st">"data/fertility.xlsx"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1272</div>
1273<section id="a.-3" class="level2 unnumbered">
1274<h2 class="unnumbered anchored" data-anchor-id="a.-3">a.</h2>
1275<div class="cell">
1276<div class="sourceCode cell-code" id="cb31"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="fu">attach</span>(fertility)</span>
1277<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a>mod.fertility1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
1278<span id="cb31-3"><a href="#cb31-3" aria-hidden="true" tabindex="-1"></a>  weeksm1 <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> morekids</span>
1279<span id="cb31-4"><a href="#cb31-4" aria-hidden="true" tabindex="-1"></a>)</span>
1280<span id="cb31-5"><a href="#cb31-5" aria-hidden="true" tabindex="-1"></a><span class="fu">detach</span>(fertility)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1281</div>
1282<p>The regression result suggests that women with more than two children work about 5 weeks less than women with two children.</p>
1283</section>
1284<section id="b.-3" class="level2 unnumbered">
1285<h2 class="unnumbered anchored" data-anchor-id="b.-3">b.</h2>
1286<ol type="1">
1287<li>Selection bias: The sample only includes married women who already have at least 2 children. Women who never married or had children may have different effects, so the estimates cannot be generalized.</li>
1288<li>Simultaneous causality: Labor supply may also affect fertility decisions, not just the other way around. So <em>weeksworked</em> should also be treated as endogenous.</li>
1289<li>Omitted variable bias: There may be omitted factors that affect both fertility and labor supply, such as religion, education, career ambition, etc. If these are not controlled for, the OLS estimates will be bi
1289ased.</li>
1290</ol>
1291</section>
1292<section id="c.-3" class="level2 unnumbered">
1293<h2 class="unnumbered anchored" data-anchor-id="c.-3">c.&nbsp;</h2>
1294<div class="cell">
1295<div class="sourceCode cell-code" id="cb32"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a>mod.morekids_on_samesex <span class="ot">&lt;-</span> <span class="fu">glm</span>(</span>
1296<span id="cb32-2"><a href="#cb32-2" aria-hidden="true" tabindex="-1"></a>  morekids <span class="sc">~</span> samesex,</span>
1297<span id="cb32-3"><a href="#cb32-3" aria-hidden="true" tabindex="-1"></a>  <span class="at">family =</span> <span class="fu">binomial</span>(<span class="at">link =</span> <span class="st">"logit"</span>),</span>
1298<span id="cb32-4"><a href="#cb32-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> fertility</span>
1299<span id="cb32-5"><a href="#cb32-5" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1300</div>
1301<p>To predict the effect of same sex of first two children on the third child, run a logit model of <em>morekids</em> on <em>samesex</em>, the regression result shows:</p>
1302<p><span class="math display">\[
1303Probit(morekids) = -0.635+0.287*samesex
1304\]</span></p>
1305<p>The marginal effect of <em>samesex</em> is <span class="math inline">\(0.287*(\phi(-0.635+0.287))=0.107\)</span>. When <em>samesex</em> increases from 0 to 1, the probability increases by 10.7%. This appears to be a reasonably large and meaningful effect, indicating having same-sex first two children meaningfully impacts the probability of having a third child. From the p-value of the regression result, the coefficient is statistically significant.</p>
1306</section>
1307<section id="d.-3" class="level2 unnumbered">
1308<h2 class="unnumbered anchored" data-anchor-id="d.-3">d.&nbsp;</h2>
1309<ol type="1">
1310<li>Relevance: <em>samesex</em> is correlated with <em>morekids</em>. Discussion in c.&nbsp;has proved that having same-sex first two children is positive correlated with more kids. So <em>samesex</em> satisfies the relevance criterion for an IV.</li>
1311<li>Exogeneity: <em>samesex</em> is unlikely to directly affect <em>weeksworked</em>. Whether the first two children are the same gender is exogenous to the mother’s labor supply. So <em>samesex</em> satisfies the exogeneity assumption.</li>
1312</ol>
1313</section>
1314<section id="e.-3" class="level2 unnumbered">
1315<h2 class="unnumbered anchored" data-anchor-id="e.-3">e.</h2>
1316<p>In the first stage, F-stat is 1237&gt;10, so it is not a weak instrument.</p>
1317</section>
1318<section id="f.-3" class="level2 unnumbered">
1319<h2 class="unnumbered anchored" data-anchor-id="f.-3">f.&nbsp;</h2>
1320<div class="cell">
1321<div class="sourceCode cell-code" id="cb33"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 1</span></span>
1322<span id="cb33-2"><a href="#cb33-2" aria-hidden="true" tabindex="-1"></a>mod.fertility_stage1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
1323<span id="cb33-3"><a href="#cb33-3" aria-hidden="true" tabindex="-1"></a>  morekids <span class="sc">~</span> samesex,</span>
1324<span id="cb33-4"><a href="#cb33-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> fertility</span>
1325<span id="cb33-5"><a href="#cb33-5" aria-hidden="true" tabindex="-1"></a>)</span>
1326<span id="cb33-6"><a href="#cb33-6" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 2</span></span>
1327<span id="cb33-7"><a href="#cb33-7" aria-hidden="true" tabindex="-1"></a>mod.fertility_stage2 <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
1328<span id="cb33-8"><a href="#cb33-8" aria-hidden="true" tabindex="-1"></a>  weeksm1 <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> morekids <span class="sc">|</span> samesex,</span>
1329<span id="cb33-9"><a href="#cb33-9" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span>
1329 fertility</span>
1330<span id="cb33-10"><a href="#cb33-10" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1331</div>
1332<p>From the TSLS, more than two kids decreases about -6.3 working weeks.</p>
1333</section>
1334<section id="g.-1" class="level2 unnumbered">
1335<h2 class="unnumbered anchored" data-anchor-id="g.-1">g.</h2>
1336<p>After including the variables <em>agem1, black, hispan</em>, and <em>othrace</em> in the labor supply regression, the effect of more kids is still negative, but shrink a little to 0, which is now -5.8. This is because <em>morekids</em> indeed has negative effect on labor supply, but after including fixed effect, the missing-variable bias is basically eliminated.</p>
1337<div class="cell">
1338<div class="sourceCode cell-code" id="cb34"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 1 with FE</span></span>
1339<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a>mod.fertility_stage1_fixed <span class="ot">&lt;-</span> <span class="fu">glm</span>(</span>
1340<span id="cb34-3"><a href="#cb34-3" aria-hidden="true" tabindex="-1"></a>  morekids <span class="sc">~</span> samesex <span class="sc">+</span> agem1 <span class="sc">+</span> black <span class="sc">+</span> hispan <span class="sc">+</span> othrace,</span>
1341<span id="cb34-4"><a href="#cb34-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">family =</span> <span class="fu">binomial</span>(<span class="at">link =</span> <span class="st">"logit"</span>),</span>
1342<span id="cb34-5"><a href="#cb34-5" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> fertility</span>
1343<span id="cb34-6"><a href="#cb34-6" aria-hidden="true" tabindex="-1"></a>)</span>
1344<span id="cb34-7"><a href="#cb34-7" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 2 with FE</span></span>
1345<span id="cb34-8"><a href="#cb34-8" aria-hidden="true" tabindex="-1"></a>mod.fertility_stage2_fixed <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
1346<span id="cb34-9"><a href="#cb34-9" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> fertility,</span>
1347<span id="cb34-10"><a href="#cb34-10" aria-hidden="true" tabindex="-1"></a>  weeksm1 <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> morekids <span class="sc">+</span> agem1 <span class="sc">+</span> black <span class="sc">+</span> hispan <span class="sc">+</span> othrace <span class="sc">|</span></span>
1348<span id="cb34-11"><a href="#cb34-11" aria-hidden="true" tabindex="-1"></a>    samesex <span class="sc">+</span> agem1 <span class="sc">+</span> black <span class="sc">+</span> hispan <span class="sc">+</span> othrace</span>
1349<span id="cb34-12"><a href="#cb34-12" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1350</div>
1351<div class="cell">
1352<div class="cell-output cell-output-stderr">
1353<pre><code>Profiled confidence intervals may take longer time to compute.
1354  Use `ci_method="wald"` for faster computation of CIs.</code></pre>
1355</div>
1356<div class="cell-output-display">
1357<div id="tbl-fertility" class="anchored">
1358<table data-quarto-postprocess="true" class="table table-sm table-striped small">
1359<caption>Table&nbsp;16: Fertility Regression Results</caption>
1360<colgroup>
1361<col style="width: 16%">
1362<col style="width: 16%">
1363<col style="width: 16%">
1364<col style="width: 16%">
1365<col style="width: 16%">
1366<col style="width: 16%">
1367</colgroup>
1368<tbody>
1369<tr class="odd">
1370<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">&nbsp;</td>
1371<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">Weekswork</td>
1372<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 1</td>
1373<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 2</td>
1374<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage1(FE)</td>
1375<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage2(FE)</td>
1376</tr>
1377<tr class="even">
1378<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Predictors</td>
1379<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1380<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1381<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1382<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Log-Odds</td>
1383<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1384</tr>
1385<tr class="odd">
1386<td style="text-align: center;">(Intercept)</td>
1387<td style="text-align: center;">21.0684 <sup>***</sup><br>
1388(0.0547)</td>
1389<td style="text-align: center;">0.3464 <sup>***</sup><br>
1390(0.0014)</td>
1391<td style="text-align: center;">21.4211 <sup>***</sup><br>
1392(0.4870)</td>
1393<td style="text-align: center;">-2.7832 <sup>***</sup><br>
1394(0.0391)</td>
1395<td style="text-align: center;">-4.7919 <sup>***</sup><br>
1396(0.4066)</td>
1397</tr>
1398<tr class="even">
1399<td style="text-align: center;">morekids</td>
1400<td style="text-align: center;">-5.3870 <sup>***</sup><br>
1401(0.0886)</td>
1402<td style="text-align: center;"></td>
1403<td style="text-align: center;">-6.3137 <sup>***</sup><br>
1404(1.2746)</td>
1405<td style="text-align: center;"></td>
1406<td style="text-align: center;">-5.8211 <sup>***</sup><br>
1407(1.2463)</td>
1408</tr>
1409<tr class="odd">
1410<td style="text-align: center;">samesex</td>
1411<td style="text-align: center;"></td>
1412<td style="text-align: center;">0.0675 <sup>***</sup><br>
1413(0.0019)</td>
1414<td style="text-align: center;"></td>
1415<td style="text-align: center;">0.2948 <sup>***</sup><br>
1416(0.0083)</td>
1417<td style="text-align: center;"></td>
1418</tr>
1419<tr class="even">
1420<td style="text-align: center;">agem1</td>
1421<td style="text-align: center;"></td>
1422<td style="text-align: center;"></td>
1423<td style="text-align: center;"></td>
1424<td style="text-align: center;">0.0678 <sup>***</sup><br>
1425(0.0013)</td>
1426<td style="text-align: center;">0.8316 <sup>***</sup><br>
1427(0.0229)</td>
1428</tr>
1429<tr class="odd">
1430<td style="text-align: center;">black</td>
1431<td style="text-align: center;"></td>
1432<td style="text-align: center;"></td>
1433<td style="text-align: center;"></td>
1434<td style="text-align: center;">0.4254 <sup>***</sup><br>
1435(0.0182)</td>
1436<td style="text-align: center;">11.6233 <sup>***</sup><br>
1437(0.2289)</td>
1438</tr>
1439<tr class="even">
1440<td style="text-align: center;">hispan</td>
1441<td style="text-align: center;"></td>
1442<td style="text-align: center;"></td>
1443<td style="text-align: center;"></td>
1444<td style="text-align: center;">0.6321 <sup>***</sup><br>
1445(0.0170)</td>
1446<td style="text-align: center;">
14460.4042 <sup></sup><br>
1447(0.2599)</td>
1448</tr>
1449<tr class="odd">
1450<td style="text-align: center;">othrace</td>
1451<td style="text-align: center;"></td>
1452<td style="text-align: center;"></td>
1453<td style="text-align: center;"></td>
1454<td style="text-align: center;">0.1175 <sup>***</sup><br>
1455(0.0194)</td>
1456<td style="text-align: center;">2.1310 <sup>***</sup><br>
1457(0.2059)</td>
1458</tr>
1459<tr class="even">
1460<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">Observations</td>
1461<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">254654</td>
1462<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">254654</td>
1463<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">254654</td>
1464<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">254654</td>
1465<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">254654</td>
1466</tr>
1467<tr class="odd">
1468<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">R<sup>2</sup> / R<sup>2</sup> adjusted</td>
1469<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.014 / 0.014</td>
1470<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.005 / 0.005</td>
1471<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.014 / 0.014</td>
1472<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.024</td>
1473<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.044 / 0.044</td>
1474</tr>
1475<tr class="even">
1476<td colspan="6" style="text-align: right; font-style: italic; border-top: double black;">* p&lt;0.05&nbsp;&nbsp;&nbsp;** p&lt;0.01&nbsp;&nbsp;&nbsp;*** p&lt;0.001</td>
1477</tr>
1478</tbody>
1479</table>
1480</div>
1481
1482
1483</div>
1484</div>
1485</section>
1486</section>
1487<section id="problem-6weakiv" class="level1">
1488<h1>Problem 6(WeakIV)</h1>
1489<section id="a.-4" class="level2 unnumbered">
1490<h2 class="unnumbered anchored" data-anchor-id="a.-4">a.</h2>
1491<p>From the TSLS result, <span class="math inline">\(\hat{beta}_1^{TSLS}=1.158\)</span>, its standard error is 0.427, and its 95% confidence interval is (0.316, 2.000).</p>
1492</section>
1493<section id="b.-4" class="level2 unnumbered">
1494<h2 class="unnumbered anchored" data-anchor-id="b.-4">b.</h2>
1495<p>The F-statistic of the regression of X on Z is 4.6, which is smaller than 10, indicating that Z is a weak instrument.</p>
1496</section>
1497<section id="c.-4" class="level2 unnumbered">
1498<h2 class="unnumbered anchored" data-anchor-id="c.-4">c.&nbsp;</h2>
1499<div class="cell">
1500<div class="sourceCode cell-code" id="cb36"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a>weak_iv <span class="ot">&lt;-</span> <span class="fu">read_xls</span>(<span class="st">"data/WeakInstrument.xls"</span>)</span>
1501<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a>mod.weakiv_stage1 <span class="ot">&lt;-</span> <span class="fu">lm</span>(</span>
1502<span id="cb36-3"><a href="#cb36-3" aria-hidden="true" tabindex="-1"></a>  x <span class="sc">~</span> <span class="dv">1</span> <span class="sc">+</span> z,</span>
1503<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> weak_iv</span>
1504<span id="cb36-5"><a href="#cb36-5" aria-hidden="true" tabindex="-1"></a>)</span>
1505<span id="cb36-6"><a href="#cb36-6" aria-hidden="true" tabindex="-1"></a>mod.weakiv_stage2 <span class="ot">&lt;-</span> <span class="fu">ivreg</span>(</span>
1506<span id="cb36-7"><a href="#cb36-7" aria-hidden="true" tabindex="-1"></a>  <span class="at">data =</span> weak_iv,</span>
1507<span id="cb36-8"><a href="#cb36-8" aria-hidden="true" tabindex="-1"></a>  y <span class="sc">~</span> x <span class="sc">|</span> z</span>
1508<span id="cb36-9"><a href="#cb36-9" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1509</div>
1510<div class="cell">
1511<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ivmodel)</span>
1512<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>ar_res <span class="ot">&lt;-</span> <span class="fu">ivmodel</span>(<span class="at">Y =</span> weak_iv<span class="sc">$</span>y, <span class="at">D =</span> weak_iv<span class="sc">$</span>x, <span class="at">Z =</span> weak_iv<span class="sc">$</span>z) <span class="sc">%&gt;%</span> <span class="fu">AR.test</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1513</div>
1514<p>The F-stat of the Anderson-Rubin test if 1.6349195, its confidence interval is ([-7.20451207607717, 1.7291568975746]).</p>
1515</section>
1516<section id="d.-4" class="level2 unnumbered">
1517<h2 class="unnumbered anchored" data-anchor-id="d.-4">d.&nbsp;</h2>
1518<p>The confidence interval in (a) will be unreliable because there is a weak instrument problem (F &lt; 10). The Anderson-Rubin CI in (c) is robust to weak instruments so will be more reliable.</p>
1519<div class="cell">
1520<div class="sourceCode cell-code" id="cb38"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a><span class="fu">tab_model</span>(mod.weakiv_stage1, mod.weakiv_stage2,</span>
1521<span id="cb38-2"><a href="#cb38-2" aria-hidden="true" tabindex="-1"></a>  <span class="at">digits =</span> <span class="dv">3</span>, <span class="at">p.style =</span> <span class="st">
1521"stars"</span>,</span>
1522<span id="cb38-3"><a href="#cb38-3" aria-hidden="true" tabindex="-1"></a>  <span class="at">CSS =</span> <span class="fu">list</span>(<span class="at">css.tdata =</span> <span class="st">"text-align: center;"</span>),</span>
1523<span id="cb38-4"><a href="#cb38-4" aria-hidden="true" tabindex="-1"></a>  <span class="at">dv.labels =</span> <span class="fu">c</span>(<span class="st">"TSLS stage 1"</span>, <span class="st">"TSLS stage 2"</span>)</span>
1524<span id="cb38-5"><a href="#cb38-5" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1525<div class="cell-output-display">
1526<div id="tbl-weak_iv" class="anchored">
1527<table data-quarto-postprocess="true" class="table table-sm table-striped small">
1528<caption>Table&nbsp;17: WeakIV TSLS Results</caption>
1529<tbody>
1530<tr class="odd">
1531<td data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">&nbsp;</td>
1532<td colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 1</td>
1533<td colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-top: double; font-style: italic; font-weight: normal; padding: 0.2cm; border-bottom: 1px solid black;">TSLS stage 2</td>
1534</tr>
1535<tr class="even">
1536<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Predictors</td>
1537<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1538<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">CI</td>
1539<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">Estimates</td>
1540<td style="text-align: center; border-bottom: 1px solid; font-style: italic; font-weight: normal; border-bottom: 1px solid black;">CI</td>
1541</tr>
1542<tr class="odd">
1543<td style="text-align: center;">(Intercept)</td>
1544<td style="text-align: center;">0.083 <sup></sup></td>
1545<td style="text-align: center;">-0.051&nbsp;–&nbsp;0.216</td>
1546<td style="text-align: center;">-0.014 <sup></sup></td>
1547<td style="text-align: center;">-0.150&nbsp;–&nbsp;0.122</td>
1548</tr>
1549<tr class="even">
1550<td style="text-align: center;">z</td>
1551<td style="text-align: center;">0.135 <sup>*</sup></td>
1552<td style="text-align: center;">0.010&nbsp;–&nbsp;0.259</td>
1553<td style="text-align: center;"></td>
1554<td style="text-align: center;"></td>
1555</tr>
1556<tr class="odd">
1557<td style="text-align: center;">x</td>
1558<td style="text-align: center;"></td>
1559<td style="text-align: center;"></td>
1560<td style="text-align: center;">1.158 <sup>**</sup></td>
1561<td style="text-align: center;">0.316&nbsp;–&nbsp;2.000</td>
1562</tr>
1563<tr class="even">
1564<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">Observations</td>
1565<td colspan="2" style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">200</td>
1566<td colspan="2" style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm; border-top: 1px solid;">200</td>
1567</tr>
1568<tr class="odd">
1569<td style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">R<sup>2</sup> / R<sup>2</sup> adjusted</td>
1570<td colspan="2" style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.023 / 0.018</td>
1571<td colspan="2" style="text-align: center; padding-top: 0.1cm; padding-bottom: 0.1cm;">0.780 / 0.778</td>
1572</tr>
1573<tr class="even">
1574<td colspan="5" style="text-align: right; font-style: italic; border-top: double black;">* p&lt;0.05&nbsp;&nbsp;&nbsp;** p&lt;0.01&nbsp;&nbsp;&nbsp;*** p&lt;0.001</td>
1575</tr>
1576</tbody>
1577</table>
1578</div>
1579
1580
1581</div>
1582</div>
1583</section>
1584</section>
1585<section id="problem-7names" class="level1">
1586<h1>Problem 7(Names)</h1>
1587<section id="附加说明" class="level2">
1588<h2 class="anchored" data-anchor-id="附加说明">附加说明</h2>
1589<p>这里要感谢@Jingyi(公开网页我就不打全名了)同学的指正,之前犯了个低级错误,把call back rate 算错了,现已更正。</p>
1590<p>另外,这道题也可用简单线性回归来做,例如第一问,回归callback rate on black,得到black的系数即为差异,其置信区间即为差异的置信区间。我已经验证过了,结果和下方公式计算完全一致。再次感谢@Jingyi同学!</p>
1591</section>
1592<section id="a.-5" class="level2 unnumbered">
1593<h2 class="unnumbered anchored" data-anchor-id="a.-5">a.</h2>
1594<p>The callback rate of white is 0.0965, and which of black is 0.0645. The 95% confidence interval for the difference of call back rates is (0.0168, 0.0473). It does not include 0, so the difference is statistically significant at 0.05 level. In real world sense, white have more probability of 3.2% to receive the callback, which is about 50% higher than that probability for African Americans. It is a large and meaningful number.</p>
1595<div class="cell">
1596<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a>Names <span class="ot">&lt;-</span> <span class="fu">read_xls</span>(<span class="st">"data/Names.xls"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1597</div>
1598<div class="cell">
1599<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a><span class="co"># develop some functions to use</span></span>
1600<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a>callback_rate <span class="ot">&lt;-</span> <span class="cf">function</span>(df) {</span>
1601<span id="cb40-3"><a href="#cb40-3" aria-hidden="true" tabindex="-1"></a>  (df <span class="sc">%&gt;%</span></span>
1602<span id="cb40-4"><a href="#cb40-4" aria-hidden="true" tabindex="-1"></a>    <span class="fu">filter</span>(call_back <span class="sc">==</span> <span class="dv">1</span>) <span class="sc">%&gt;%</span></span>
1603<span id="cb40-5"><a href="#cb40-5" aria-hidden="true" tabindex="-1"></a>    <span class="fu">nrow</span>()) <span class="sc">/</span> <span class="fu">nrow</span>(df)</span>
1604<span id="cb40-6"><a href="#cb40-6" aria-hidden="true" tabindex="-1"></a>}</span>
1605<span id="cb40-7"><a href="#cb40-7" aria-hidden="true" tabindex="-1"></a></span>
1606<span id="cb40-8"><a href="#cb40-8" aria-hidden="true" tabindex="-1"></a><span class="co">
1606# https://www.stats4stem.org/confidence-interval-two-proportions-difference-of-proportions</span></span>
1607<span id="cb40-9"><a href="#cb40-9" aria-hidden="true" tabindex="-1"></a>cbr_diff_ci <span class="ot">&lt;-</span> <span class="cf">function</span>(cate1, cate2) {</span>
1608<span id="cb40-10"><a href="#cb40-10" aria-hidden="true" tabindex="-1"></a>  cbr1 <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(cate1)</span>
1609<span id="cb40-11"><a href="#cb40-11" aria-hidden="true" tabindex="-1"></a>  cbr2 <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(cate2)</span>
1610<span id="cb40-12"><a href="#cb40-12" aria-hidden="true" tabindex="-1"></a>  n1 <span class="ot">&lt;-</span> cate1 <span class="sc">%&gt;%</span> <span class="fu">nrow</span>()</span>
1611<span id="cb40-13"><a href="#cb40-13" aria-hidden="true" tabindex="-1"></a>  n2 <span class="ot">&lt;-</span> cate2 <span class="sc">%&gt;%</span> <span class="fu">nrow</span>()</span>
1612<span id="cb40-14"><a href="#cb40-14" aria-hidden="true" tabindex="-1"></a>  diff <span class="ot">&lt;-</span> <span class="fu">abs</span>(cbr1 <span class="sc">-</span> cbr2)</span>
1613<span id="cb40-15"><a href="#cb40-15" aria-hidden="true" tabindex="-1"></a>  <span class="co"># Standard error of difference in call-back rates</span></span>
1614<span id="cb40-16"><a href="#cb40-16" aria-hidden="true" tabindex="-1"></a>  se <span class="ot">&lt;-</span> <span class="fu">sqrt</span>(cbr1 <span class="sc">*</span> (<span class="dv">1</span> <span class="sc">-</span> cbr1) <span class="sc">/</span> n1 <span class="sc">+</span> cbr2 <span class="sc">*</span> (<span class="dv">1</span> <span class="sc">-</span> cbr2) <span class="sc">/</span> n2)</span>
1615<span id="cb40-17"><a href="#cb40-17" aria-hidden="true" tabindex="-1"></a>  CI_low <span class="ot">&lt;-</span> diff <span class="sc">-</span> <span class="fl">1.96</span> <span class="sc">*</span> se</span>
1616<span id="cb40-18"><a href="#cb40-18" aria-hidden="true" tabindex="-1"></a>  CI_high <span class="ot">&lt;-</span> diff <span class="sc">+</span> <span class="fl">1.96</span> <span class="sc">*</span> se</span>
1617<span id="cb40-19"><a href="#cb40-19" aria-hidden="true" tabindex="-1"></a>  <span class="fu">c</span>(CI_low, CI_high)</span>
1618<span id="cb40-20"><a href="#cb40-20" aria-hidden="true" tabindex="-1"></a>}</span>
1619<span id="cb40-21"><a href="#cb40-21" aria-hidden="true" tabindex="-1"></a></span>
1620<span id="cb40-22"><a href="#cb40-22" aria-hidden="true" tabindex="-1"></a>white_vs_black <span class="ot">&lt;-</span> <span class="cf">function</span>(df) {</span>
1621<span id="cb40-23"><a href="#cb40-23" aria-hidden="true" tabindex="-1"></a>  white <span class="ot">&lt;-</span> df <span class="sc">%&gt;%</span> <span class="fu">filter</span>(black <span class="sc">==</span> <span class="dv">0</span>)</span>
1622<span id="cb40-24"><a href="#cb40-24" aria-hidden="true" tabindex="-1"></a>  black <span class="ot">&lt;-</span> df <span class="sc">%&gt;%</span> <span class="fu">filter</span>(black <span class="sc">==</span> <span class="dv">1</span>)</span>
1623<span id="cb40-25"><a href="#cb40-25" aria-hidden="true" tabindex="-1"></a>  cbr_white <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(white)</span>
1624<span id="cb40-26"><a href="#cb40-26" aria-hidden="true" tabindex="-1"></a>  cbr_black <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(black)</span>
1625<span id="cb40-27"><a href="#cb40-27" aria-hidden="true" tabindex="-1"></a>  diff_ci <span class="ot">&lt;-</span> <span class="fu">cbr_diff_ci</span>(white, black)</span>
1626<span id="cb40-28"><a href="#cb40-28" aria-hidden="true" tabindex="-1"></a>  <span class="fu">tibble</span>(</span>
1627<span id="cb40-29"><a href="#cb40-29" aria-hidden="true" tabindex="-1"></a>    <span class="at">race =</span> <span class="fu">c</span>(<span class="st">"white"</span>, <span class="st">"black"</span>),</span>
1628<span id="cb40-30"><a href="#cb40-30" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">callback rate</span><span class="st">`</span> <span class="ot">=</span> <span class="fu">c</span>(cbr_white, cbr_black),</span>
1629<span id="cb40-31"><a href="#cb40-31" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">CI_lower</span><span class="st">`</span> <span class="ot">=</span>
1629 diff_ci[<span class="dv">1</span>],</span>
1630<span id="cb40-32"><a href="#cb40-32" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">CI_upper</span><span class="st">`</span> <span class="ot">=</span> diff_ci[<span class="dv">2</span>]</span>
1631<span id="cb40-33"><a href="#cb40-33" aria-hidden="true" tabindex="-1"></a>  )</span>
1632<span id="cb40-34"><a href="#cb40-34" aria-hidden="true" tabindex="-1"></a>}</span>
1633<span id="cb40-35"><a href="#cb40-35" aria-hidden="true" tabindex="-1"></a></span>
1634<span id="cb40-36"><a href="#cb40-36" aria-hidden="true" tabindex="-1"></a><span class="co"># generate result of white &amp; black</span></span>
1635<span id="cb40-37"><a href="#cb40-37" aria-hidden="true" tabindex="-1"></a>white_black_diff <span class="ot">&lt;-</span> <span class="fu">white_vs_black</span>(Names)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1636</div>
1637<div class="cell">
1638<div class="cell-output-display">
1639<div id="tbl-cb_rates" class="anchored">
1640
1641<div class="tabwid"><style>.cl-32a53cae{}.cl-329e0e7a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-329e0e84{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-32a0e410{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32a0e41a{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32a0e41b{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32a0f54a{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f54b{width:1.143in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f554{width:0.888in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f555{width:0.914in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f55e{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f568{width:1.143in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f572{width:0.888in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f573{width:0.914in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f574{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f57c{width:1.143in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f57d{width:0.888in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32a0f57e{width:0.914in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-32a53cae"><caption>Table&nbsp;18:  <p>Callback Rates between Black and White</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-32a0f54a"><p class="cl-32a0e410"><span class="cl-329e0e7a">race</span></p></th><th class="cl-32a0f54b"><p class="cl-32a0e41a"><span class="cl-329e0e7a">callback rate</span></p></th><th class="cl-32a0f554"><p class="cl-32a0e41a"><span class="cl-329e0e7a">CI_lower</span></p></th><th class="cl-32a0f555"><p class="cl-32a0e41a"><span class="cl-329e0e7a">CI_upper</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-32a0f55e"><p class="cl-32a0e41b"><span class="cl-329e0e84">white</span></p></td><td class="cl-32a0f568"><p class="cl-32a0e41b"><span class="cl-329e0e84">0.0965</span></p></td><td rowspan="2" class="cl-32a0f572"><p class="cl-32a0e41b"><span class="cl-329e0e84">0.0168</span></p></td><td rowspan="2" class="cl-32a0f573"><p class="cl-32a0e41b"><span class="cl-329e0e84">0.0473</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32a0f574"><p class="cl-32a0e41b"><span class="cl-329e0e84">black</span></p></td><td class="cl-32a0f57c"><p class="cl-32a0e41b"><span class="cl-329e0e84">0.0645</span></p></td></tr></tbody></table></div>
1642</div>
1643</div>
1644</div>
1645</section>
1646<section id="b.-5" class="level2 unnumbered">
1647<h2 class="unnumbered anchored" data-anchor-id="b.-5">b.</h2>
1648<p>To determine if the African American/white call-back rate differential is different for men than for women, we can compare these two confidence intervals. Since they overlap substantially, we cannot conclude that there is a significant difference in the African American/white call-back rate differential between men and women.</p>
1649<div class="cell">
1650<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>male <span class="ot">&lt;-</span> Names <span class="sc">%&gt;%</span> <span class="fu">filter</span>(female <span class="sc">==</span> <span class="dv">0</span>)</span>
1651<span id="cb41-2"><a href="#cb41-2" aria-hidden="true" tabindex="-1"></a>female <span class="ot">&lt;-</span> Names <span class="sc">%&gt;%</span> <span class="fu">filter</span>(female <span class="sc">==</span> <span class="dv">1</span>)</span>
1652<span id="cb41-3"><a href="#cb41-3" aria-hidden="true" tabindex="-1"></a></span>
1653<span id="cb41-4"><a href="#cb41-4" aria-hidden="true" tabindex="-1"></a><span class="co">#   white and black callback rate difference of male</span></span>
1654<span id="cb41-5"><a href="#cb41-5" aria-hidden="true" tabindex="-1"></a>male_cbr_diff_wb <span class="ot">&lt;-</span> <span class="fu">white_vs_black</span>(male) <span class="sc">%&gt;%</span></span>
1655<span id="cb41-6"><a href="#cb41-6" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">gender =</span> <span class="st">
1655"male"</span>, <span class="at">.before =</span> race)</span>
1656<span id="cb41-7"><a href="#cb41-7" aria-hidden="true" tabindex="-1"></a>female_cbr_diff_wb <span class="ot">&lt;-</span> <span class="fu">white_vs_black</span>(female) <span class="sc">%&gt;%</span></span>
1657<span id="cb41-8"><a href="#cb41-8" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">gender =</span> <span class="st">"female"</span>, <span class="at">.before =</span> race)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1658</div>
1659<div class="cell">
1660<div class="cell-output-display">
1661<div id="tbl-cbrate_male_female" class="anchored">
1662
1663<div class="tabwid"><style>.cl-32ce2f42{}.cl-32c6944e{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-32c69458{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-32c9966c{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32c99680{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32c99681{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32c9ab48{width:0.795in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab49{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab52{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab53{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab5c{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab5d{width:0.795in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab66{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab70{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab7a{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab7b{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab84{width:0.795in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab8e{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab8f{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9ab98{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9aba2{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9aba3{width:0.795in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9abac{width:0.642in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9abad{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9abb6{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32c9abb7{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-32ce2f42"><caption>Table&nbsp;
166319:  <p>Call-back Rate &amp; CI for Male and Female, Black and White</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-32c9ab48"><p class="cl-32c9966c"><span class="cl-32c6944e">gender</span></p></th><th class="cl-32c9ab49"><p class="cl-32c9966c"><span class="cl-32c6944e">race</span></p></th><th class="cl-32c9ab52"><p class="cl-32c99680"><span class="cl-32c6944e">callback rate</span></p></th><th class="cl-32c9ab53"><p class="cl-32c99680"><span class="cl-32c6944e">CI_lower</span></p></th><th class="cl-32c9ab5c"><p class="cl-32c99680"><span class="cl-32c6944e">CI_upper</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td rowspan="2" class="cl-32c9ab5d"><p class="cl-32c99681"><span class="cl-32c69458">male</span></p></td><td class="cl-32c9ab66"><p class="cl-32c99681"><span class="cl-32c69458">white</span></p></td><td class="cl-32c9ab70"><p class="cl-32c99681"><span class="cl-32c69458">0.0887</span></p></td><td rowspan="2" class="cl-32c9ab7a"><p class="cl-32c99681"><span class="cl-32c69458">0.0000</span></p></td><td rowspan="2" class="cl-32c9ab7b"><p class="cl-32c99681"><span class="cl-32c69458">0.0608</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32c9ab8e"><p class="cl-32c99681"><span class="cl-32c69458">black</span></p></td><td class="cl-32c9ab8f"><p class="cl-32c99681"><span class="cl-32c69458">0.0583</span></p></td></tr><tr style="overflow-wrap:break-word;"><td rowspan="2" class="cl-32c9aba3"><p class="cl-32c99681"><span class="cl-32c69458">female</span></p></td><td class="cl-32c9abac"><p class="cl-32c99681"><span class="cl-32c69458">white</span></p></td><td class="cl-32c9abad"><p class="cl-32c99681"><span class="cl-32c69458">0.0989</span></p></td><td rowspan="2" class="cl-32c9abb6"><p class="cl-32c99681"><span class="cl-32c69458">0.0150</span></p></td><td rowspan="2" class="cl-32c9abb7"><p class="cl-32c99681"><span class="cl-32c69458">0.0503</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32c9abac"><p class="cl-32c99681"><span class="cl-32c69458">black</span></p></td><td class="cl-32c9abad"><p class="cl-32c99681"><span class="cl-32c69458">0.0663</span></p></td></tr></tbody></table></div>
1664</div>
1665</div>
1666</div>
1667</section>
1668<section id="c.-5" class="level2 unnumbered">
1669<h2 class="unnumbered anchored" data-anchor-id="c.-5">c.&nbsp;</h2>
1670<p>From the results, the confidence intervals all include 0, so all of the differences are statistically significant.</p>
1671<div class="cell">
1672<div class="sourceCode cell-code" id="cb42"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a>high_vs_low <span class="ot">&lt;-</span> <span class="cf">function</span>(df) {</span>
1673<span id="cb42-2"><a href="#cb42-2" aria-hidden="true" tabindex="-1"></a>  h <span class="ot">&lt;-</span> df <span class="sc">%&gt;%</span> <span class="fu">filter</span>(high <span class="sc">==</span> <span class="dv">1</span>)</span>
1674<span id="cb42-3"><a href="#cb42-3" aria-hidden="true" tabindex="-1"></a>  l <span class="ot">&lt;-</span> df <span class="sc">%&gt;%</span> <span class="fu">filter</span>(high <span class="sc">==</span> <span class="dv">0</span>)</span>
1675<span id="cb42-4"><a href="#cb42-4" aria-hidden="true" tabindex="-1"></a>  cbr_h <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(h)</span>
1676<span id="cb42-5"><a href="#cb42-5" aria-hidden="true" tabindex="-1"></a>  cbr_l <span class="ot">&lt;-</span> <span class="fu">callback_rate</span>(l)</span>
1677<span id="cb42-6"><a href="#cb42-6" aria-hidden="true" tabindex="-1"></a>  diff_ci <span class="ot">&lt;-</span> <span class="fu">cbr_diff_ci</span>(h, l)</span>
1678<span id="cb42-7"><a href="#cb42-7" aria-hidden="true" tabindex="-1"></a>  <span class="fu">tibble</span>(</span>
1679<span id="cb42-8"><a href="#cb42-8" aria-hidden="true" tabindex="-1"></a>    <span class="at">quality =</span> <span class="fu">c</span>(<span class="st">"high"</span>, <span class="st">"low"</span>),</span>
1680<span id="cb42-9"><a href="#cb42-9" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">callback rate</span><span class="st">`</span> <span class="ot">=</span> <span class="fu">c</span>(cbr_h, cbr_l),</span>
1681<span id="cb42-10"><a href="#cb42-10" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">CI_lower</span><span class="st">`</span> <span class="ot">=</span>
1681 diff_ci[<span class="dv">1</span>],</span>
1682<span id="cb42-11"><a href="#cb42-11" aria-hidden="true" tabindex="-1"></a>    <span class="st">`</span><span class="at">CI_upper</span><span class="st">`</span> <span class="ot">=</span> diff_ci[<span class="dv">2</span>]</span>
1683<span id="cb42-12"><a href="#cb42-12" aria-hidden="true" tabindex="-1"></a>  )</span>
1684<span id="cb42-13"><a href="#cb42-13" aria-hidden="true" tabindex="-1"></a>}</span>
1685<span id="cb42-14"><a href="#cb42-14" aria-hidden="true" tabindex="-1"></a></span>
1686<span id="cb42-15"><a href="#cb42-15" aria-hidden="true" tabindex="-1"></a><span class="co"># classify them into different tibbles</span></span>
1687<span id="cb42-16"><a href="#cb42-16" aria-hidden="true" tabindex="-1"></a>white <span class="ot">&lt;-</span> Names <span class="sc">%&gt;%</span> <span class="fu">filter</span>(black <span class="sc">==</span> <span class="dv">0</span>)</span>
1688<span id="cb42-17"><a href="#cb42-17" aria-hidden="true" tabindex="-1"></a>black <span class="ot">&lt;-</span> Names <span class="sc">%&gt;%</span> <span class="fu">filter</span>(black <span class="sc">==</span> <span class="dv">1</span>)</span>
1689<span id="cb42-18"><a href="#cb42-18" aria-hidden="true" tabindex="-1"></a></span>
1690<span id="cb42-19"><a href="#cb42-19" aria-hidden="true" tabindex="-1"></a>high_vs_low_all <span class="ot">&lt;-</span> <span class="fu">high_vs_low</span>(Names) <span class="sc">%&gt;%</span> <span class="fu">mutate</span>(<span class="at">catogory =</span> <span class="st">"all"</span>, <span class="at">.before =</span> quality)</span>
1691<span id="cb42-20"><a href="#cb42-20" aria-hidden="true" tabindex="-1"></a>high_vs_low_white <span class="ot">&lt;-</span> <span class="fu">high_vs_low</span>(white) <span class="sc">%&gt;%</span> <span class="fu">mutate</span>(<span class="at">catogory =</span> <span class="st">"white"</span>, <span class="at">.before =</span> quality)</span>
1692<span id="cb42-21"><a href="#cb42-21" aria-hidden="true" tabindex="-1"></a>high_vs_low_black <span class="ot">&lt;-</span> <span class="fu">high_vs_low</span>(black) <span class="sc">%&gt;%</span> <span class="fu">mutate</span>(<span class="at">catogory =</span> <span class="st">"black"</span>, <span class="at">.before =</span> quality)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1693</div>
1694<div class="cell">
1695<div class="cell-output-display">
1696<div id="tbl-cbr_quality" class="anchored">
1697
1698<div class="tabwid"><style>.cl-32fe52b2{}.cl-32f6ca6a{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-32f6ca7e{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-32f9bb9e{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32f9bba8{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32f9bba9{margin:0;text-align:center;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-32f9ce68{width:0.93in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce72{width:0.778in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce7c{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce7d{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce7e{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce86{width:0.93in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce87{width:0.778in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce90{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce91{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce92{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce9a{width:0.93in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ce9b{width:0.778in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cea4{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cea5{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cea6{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ceae{width:0.93in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ceaf{width:0.778in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ceb8{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9ceb9{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cec2{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cec3{width:0.93in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cec4{width:0.778in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cecc{width:1.211in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cecd{width:0.922in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-32f9cee0{width:0.947in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-32fe52b2"><caption>Table&nbsp;20:  <p>Callback Rate of High and Low Quality, with Differenc Categories</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-32f9ce68"><p class="cl-32f9bb9e"><span class="cl-32f6ca6a">catogory</span></p></th><th class="cl-32f9ce72"><p class="cl-32f9bb9e"><span class="cl-32f6ca6a">quality</span></p></th><th class="cl-32f9ce7c"><p class="cl-32f9bba8"><span class="cl-32f6ca6a">callback rate</span></p></th><th class="cl-32f9ce7d"><p class="cl-32f9bba8"><span class="cl-32f6ca6a">CI_lower</span></p></th><th class="cl-32f9ce7e"><p class="cl-32f9bba8"><span class="cl-32f6ca6a">CI_upper</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td rowspan="2" class="cl-32f9ce86"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">all</span></p></td><td class="cl-32f9ce87"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">high</span></p></td><td class="cl-32f9ce90"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0875</span></p></td><td rowspan="2" class="cl-32f9ce91"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">-0.0012</span></p></td><td rowspan="2" class="cl-32f9ce92"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0293</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32f9ce9b"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">low</span></p></td><td class="cl-32f9cea4"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">
16980.0734</span></p></td></tr><tr style="overflow-wrap:break-word;"><td rowspan="2" class="cl-32f9ceae"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">white</span></p></td><td class="cl-32f9ceaf"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">high</span></p></td><td class="cl-32f9ceb8"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.1079</span></p></td><td rowspan="2" class="cl-32f9ceb9"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">-0.0005</span></p></td><td rowspan="2" class="cl-32f9cec2"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0464</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32f9cec4"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">low</span></p></td><td class="cl-32f9cecc"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0850</span></p></td></tr><tr style="overflow-wrap:break-word;"><td rowspan="2" class="cl-32f9ceae"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">black</span></p></td><td class="cl-32f9ceaf"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">high</span></p></td><td class="cl-32f9ceb8"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0670</span></p></td><td rowspan="2" class="cl-32f9ceb9"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">-0.0143</span></p></td><td rowspan="2" class="cl-32f9cec2"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0247</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-32f9ce9b"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">low</span></p></td><td class="cl-32f9cea4"><p class="cl-32f9bba9"><span class="cl-32f6ca7e">0.0619</span></p></td></tr></tbody></table></div>
1699</div>
1700</div>
1701</div>
1702</section>
1703<section id="d.-5" class="level2 unnumbered">
1704<h2 class="unnumbered anchored" data-anchor-id="d.-5">d.&nbsp;</h2>
1705<p>Construct t-tests for the characteristics, separated by race. The result shows that only one of the characteristics is statistically significant at 0.05 level, which is computer skills, with value of 0.0303. So it is a random assignment.</p>
1706<div class="cell">
1707<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a>char <span class="ot">&lt;-</span> <span class="fu">c</span>()</span>
1708<span id="cb43-2"><a href="#cb43-2" aria-hidden="true" tabindex="-1"></a>tt <span class="ot">&lt;-</span> <span class="fu">c</span>()</span>
1709<span id="cb43-3"><a href="#cb43-3" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">ncol</span>(white)) {</span>
1710<span id="cb43-4"><a href="#cb43-4" aria-hidden="true" tabindex="-1"></a>  col_name <span class="ot">&lt;-</span> <span class="fu">names</span>(white[i])</span>
1711<span id="cb43-5"><a href="#cb43-5" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> (col_name <span class="sc">==</span> <span class="st">"black"</span> <span class="sc">|</span> col_name <span class="sc">==</span> <span class="st">"call_back"</span> <span class="sc">|</span> <span class="fu">mode</span>(white[[i]]) <span class="sc">==</span> <span class="st">"character"</span>) {</span>
1712<span id="cb43-6"><a href="#cb43-6" aria-hidden="true" tabindex="-1"></a>    <span class="cf">next</span></span>
1713<span id="cb43-7"><a href="#cb43-7" aria-hidden="true" tabindex="-1"></a>  }</span>
1714<span id="cb43-8"><a href="#cb43-8" aria-hidden="true" tabindex="-1"></a>  char <span class="ot">&lt;-</span> <span class="fu">c</span>(char, col_name)</span>
1715<span id="cb43-9"><a href="#cb43-9" aria-hidden="true" tabindex="-1"></a>  tt <span class="ot">&lt;-</span> <span class="fu">c</span>(tt, <span class="fu">t.test</span>(white[i], black[i])<span class="sc">$</span>p.value)</span>
1716<span id="cb43-10"><a href="#cb43-10" aria-hidden="true" tabindex="-1"></a>}</span>
1717<span id="cb43-11"><a href="#cb43-11" aria-hidden="true" tabindex="-1"></a></span>
1718<span id="cb43-12"><a href="#cb43-12" aria-hidden="true" tabindex="-1"></a>sig_res <span class="ot">&lt;-</span> <span class="fu">list</span>(<span class="at">char =</span> <span class="fu">c</span>(), <span class="at">p =</span> <span class="fu">c</span>())</span>
1719<span id="cb43-13"><a href="#cb43-13" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">length</span>(tt)) {</span>
1720<span id="cb43-14"><a href="#cb43-14" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> (tt[i] <span class="sc">&lt;</span> <span class="fl">0.05</span>) {</span>
1721<span id="cb43-15"><a href="#cb43-15" aria-hidden="true" tabindex="-1"></a>    sig_res<span class="sc">$</span>char <span class="ot">&lt;-</span> <span class="fu">c</span>(sig_res<span class="sc">$</span>char, char[i])</span>
1722<span id="cb43-16"><a href="#cb43-16" aria-hidden="true" tabindex="-1"></a>    sig_res<span class="sc">$</span>p <span class="ot">&lt;-</span> <span class="fu">c</span>(sig_res<span class="sc">$</span>p, tt[i])</span>
1723<span id="cb43-17"><a href="#cb43-17" aria-hidden="true" tabindex="-1"></a>  }</span>
1724<span id="cb43-18"><a href="#cb43-18" aria-hidden="true" tabindex="-1"></a>}</span>
1725<span id="cb43-19"><a href="#cb43-19" aria-hidden="true" tabindex="-1"></a>sig_res <span class="sc">%&gt;%</span></span>
1726<span id="cb43-20"><a href="#cb43-20" aria-hidden="true" tabindex="-1"></a>  <span class="fu">
1726as_tibble</span>() <span class="sc">%&gt;%</span></span>
1727<span id="cb43-21"><a href="#cb43-21" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mutate</span>(<span class="at">character =</span> char, <span class="st">`</span><span class="at">p-value</span><span class="st">`</span> <span class="ot">=</span> p) <span class="sc">%&gt;%</span></span>
1728<span id="cb43-22"><a href="#cb43-22" aria-hidden="true" tabindex="-1"></a>  <span class="fu">select</span>(character, <span class="st">`</span><span class="at">p-value</span><span class="st">`</span>) <span class="sc">%&gt;%</span></span>
1729<span id="cb43-23"><a href="#cb43-23" aria-hidden="true" tabindex="-1"></a>  <span class="fu">flextable</span>() <span class="sc">%&gt;%</span></span>
1730<span id="cb43-24"><a href="#cb43-24" aria-hidden="true" tabindex="-1"></a>  <span class="fu">bold</span>(<span class="at">part =</span> <span class="st">"header"</span>) <span class="sc">%&gt;%</span></span>
1731<span id="cb43-25"><a href="#cb43-25" aria-hidden="true" tabindex="-1"></a>  <span class="fu">autofit</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1732<div class="cell-output-display">
1733<div id="tbl-not_sig" class="anchored">
1734
1735<div class="tabwid"><style>.cl-331c00aa{}.cl-33152ce4{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-33152cf8{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-3317eda8{margin:0;text-align:left;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-3317edbc{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-33180022{width:1.253in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-3318002c{width:1.092in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-3318002d{width:1.253in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-33180036{width:1.092in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing="true" class="cl-331c00aa"><caption>Table&nbsp;21:  <p>Characters with Statistically Significant Difference</p> </caption><thead><tr style="overflow-wrap:break-word;"><th class="cl-33180022"><p class="cl-3317eda8"><span class="cl-33152ce4">character</span></p></th><th class="cl-3318002c"><p class="cl-3317edbc"><span class="cl-33152ce4">p-value</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-3318002d"><p class="cl-3317eda8"><span class="cl-33152cf8">computerskills</span></p></td>
1735<td class="cl-33180036"><p class="cl-3317edbc"><span class="cl-33152cf8">0.03032706</span></p></td></tr></tbody></table></div>
1736</div>
1737</div>
1738</div>
1739</section>
1740</section>
1741<section id="结语" class="level1">
1742<h1>结语</h1>
1743<p>本次实验内容就到此结束了,谢谢你的耐心阅读。 如果你觉得本篇实验参考对你有帮助的话,欢迎请我喝杯茶! ;)</p>
1744<div class="quarto-figure quarto-figure-left">
1745<figure class="figure">
1746<p><img src="images/buymetea.png" class="img-fluid figure-img" style="width:25.0%"></p>
1747<p></p><figcaption class="figure-caption">buymetea</figcaption><p></p>
1748</figure>
1749</div>
1750<div class="cell">
1751<div class="sourceCode cell-code hidden" id="cb44" data-startfrom="1430" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 1429;"><span id="cb44-1430"><a href="#cb44-1430" aria-hidden="true" tabindex="-1"></a><span class="fu">initComments</span>({</span>
1752<span id="cb44-1431"><a href="#cb44-1431" aria-hidden="true" tabindex="-1"></a>  <span class="dt">node</span><span class="op">:</span> <span class="bu">document</span><span class="op">.</span><span class="fu">getElementById</span>(<span class="st">"comment-section"</span>)<span class="op">,</span></span>
1753<span id="cb44-1432"><a href="#cb44-1432" aria-hidden="true" tabindex="-1"></a>  <span class="dt">defaultHomeserverUrl</span><span class="op">:</span> <span class="st">"https://matrix.cactus.chat:8448"</span><span class="op">,</span></span>
1754<span id="cb44-1433"><a href="#cb44-1433" aria-hidden="true" tabindex="-1"></a>  <span class="dt">serverName</span><span class="op">:</span> <span class="st">"cactus.chat"</span><span class="op">,</span></span>
1755<span id="cb44-1434"><a href="#cb44-1434" aria-hidden="true" tabindex="-1"></a>    <span class="dt">siteName</span><span class="op">:</span> <span class="st">"zzzzorange-eco-exp2"</span><span class="op">,</span></span>
1756<span id="cb44-1435"><a href="#cb44-1435" aria-hidden="true" tabindex="-1"></a>    <span class="dt">commentSectionId</span><span class="op">:</span> <span class="st">"section1"</span></span>
1757<span id="cb44-1436"><a href="#cb44-1436" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
1758<div class="cell-output cell-output-display hidden">
1759<div id="ojs-cell-1" data-nodetype="expression">
1760
1761</div>
1762</div>
1763</div>
1764</section>
1765
1766</main>
1767<!-- /main column -->
1768<script type="ojs-module-contents">
1769{"contents":[{"methodName":"interpret","cellName":"ojs-cell-1","inline":false,"source":"initComments({\n  node: document.getElementById(\"comment-section\"),\n  defaultHomeserverUrl: \"https://matrix.cactus.chat:8448\",\n  serverName: \"cactus.chat\",\n    siteName: \"zzzzorange-eco-exp2\",\n    commentSectionId: \"section1\"\n}) \n"}]}
1770</script>
vendor: 1 bytes, line 1770
1770
1771<script type="module">
1772if (window.location.protocol === "file:") { alert("The OJS runtime does not work with file:// URLs. Please use a web server to view this document."); }
1773window._ojs.paths.runtimeToDoc = "../../..";
1774window._ojs.paths.runtimeToRoot = "../../..";
1775window._ojs.paths.docToRoot = "";
1776window._ojs.selfContained = false;
1777window._ojs.runtime.interpretFromScriptTags();
1778</script>
vendor: 1 bytes, line 1778
1778
1779<script id="quarto-html-after-body" type="application/javascript">
1780window.document.addEventListener("DOMContentLoaded", function (event) {
1781  const toggleBodyColorMode = (bsSheetEl) => {
1782    const mode = bsSheetEl.getAttribute("data-mode");
1783    const bodyEl = window.document.querySelector("body");
1784    if (mode === "dark") {
1785      bodyEl.classList.add("quarto-dark");
1786      bodyEl.classList.remove("quarto-light");
1787    } else {
1788      bodyEl.classList.add("quarto-light");
1789      bodyEl.classList.remove("quarto-dark");
1790    }
1791  }
1792  const toggleBodyColorPrimary = () => {
1793    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
1794    if (bsSheetEl) {
1795      toggleBodyColorMode(bsSheetEl);
1796    }
1797  }
1798  toggleBodyColorPrimary();  
1799  const icon = "";
1800  const anchorJS = new window.AnchorJS();
1801  anchorJS.options = {
1802    placement: 'right',
1803    icon: icon
1804  };
1805  anchorJS.add('.anchored');
1806  const isCodeAnnotation = (el) => {
1807    for (const clz of el.classList) {
1808      if (clz.startsWith('code-annotation-')) {                     
1809        return true;
1810      }
1811    }
1812    return false;
1813  }
1814  const clipboard = new window.ClipboardJS('.code-copy-button', {
1815    text: function(trigger) {
1816      const codeEl = trigger.previousElementSibling.cloneNode(true);
1817      for (const childEl of codeEl.children) {
1818        if (isCodeAnnotation(childEl)) {
1819          childEl.remove();
1820        }
1821      }
1822      return codeEl.innerText;
1823    }
1824  });
1825  clipboard.on('success', function(e) {
1826    // button target
1827    const button = e.trigger;
1828    // don't keep focus
1829    button.blur();
1830    // flash "checked"
1831    button.classList.add('code-copy-button-checked');
1832    var currentTitle = button.getAttribute("title");
1833    button.setAttribute("title", "Copied!");
1834    let tooltip;
1835    if (window.bootstrap) {
1836      button.setAttribute("data-bs-toggle", "tooltip");
1837      button.setAttribute("data-bs-placement", "left");
1838      button.setAttribute("data-bs-title", "Copied!");
1839      tooltip = new bootstrap.Tooltip(button, 
1840        { trigger: "manual", 
1841          customClass: "code-copy-button-tooltip",
1842          offset: [0, -8]});
1843      tooltip.show();    
1844    }
1845    setTimeout(function() {
1846      if (tooltip) {
1847        tooltip.hide();
1848        button.removeAttribute("data-bs-title");
1849        button.removeAttribute("data-bs-toggle");
1850        button.removeAttribute("data-bs-placement");
1851      }
1852      button.setAttribute("title", currentTitle);
1853      button.classList.remove('code-copy-button-checked');
1854    }, 1000);
1855    // clear code selection
1856    e.clearSelection();
1857  });
1858  function tippyHover(el, contentFn) {
1859    const config = {
1860      allowHTML: true,
1861      content: contentFn,
1862      maxWidth: 500,
1863      delay: 100,
1864      arrow: false,
1865      appendTo: function(el) {
1866          return el.parentElement;
1867      },
1868      interactive: true,
1869      interactiveBorder: 10,
1870      theme: 'quarto',
1871      placement: 'bottom-start'
1872    };
1873    window.tippy(el, config); 
1874  }
1875  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
1876  for (var i=0; i<noterefs.length; i++) {
1877    const ref = noterefs[i];
1878    tippyHover(ref, function() {
1879      // use id or data attribute instead here
1880      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
1881      try { href = new URL(href).hash; } catch {}
1882      const id = href.replace(/^#\/?/, "");
1883      const note = window.document.getElementById(id);
1884      return note.innerHTML;
1885    });
1886  }
1887      let selectedAnnoteEl;
1888      const selectorForAnnotation = ( cell, annotation) => {
1889        let cellAttr = 'data-code-cell="' + cell + '"';
1890        let lineAttr = 'data-code-annotation="' +  annotation + '"';
1891        const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
1892        return selector;
1893      }
1894      const selectCodeLines = (annoteEl) => {
1895        const doc = window.document;
1896        const targetCell = annoteEl.getAttribute("data-target-cell");
1897        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
1898        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
1899        const lines = annoteSpan.getAttribute("data-code-lines").split(",");
1900        const lineIds = lines.map((line) => {
1901          return targetCell + "-" + line;
1902        })
1903        let top = null;
1904        let height = null;
1905        let parent = null;
1906        if (lineIds.length > 0) {
1907            //compute the position of the single el (top and bottom and make a div)
1908            const el = window.document.getElementById(lineIds[0]);
1909            top = el.offsetTop;
1910            height = el.offsetHeight;
1911            parent = el.parentElement.parentElement;
1912          if (lineIds.length > 1) {
1913            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
1914            const bottom = lastEl.offsetTop + lastEl.offsetHeight;
1915            height = bottom - top;
1916          }
1917          if (top !== null && height !== null && parent !== null) {
1918            // cook up a div (if necessary) and position it 
1919            let div = window.document.getElementById("code-annotation-line-highlight");
1920            if (div === null) {
1921              div = window.document.createElement("div");
1922              div.setAttribute("id", "code-annotation-line-highlight");
1923              div.style.position = 'absolute';
1924              parent.appendChild(div);
1925            }
1926            div.style.top = top - 2 + "px";
1927            div.style.height = height + 4 + "px";
1928            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
1929            if (gutterDiv === null) {
1930              gutterDiv = window.document.createElement("div");
1931              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
1932              gutterDiv.style.position = 'absolute';
1933              const codeCell = window.document.getElementById(targetCell);
1934              const gutter = codeCell.querySelector('.code-annotation-gutter');
1935              gutter.appendChild(gutterDiv);
1936            }
1937            gutterDiv.style.top = top - 2 + "px";
1938            gutterDiv.style.height = height + 4 + "px";
1939          }
1940          selectedAnnoteEl = annoteEl;
1941        }
1942      };
1943      const unselectCodeLines = () => {
1944        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
1945        elementsIds.forEach((elId) => {
1946          const div = window.document.getElementById(elId);
1947          if (div) {
1948            div.remove();
1949          }
1950        });
1951        selectedAnnoteEl = undefined;
1952      };
1953      // Attach click handler to the DT
1954      const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
1955      for (const annoteDlNode of annoteDls) {
1956        annoteDlNode.addEventListener('click', (event) => {
1957          const clickedEl = event.target;
1958          if (clickedEl !== selectedAnnoteEl) {
1959            unselectCodeLines();
1960            const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
1961            if (activeEl) {
1962              activeEl.classList.remove('code-annotation-active');
1963            }
1964            selectCodeLines(clickedEl);
1965            clickedEl.classList.add('code-annotation-active');
1966          } else {
1967            // Unselect the line
1968            unselectCodeLines();
1969            clickedEl.classList.remove('code-annotation-active');
1970          }
1971        });
1972      }
1973  const findCites = (el) => {
1974    const parentEl = el.parentElement;
1975    if (parentEl) {
1976      const cites = parentEl.dataset.cites;
1977      if (cites) {
1978        return {
1979          el,
1980          cites: cites.split(' ')
1981        };
1982      } else {
1983        return findCites(el.parentElement)
1984      }
1985    } else {
1986      return undefined;
1987    }
1988  };
1989  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
1990  for (var i=0; i<bibliorefs.length; i++) {
1991    const ref = bibliorefs[i];
1992    const citeInfo = findCites(ref);
1993    if (citeInfo) {
1994      tippyHover(citeInfo.el, function() {
1995        var popup = window.document.createElement('div');
1996        citeInfo.cites.forEach(function(cite) {
1997          var citeDiv = window.document.createElement('div');
1998          citeDiv.classList.add('hanging-indent');
1999          citeDiv.classList.add('csl-entry');
2000          var biblioDiv = window.document.getElementById('ref-' + cite);
2001          if (biblioDiv) {
2002            citeDiv.innerHTML = biblioDiv.innerHTML;
2003          }
2004          popup.appendChild(citeDiv);
2005        });
2006        return popup.innerHTML;
2007      });
2008    }
2009  }
2010});
2011</script>
2011
2012</div> <!-- /content -->
2013<div id="comment-section"></div>
2014
2015
2016
2017</body></html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.