-
Notifications
You must be signed in to change notification settings - Fork 0
/
STAT462_Lab7.html
742 lines (648 loc) · 29.9 KB
/
STAT462_Lab7.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Lab 7: Multiple Regression</title>
<script src="site_libs/header-attrs-2.11/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.tab('show');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">STAT-462</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="T1_R_Basics.html">Tutorials</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Labs
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="STAT462_22_L1Basics.html">Lab 1:R-Basics</a>
</li>
<li>
<a href="STAT462_Lab2.html">Lab 2: Exploratory Data Analysis (EDA)</a>
</li>
<li>
<a href="STAT462_Lab3.html">Lab 3: Scatterplots</a>
</li>
<li>
<a href="STAT462_Lab4.html">Lab 4: Regression Code showcase</a>
</li>
<li>
<a href="STAT462_Lab5.html">Lab 5: LINE Assumptions</a>
</li>
<li>
<a href="STAT462_Lab6.html">Lab 6: Outliers & Transformations</a>
</li>
<li>
<a href="STAT462_Lab7.html">Lab 7: Multiple Regression</a>
</li>
<li>
<a href="STAT462_Lab8.html">Lab 8: Putting it together</a>
</li>
</ul>
</li>
<li>
<a href="STAT462_LabEXAMPLE.html">LAB EXAMPLE</a>
</li>
<li>
<a href="Worked_questions.html">Worked questions</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Lab 7: Multiple Regression</h1>
<h3 class="subtitle"><h5 style="font-style:normal">
STAT-462 - Regression Analysis
</h4></h3>
<h4 class="author"><h5 style="font-style:normal">
Dr Helen Greatrex
</h4></h4>
</div>
<style>
p.comment {
background-color: #DBDBDB;
padding: 10px;
border: 1px solid black;
margin-left: 0px;
border-radius: 5px;
font-style: normal;
}
h1.title {
font-weight: bold;
font-family: Arial;
}
h2.title {
font-family: Arial;
}
</style>
<style type="text/css">
#TOC {
font-size: 12px;
font-family: Arial;
}
</style>
<p><br />
</p>
<div id="learning-objectives" class="section level1">
<h1>Learning objectives</h1>
<p class="comment">
<strong>Assignment 7 is due by midnight NEXT WEDNESDAY (1 week lab)</strong> <a href="https://psu.instructure.com/courses/2174925/assignments/13762850">See here</a> I PROVIDE HELP UNTIL THE END OF NEXT WEEK’S LAB. After next week’s lab (All of Wed evening) is for your own finishing up.
</p>
<p>By the end of this week’s lab, you will be able to:</p>
<ol style="list-style-type: decimal">
<li>Create Multiple Regression Models</li>
<li>Assess Multiple Regression Models</li>
<li>Model selection</li>
</ol>
<p>There is a TEAMS discussion for lab help <a href="https://teams.microsoft.com/l/team/19%3aWabo92vghie-p1jKkmYOGJIOPMUExkoPb0JQMb_9dgw1%40thread.tacv2/conversations?groupId=bbc92dcc-56df-48e6-8da3-5cd766908eeb&tenantId=7cf48d45-3ddb-4389-a9c1-c115526eb52e">CLICK HERE</a>. Remember to include a screenshot of the issue and a short description of the problem. Also try googling the error first.</p>
<p><br></p>
</div>
<div id="part-1-lab-set-up.-do-not-skip" class="section level1">
<h1>PART 1: Lab set-up. DO NOT SKIP!</h1>
<p><br></p>
<p><strong>Step A:</strong> Create a new project for Lab 7. If you are stuck, see previous labs or <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#21_Projects">Tutorial 2.1</a>.</p>
<p><br></p>
<p><strong>Step B:</strong> Copy your lab template to your lab 7 folder, rename as <code>STAT-462_Lab7_EMAILID.Rmd</code> and open (e.g.STAT-462_Lab6_hlg5155.Rmd). This should have your theme, your table of contents and your headings.</p>
<p><br></p>
<p><strong>Step C:</strong> In the library section, add a new code chunk and use this code to load the libraries below.</p>
<ul>
<li><p>If some don’t exist on your computer or on the cloud, use <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#23_Adding_a_new_package">Tutorial 2.3</a> to install/download them first. NEVER put install.packages in your code chunk, run it in the console.</p></li>
<li><p>To make sure they loaded OK, run the code chunk TWICE. The second time any welcome text will disappear unless there are errors.</p></li>
<li><p>Sometimes you might need an extra package later in the lab. Install it using the instructions above and add the library commands to your library code chunk.</p></li>
</ul>
<pre class="r"><code># Load libraries
library("tidyverse") # Lots of data processing commands
library("knitr") # Helps make good output files
library("ggplot2") # Output plots
library("rmarkdown") # Helps make good output files
library("lattice") # Makes nice plots
library("RColorBrewer") # Makes nice color-scales
library("skimr") # Summary statistics
library("Stat2Data") # Regression specific commands
library("corrplot") # correlation plots
library("GGally") # correlation plots
library("ggpubr") # QQplots
library("olsrr") # Regression specific commands
library("plotly") # Interactive plots
library("readxl") # Read from excel files
library("equatiomatic") # extract equations
library("ggstatsplot")
library("MASS")
## you may need additional libraries. Just add them to this list if you get errors.</code></pre>
<p><br></p>
<p><strong>Step D:</strong> Finally, press knit to check the html works and your theme works.</p>
<p><br></p>
</div>
<div id="part-2-code-showcase" class="section level1">
<h1>PART 2: Code showcase</h1>
<p>There is no code showcase this week so you have more time for revision etc.</p>
</div>
<div id="part-3-movie-ratings" class="section level1">
<h1>PART 3: Movie Ratings</h1>
<div id="background" class="section level2">
<h2>Background</h2>
<p>You are an analyst for a Hollywood studio. The studio wants to understand how well a movie will perform on the review website Rotten Tomatoes. They have paid you to build a model to predict the movie’s Rotten Tomatoes score.</p>
<p>Download the two files from Canvas which contain the data.</p>
<ul>
<li>The file <em>HollywoodMovies2011.csv</em> is the data itself, which includes information on movies that came out of your Hollywood Studio in 2011. The dataset contains the Rotten Tomatoes score plus six predictor variables. Download it from Canvas and read it into R as a variable called movies.</li>
<li>The meta data (the data explaining what the spreadsheet shows), is stored in <em>HollywoodMovies2011MetaData.txt</em>. Download it from Canvas. You do not need to read it into R, but take a look as it provides vital information about what the data is showing.</li>
</ul>
</div>
<div id="lab-report-format" class="section level2 unnumbered">
<h2 class="unnumbered">Lab report format</h2>
<p>Imagine this is a formal report you are submitting to the Studio. You will be graded on the professionality of your final report. In all of your answers below, I expect good formatting, appropriate units and full sentences to explain your answers. Please also make sure that you use headings, sub-headings and the spell check to make your lab easier to follow and grade.</p>
<p>Think about using any/all of the markdown features we have learned so far, for example equations, text formatting, pictures, code-chunk options or anything else that makes your report look more professional.</p>
<p class="comment">
The headings in the template are guidelines. If it helps to use your own or to tweak them, this is OK.
</p>
<p><br></p>
<p>Follow the instructions below to answer their questions.</p>
<p><br></p>
<div id="describe-the-study-step-1" class="section level3">
<h3>Describe the study (Step 1)</h3>
<p><strong>Step 1:</strong> If you skipped it, go back and read the brief above. Seriously, it will save you time. If you skipped making/copying/using the lab report template, go back and do it - or these instructions will not make sense <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#5_Report_template">Tutorial 5</a>.</p>
<p><br></p>
</div>
<div id="exploratory-data-analysis-step-2-5" class="section level3">
<h3>Exploratory Data Analysis (Step 2-5)</h3>
<p><strong>Step 2:</strong> Read the data into R. In the <code>Data Description</code> and <code>Study Aim</code> sections, use the first part of the <a href="https://psu.instructure.com/courses/2174925/files/132549205">teaching notes</a> to help you write about the following: <br></p>
<ul>
<li>The background of the study <em>(imagine this is a real report and your customer doesn’t know the background)</em></li>
<li>A short description of the data.</li>
<li>The object of analysis</li>
<li>A reasonable population <em>(what population could your results be extrapolated to/ All water in the universe in all time?)</em></li>
<li>The response variable <em>(and units - if they are not provided, state that!)</em></li>
<li>A bullet point list the other variables <em>(and units)</em> that could potentially be a predictor.</li>
<li>The amount of data</li>
<li>Statements to answer the questions on page 3 of the teaching notes</li>
<li>A short paragraph to summarise the study <em>(Example for penguins on page 3 of the teaching notes)</em></li>
</ul>
<p class="comment">
There are also guidelines in the template. You do NOT need to repeat yourself, so ignore/delete any prompts you have already done or refer to it in your answers e.g. “As shown in the histogram above….”.
</p>
<p><br></p>
<p><strong>Step 3:</strong> Under <code>Exploratory Analysis | Response Variable</code> in your report, explore your response variable and describe it in the report, working through page 4-6 of the teaching notes (Step 2) and commenting on all the questions. E.g. if there are no outliers, SAY there are no outliers (Step 2). <br><br> Again, there are additional hints in the template - you do not need to answer things twice.</p>
<p class="comment">
Hint: There is DEFINITELY something wrong with this data that needs addressing.
</p>
<p class="comment">
Hint: For full marks, plots like histograms should have proper x and y axis labels and titles. All the tutorial examples in <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#7_Making_plots">Tutorial 7</a> can be copy/pasted, why not choose a more sophisticated one..
</p>
<p><br></p>
<p><strong>Step 4:</strong> <strong>Download/Install</strong> the<code></code>ggcorrplot<code>package and add it to your library code chunk (remember to re-run!). Inside</code>Exploratory analysis<code>, make a new sub-section called</code>Correlation<code>. Use the</code>ggcorrmat` command to create a plot <a href="https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggcorrmat.html" class="uri">https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggcorrmat.html</a>. The most common errors here are that you are missing another package. If so, install <em>that</em> package, and re-run. Repeat for each package needed until the error goes away. Note, look at the help file and online tutorials for loads of color and style options.</p>
<p><br></p>
<p><strong>Step 5:</strong> Use the correlation plot to describe the relationship between your response variable and each of your predictors. Which predictors do you think will have the strongest impact on a movie’s Rotten Tomatoes score. If it helps to make individual scatterplots with your response to see the relationship, feel free!</p>
<p><br></p>
</div>
<div id="original-model-step-6---10" class="section level3">
<h3>Original model (Step 6 - 10)</h3>
<p><strong>Step 6:</strong> Set up a multiple regression model. Under <code>Model 1:</code></p>
<ol style="list-style-type: lower-alpha">
<li><p>Fit a full multiple regression model to the data, with RottenTomatoes as your response and ALL of the other variables as your predictors. Hint, if you haven’t already done this, <em>first</em> remove the TEST_TEST movie row from the excel file and re-run.</p></li>
<li><p>Show the model summary</p></li>
<li><p>Use equatiomatic or any other method to formally write out the equation and coefficients.</p></li>
<li><p>Clearly interpret each of the estimated model parameters (slope & intercept)/model summary-statistics in the the context of the problem, in a way that would be understandable to your customer. <br><br> By this I mean explain what the slopes and intercept means in term of Rotten Tomatoes scores, highlighting if this is useful or nonsensical (like knowing weight of someone with zero height is not useful). <br></p></li>
<li><p>State the percentage of variability in Rotten Tomatoes score is explained by your model, and exactly which statistic you chose for this.</p></li>
</ol>
<p><br></p>
<p><strong>Step 7:</strong> Under <code>Model Validity</code>, use <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#12_Checking_LINE_Assumptions">Tutorial 12</a> to help you formally assess each LINE assumption for model 1. Comment if it meets the requirements for simple linear regression, referring back to your plots. Remember this is the same as for a simple linear model!</p>
<p><br></p>
<p><strong>Step 8:</strong> Use <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#14_Outliers,_leverage_and_influential_points">Tutorial 14 on outliers</a> to assess if any movie appears to be an influential outlier. If a movie does fit the criteria of influential outlier, do not remove anything from the dataset. Instead, in your write-up, please provide its name and justify why you think it is influential.</p>
<p><br></p>
<p><br></p>
<p><strong>Step 9:</strong> Write a hypothesis test using the F-Statistic/ANOVA to test whether our model contains at least one predictor useful in predicting Rotten Tomatoes score.</p>
<p><br></p>
<p><strong>Step 10:</strong> Partial Slopes</p>
<p><em>“The test-results for partial slopes” is a fancy way of saying “look at the T-test result and corresponding p-value of each variable in the model summary”. Essentially, they are the likelihood of that variable being an important part of the model IF EVERYTHING ELSE WAS HELD CONSTANT.</em></p>
<p>By looking at the test results for the partial slopes (at a 10% level of significance), identify any predictor variable/s you would like to drop/delete from your model. Provide reasons for your choice(s). Does this meet your expectations from the correlation matrix? You do not have to write down any steps for hypothesis testing here, but you do need to justify your decision.</p>
<p>Note, there might be quite a few things you decide to drop..</p>
<p><br></p>
</div>
<div id="new-models-step-11-12" class="section level3">
<h3>New models (Step 11-12)</h3>
<p><strong>Step 11:</strong> Let’s make a better model. Under <code>Model 2:</code></p>
<ul>
<li>Fit a NEW model by eliminating the variables you decided to drop in the previous question.</li>
<li>Show the model summary and the model regression line equation.</li>
<li>Quickly if that model meets LINE assumptions. Don’t worry about changing anything if it doesn’t, just comment on your findings.</li>
</ul>
<p><br></p>
<p><strong>Step 12:</strong> Compare Model 1 and Model 2 using <span class="math inline">\(AdjR^2\)</span> and AIC. Which model do you consider to be a better fit and why?</p>
<p><br></p>
<p><strong>Step 13:</strong> The studio has just trialed a new movie with details:</p>
<table>
<thead>
<tr class="header">
<th>Variable Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><em>Name</em></td>
<td>“Hunt of the Killer Cactus”</td>
</tr>
<tr class="even">
<td><em>AudienceScore</em></td>
<td>59%</td>
</tr>
<tr class="odd">
<td><em>TheatersOpenWeek</em></td>
<td>15 cinemas</td>
</tr>
<tr class="even">
<td><em>BOAverageOpenWeek</em></td>
<td>$5200</td>
</tr>
<tr class="odd">
<td><em>Budget</em></td>
<td>43 Million</td>
</tr>
<tr class="even">
<td><em>DomesticGross</em></td>
<td>16.38 million USD</td>
</tr>
<tr class="odd">
<td><em>Profitability</em></td>
<td>150% of the budget recovered in profits</td>
</tr>
</tbody>
</table>
<p>Under prediction (or the appropriate subheading in model 2), estimate this new movie’s Rotten Tomatoes score? Show the 99% range of uncertainty on your estimate.</p>
<p>Hint, this is <em>similar</em> code to <a href="https://psu-spatial.github.io/stat462-2022/T1_R_Basics.html#13_Confidence_and_Prediction_Intervals">Tutorial 13 on confidence/prediction intervals</a>. To see a worked example and code for multiple regression, see here. <a href="https://online.stat.psu.edu/stat501/lesson/r-help-7-mlr-estimation-prediction-model-assumptions" class="uri">https://online.stat.psu.edu/stat501/lesson/r-help-7-mlr-estimation-prediction-model-assumptions</a></p>
<p><br></p>
</div>
<div id="stepwise-regression-and-model-selection-step-14" class="section level3">
<h3>Stepwise regression and model selection (Step 14)</h3>
<p><strong>Step 14:</strong> Find the “optimum”/“best model. There are many models/combinations of predictors that we could use to predict our response variable. We want to find the best model possible, but we also don’t want to overfit.</p>
<p>So far, we manually compared two models. In fact there is a way to compare all the combinations of predictors. This is using the <code>ols_step_best_subset()</code> command. Run this on your ORIGINAL linear model fit (Model1, the one including all the variables). e.g. <code>ols_step_best_subset(mymodel)</code>.</p>
<p>Describe what the “best subset” method is doing. Hint, we will go over this in lectures, but also <a href="https://online.stat.psu.edu/stat501/lesson/10/10.3" class="uri">https://online.stat.psu.edu/stat501/lesson/10/10.3</a></p>
<p>Use the subset method to assess the optimal fit using at least 3 goodness of fit measures. Which model is your final favourite. Fit the model and take a quick look at LINE assumptions but you don’t need to find a new model if it’s not valid (just talk about what you find)</p>
</div>
<div id="bonus-mark-1" class="section level3">
<h3>Bonus mark 1%</h3>
<p>Why are there suddenly variables in your “best” model that you would have dropped from your original model in Step 10.</p>
</div>
</div>
<div id="show-me-something-new" class="section level2">
<h2>Show me something new</h2>
<p>No show me something new so you can focus on revision/exams.</p>
<p><br></p>
</div>
</div>
<div id="submitting-your-lab" class="section level1">
<h1>Submitting your Lab</h1>
<p>Remember to save your work throughout and to spell check your writing (next to the save button).</p>
<p>Now, press the knit button for the final time.</p>
<p>If you have not made any mistakes in the code then R should create a html file in your lab 7 folder which includes your answers. If you look at your lab 7 folder, you should see this there - complete with a very recent time-stamp. In that folder, double click on the html file. This will open it in your browser. CHECK THAT THIS IS WHAT YOU WANT TO SUBMIT.</p>
<p>If you are on R studio cloud, see Tutorial 1 for how to download your files Now go to Canvas and submit BOTH your html and your .Rmd file in Lab 7.</p>
<p><br></p>
</div>
<div id="grading-rubricchecklist" class="section level1">
<h1>Grading Rubric/checklist</h1>
<p>See the table below for what this means - 100% is hard to get!</p>
<p><strong>HTML FILE SUBMISSION - 10 marks</strong></p>
<p><strong>RMD CODE SUBMISSION - 5 marks</strong></p>
<p><strong>Professional report 15 MARKS</strong></p>
<p>Full marks for a report that <em>I</em> would take into a job interview. You have done things like fully labeled plots using words, tried more sophisticated plots than just the basics, written full paragraphs/sentences, used equation formats, sub-headings, used spell check, explained results in clear language, included units, used a theme and table of contents.. Lose marks for each thing that makes it look non-professional.</p>
<p><strong>Describe the data and EDA - 10 MARKS</strong></p>
<p>You have explored the data using the guide, conducted quality control where you removed the observation that was clearly wrong and written up your results clearly. You have created the correlation matrix plot and sensitively described the relationship between your response and your predictors.</p>
<p><strong>First model - 10 MARKS</strong></p>
<p>You created the model correctly. In your write up you have summarised the model equation (including the coefficients as numbers) & summarising units afterwards. You have produced a model summary and written how much variability in the Rotten Tomatoes score is explained by your model.</p>
<p><strong>LINE and outliers- 10 MARKS</strong></p>
<p>You have clearly assessed whether the model meets LINE assumptions (2 for each). You have assessed whether there are outliers and whether they are influential. You have identified any movies which are influential.</p>
<p><strong>Model Fit - 10 MARKS</strong></p>
<p>You have correctly conducted a hypothesis test to assess model fit. You have assessed which variables do not add to the model using partial slopes.</p>
<p><strong>New model, making the model - 10 MARKS</strong></p>
<p>You have correctly refitted and interpreted the model. You have compared the models using 3 goodness of fit metrics</p>
<p><strong>Prediction - 10 MARKS</strong></p>
<p>You have correctly predicted the rotten tomatoes score of Hunt of the killer cactus.</p>
<p><strong>Stepwise - 10 MARKS</strong></p>
<p>You have found the “optimal model” and commented on what the best subset command is doing,.</p>
<p>See above</p>
<p>[100 marks total]</p>
<p>Overall, here is what your lab should correspond to:</p>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// temporarily add toc-ignore selector to headers for the consistency with Pandoc
$('.unlisted.unnumbered').addClass('toc-ignore')
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3,h4",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>