-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial-moderation-analysis.html
966 lines (925 loc) · 124 KB
/
tutorial-moderation-analysis.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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title> 15 Tutorial: Moderation analysis | R for Conditional Process Analysis</title>
<meta name="description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="generator" content="bookdown 0.24 and GitBook 2.6.7" />
<meta property="og:title" content=" 15 Tutorial: Moderation analysis | R for Conditional Process Analysis" />
<meta property="og:type" content="book" />
<meta property="og:description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content=" 15 Tutorial: Moderation analysis | R for Conditional Process Analysis" />
<meta name="twitter:description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="author" content="Lara Kobilke, IKMZ, University of Zurich" />
<meta name="date" content="2022-05-04" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="exercise-5-test-your-knowledge.html"/>
<link rel="next" href="exercise-6-test-your-knowledge.html"/>
<script src="libs/header-attrs-2.11/header-attrs.js"></script>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.0.1/anchor-sections.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.0.1/anchor-sections.js"></script>
<script src="libs/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<script src="libs/viz-1.8.2/viz.js"></script>
<link href="libs/DiagrammeR-styles-0.2/styles.css" rel="stylesheet" />
<script src="libs/grViz-binding-1.0.9/grViz.js"></script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">CPA Seminar</a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>General information on the course</a>
<ul>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#how-to-use-this-tutorial"><i class="fa fa-check"></i>How to use this tutorial</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#what-can-i-do-if-questions-arise"><i class="fa fa-check"></i>What can I do if questions arise?</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#what-can-i-do-if-i-have-problems-with-my-r-code"><i class="fa fa-check"></i>What can I do if I have problems with my R code?</a></li>
</ul></li>
<li class="chapter" data-level="1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html"><i class="fa fa-check"></i><b>1</b> Tutorial: Installing & Understanding R/R Studio</a>
<ul>
<li class="chapter" data-level="1.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#installing-r"><i class="fa fa-check"></i><b>1.1</b> Installing R</a></li>
<li class="chapter" data-level="1.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#installing-r-studio"><i class="fa fa-check"></i><b>1.2</b> Installing R Studio</a></li>
<li class="chapter" data-level="1.3" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#updating-r-and-r-studio"><i class="fa fa-check"></i><b>1.3</b> Updating R and R Studio</a>
<ul>
<li class="chapter" data-level="1.3.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#on-windows"><i class="fa fa-check"></i><b>1.3.1</b> On Windows</a></li>
<li class="chapter" data-level="1.3.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#on-mac"><i class="fa fa-check"></i><b>1.3.2</b> On MAC</a></li>
</ul></li>
<li class="chapter" data-level="1.4" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#how-does-r-work"><i class="fa fa-check"></i><b>1.4</b> How does R work?</a></li>
<li class="chapter" data-level="1.5" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#how-does-r-studio-work"><i class="fa fa-check"></i><b>1.5</b> How does R Studio work?</a>
<ul>
<li class="chapter" data-level="1.5.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#source-writing-your-own-code"><i class="fa fa-check"></i><b>1.5.1</b> Source: Writing your own code</a></li>
<li class="chapter" data-level="1.5.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#console-printing-results"><i class="fa fa-check"></i><b>1.5.2</b> Console: Printing results</a></li>
<li class="chapter" data-level="1.5.3" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#environment-overview-of-objects"><i class="fa fa-check"></i><b>1.5.3</b> Environment: Overview of objects</a></li>
<li class="chapter" data-level="1.5.4" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#plotshelppackages-do-everything-else"><i class="fa fa-check"></i><b>1.5.4</b> Plots/Help/Packages: Do everything else</a></li>
</ul></li>
<li class="chapter" data-level="1.6" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#take-aways"><i class="fa fa-check"></i><b>1.6</b> Take-Aways</a></li>
<li class="chapter" data-level="1.7" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#additional-tutorials"><i class="fa fa-check"></i><b>1.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html"><i class="fa fa-check"></i><b>2</b> Tutorial: Workflow in R</a>
<ul>
<li class="chapter" data-level="2.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#defining-your-working-directory"><i class="fa fa-check"></i><b>2.1</b> Defining your working directory</a></li>
<li class="chapter" data-level="2.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#packages"><i class="fa fa-check"></i><b>2.2</b> Packages</a>
<ul>
<li class="chapter" data-level="2.2.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#installing-packages"><i class="fa fa-check"></i><b>2.2.1</b> Installing packages</a></li>
<li class="chapter" data-level="2.2.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#activating-packages"><i class="fa fa-check"></i><b>2.2.2</b> Activating packages</a></li>
<li class="chapter" data-level="2.2.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#getting-information-about-packages"><i class="fa fa-check"></i><b>2.2.3</b> Getting information about packages</a></li>
</ul></li>
<li class="chapter" data-level="2.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#help"><i class="fa fa-check"></i><b>2.3</b> Help?!</a>
<ul>
<li class="chapter" data-level="2.3.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#finding-information-about-packages"><i class="fa fa-check"></i><b>2.3.1</b> Finding information about packages</a></li>
<li class="chapter" data-level="2.3.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#finding-information-about-functions"><i class="fa fa-check"></i><b>2.3.2</b> Finding information about functions</a></li>
<li class="chapter" data-level="2.3.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#searching-for-help-online"><i class="fa fa-check"></i><b>2.3.3</b> Searching for help online</a></li>
<li class="chapter" data-level="2.3.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#interrupting-r"><i class="fa fa-check"></i><b>2.3.4</b> Interrupting R</a></li>
</ul></li>
<li class="chapter" data-level="2.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-loading-cleaning-coderesults"><i class="fa fa-check"></i><b>2.4</b> Saving, loading & cleaning code/results</a>
<ul>
<li class="chapter" data-level="2.4.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-your-code"><i class="fa fa-check"></i><b>2.4.1</b> Saving your code</a></li>
<li class="chapter" data-level="2.4.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-your-results"><i class="fa fa-check"></i><b>2.4.2</b> Saving your results</a></li>
<li class="chapter" data-level="2.4.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#loading-working-spaces"><i class="fa fa-check"></i><b>2.4.3</b> Loading working spaces</a></li>
<li class="chapter" data-level="2.4.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#clean-your-working-space"><i class="fa fa-check"></i><b>2.4.4</b> Clean your working space</a></li>
<li class="chapter" data-level="2.4.5" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#take-aways-1"><i class="fa fa-check"></i><b>2.4.5</b> Take Aways</a></li>
</ul></li>
<li class="chapter" data-level="2.5" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#additional-tutorials-1"><i class="fa fa-check"></i><b>2.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html"><i class="fa fa-check"></i><b>3</b> Tutorial: Using R as a calculator</a>
<ul>
<li class="chapter" data-level="3.1" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#using-variables-for-calculation"><i class="fa fa-check"></i><b>3.1</b> Using variables for calculation</a></li>
<li class="chapter" data-level="3.2" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#using-vectors-for-calculation"><i class="fa fa-check"></i><b>3.2</b> Using vectors for calculation</a></li>
<li class="chapter" data-level="3.3" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#take-aways-2"><i class="fa fa-check"></i><b>3.3</b> Take-Aways</a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html"><i class="fa fa-check"></i><b>4</b> Tutorial: Objects & structures in R</a>
<ul>
<li class="chapter" data-level="4.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#types-of-data"><i class="fa fa-check"></i><b>4.1</b> Types of data</a>
<ul>
<li class="chapter" data-level="4.1.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#accessing-variables-in-data-sets"><i class="fa fa-check"></i><b>4.1.1</b> Accessing variables in data sets</a></li>
<li class="chapter" data-level="4.1.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#numbers"><i class="fa fa-check"></i><b>4.1.2</b> Numbers</a></li>
<li class="chapter" data-level="4.1.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#text"><i class="fa fa-check"></i><b>4.1.3</b> Text</a></li>
<li class="chapter" data-level="4.1.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#factors"><i class="fa fa-check"></i><b>4.1.4</b> Factors</a></li>
<li class="chapter" data-level="4.1.5" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#dates"><i class="fa fa-check"></i><b>4.1.5</b> Dates</a></li>
<li class="chapter" data-level="4.1.6" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#missing-datanas"><i class="fa fa-check"></i><b>4.1.6</b> Missing data/NAs</a></li>
<li class="chapter" data-level="4.1.7" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#logicalother-operators"><i class="fa fa-check"></i><b>4.1.7</b> Logical/other operators</a></li>
</ul></li>
<li class="chapter" data-level="4.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#types-of-objects"><i class="fa fa-check"></i><b>4.2</b> Types of objects</a>
<ul>
<li class="chapter" data-level="4.2.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#scalars"><i class="fa fa-check"></i><b>4.2.1</b> Scalars</a></li>
<li class="chapter" data-level="4.2.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#vectors"><i class="fa fa-check"></i><b>4.2.2</b> Vectors</a></li>
<li class="chapter" data-level="4.2.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#data-frames-matrices"><i class="fa fa-check"></i><b>4.2.3</b> Data frames & matrices</a></li>
<li class="chapter" data-level="4.2.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#lists"><i class="fa fa-check"></i><b>4.2.4</b> Lists</a></li>
<li class="chapter" data-level="4.2.5" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#other-types-of-objects"><i class="fa fa-check"></i><b>4.2.5</b> Other types of objects</a></li>
</ul></li>
<li class="chapter" data-level="4.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#take-aways-3"><i class="fa fa-check"></i><b>4.3</b> Take Aways</a></li>
<li class="chapter" data-level="4.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#additional-tutorials-2"><i class="fa fa-check"></i><b>4.4</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html"><i class="fa fa-check"></i><b>5</b> Tutorial: Reading data in/out</a>
<ul>
<li class="chapter" data-level="5.1" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#getting-data-into-r"><i class="fa fa-check"></i><b>5.1</b> Getting data into R</a></li>
<li class="chapter" data-level="5.2" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#getting-data-out-of-r"><i class="fa fa-check"></i><b>5.2</b> Getting data out of R</a></li>
<li class="chapter" data-level="5.3" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#other-packages-for-getting-data-intoout-of-r"><i class="fa fa-check"></i><b>5.3</b> Other packages for getting data into/out of R</a></li>
<li class="chapter" data-level="5.4" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#take-aways-4"><i class="fa fa-check"></i><b>5.4</b> Take Aways</a></li>
<li class="chapter" data-level="5.5" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#additional-tutorials-3"><i class="fa fa-check"></i><b>5.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html"><i class="fa fa-check"></i><b>6</b> Exercise 1: Test your knowledge</a>
<ul>
<li class="chapter" data-level="6.1" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-1"><i class="fa fa-check"></i><b>6.1</b> Task 1</a></li>
<li class="chapter" data-level="6.2" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-2"><i class="fa fa-check"></i><b>6.2</b> Task 2</a></li>
<li class="chapter" data-level="6.3" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-3"><i class="fa fa-check"></i><b>6.3</b> Task 3</a></li>
<li class="chapter" data-level="6.4" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-4"><i class="fa fa-check"></i><b>6.4</b> Task 4</a></li>
<li class="chapter" data-level="6.5" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-5"><i class="fa fa-check"></i><b>6.5</b> Task 5</a></li>
</ul></li>
<li class="chapter" data-level="7" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html"><i class="fa fa-check"></i><b>7</b> Tutorial: Data management with tidyverse</a>
<ul>
<li class="chapter" data-level="7.1" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#why-not-stick-with-base-r"><i class="fa fa-check"></i><b>7.1</b> Why not stick with Base R?</a></li>
<li class="chapter" data-level="7.2" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#tidyverse-packages"><i class="fa fa-check"></i><b>7.2</b> Tidyverse packages</a></li>
<li class="chapter" data-level="7.3" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#tidy-data"><i class="fa fa-check"></i><b>7.3</b> Tidy data</a></li>
<li class="chapter" data-level="7.4" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#the-pipe-operator"><i class="fa fa-check"></i><b>7.4</b> The pipe operator</a></li>
<li class="chapter" data-level="7.5" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#data-transformation-with-dplyr"><i class="fa fa-check"></i><b>7.5</b> Data transformation with dplyr</a>
<ul>
<li class="chapter" data-level="7.5.1" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#select"><i class="fa fa-check"></i><b>7.5.1</b> select()</a></li>
<li class="chapter" data-level="7.5.2" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#filter"><i class="fa fa-check"></i><b>7.5.2</b> filter()</a></li>
<li class="chapter" data-level="7.5.3" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#arrange"><i class="fa fa-check"></i><b>7.5.3</b> arrange()</a></li>
<li class="chapter" data-level="7.5.4" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#mutate"><i class="fa fa-check"></i><b>7.5.4</b> mutate()</a></li>
<li class="chapter" data-level="7.5.5" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#simmarize-group_by"><i class="fa fa-check"></i><b>7.5.5</b> simmarize() [+ group_by()]</a></li>
<li class="chapter" data-level="7.5.6" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#chaining-functions-in-a-pipe"><i class="fa fa-check"></i><b>7.5.6</b> Chaining functions in a pipe</a></li>
</ul></li>
<li class="chapter" data-level="7.6" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#take-aways-5"><i class="fa fa-check"></i><b>7.6</b> Take-Aways</a></li>
<li class="chapter" data-level="7.7" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#additional-tutorials-4"><i class="fa fa-check"></i><b>7.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html"><i class="fa fa-check"></i><b>8</b> Exercise 2: Test your knowledge</a>
<ul>
<li class="chapter" data-level="8.1" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-1-1"><i class="fa fa-check"></i><b>8.1</b> Task 1</a></li>
<li class="chapter" data-level="8.2" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-2-1"><i class="fa fa-check"></i><b>8.2</b> Task 2</a></li>
<li class="chapter" data-level="8.3" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-3-1"><i class="fa fa-check"></i><b>8.3</b> Task 3</a></li>
<li class="chapter" data-level="8.4" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-4-1"><i class="fa fa-check"></i><b>8.4</b> Task 4</a></li>
<li class="chapter" data-level="8.5" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-5-1"><i class="fa fa-check"></i><b>8.5</b> Task 5</a></li>
<li class="chapter" data-level="8.6" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-6"><i class="fa fa-check"></i><b>8.6</b> Task 6</a></li>
<li class="chapter" data-level="8.7" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-7"><i class="fa fa-check"></i><b>8.7</b> Task 7</a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html"><i class="fa fa-check"></i><b>9</b> Tutorial: Data visualization with ggplot</a>
<ul>
<li class="chapter" data-level="9.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#why-not-stick-with-base-r-1"><i class="fa fa-check"></i><b>9.1</b> Why not stick with Base R?</a></li>
<li class="chapter" data-level="9.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#components-of-a-ggplot-graph"><i class="fa fa-check"></i><b>9.2</b> Components of a ggplot graph</a></li>
<li class="chapter" data-level="9.3" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#installing-activating-ggplot"><i class="fa fa-check"></i><b>9.3</b> Installing & activating ggplot</a></li>
<li class="chapter" data-level="9.4" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#building-your-first-plot"><i class="fa fa-check"></i><b>9.4</b> Building your first plot</a>
<ul>
<li class="chapter" data-level="9.4.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#data"><i class="fa fa-check"></i><b>9.4.1</b> Data</a></li>
<li class="chapter" data-level="9.4.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#aesthetics"><i class="fa fa-check"></i><b>9.4.2</b> Aesthetics</a></li>
<li class="chapter" data-level="9.4.3" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#geometrics"><i class="fa fa-check"></i><b>9.4.3</b> Geometrics</a></li>
<li class="chapter" data-level="9.4.4" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#scales"><i class="fa fa-check"></i><b>9.4.4</b> Scales</a></li>
<li class="chapter" data-level="9.4.5" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#themes"><i class="fa fa-check"></i><b>9.4.5</b> Themes</a></li>
<li class="chapter" data-level="9.4.6" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#labs"><i class="fa fa-check"></i><b>9.4.6</b> Labs</a></li>
<li class="chapter" data-level="9.4.7" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#facets"><i class="fa fa-check"></i><b>9.4.7</b> Facets</a></li>
<li class="chapter" data-level="9.4.8" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#saving-graphs"><i class="fa fa-check"></i><b>9.4.8</b> Saving graphs</a></li>
</ul></li>
<li class="chapter" data-level="9.5" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#other-common-plot-types"><i class="fa fa-check"></i><b>9.5</b> Other common plot types</a>
<ul>
<li class="chapter" data-level="9.5.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#bar-plots"><i class="fa fa-check"></i><b>9.5.1</b> bar plots</a></li>
<li class="chapter" data-level="9.5.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#box-plots"><i class="fa fa-check"></i><b>9.5.2</b> box plots</a></li>
</ul></li>
<li class="chapter" data-level="9.6" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#take-aways-6"><i class="fa fa-check"></i><b>9.6</b> Take Aways</a></li>
<li class="chapter" data-level="9.7" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#additional-tutorials-5"><i class="fa fa-check"></i><b>9.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="10" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html"><i class="fa fa-check"></i><b>10</b> Exercise 3: Test your knowledge</a>
<ul>
<li class="chapter" data-level="10.1" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-1-2"><i class="fa fa-check"></i><b>10.1</b> Task 1</a></li>
<li class="chapter" data-level="10.2" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-2-2"><i class="fa fa-check"></i><b>10.2</b> Task 2</a></li>
<li class="chapter" data-level="10.3" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-3-2"><i class="fa fa-check"></i><b>10.3</b> Task 3</a></li>
</ul></li>
<li class="chapter" data-level="11" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html"><i class="fa fa-check"></i><b>11</b> Tutorial: Linear regression</a>
<ul>
<li class="chapter" data-level="11.1" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#knowing-your-data"><i class="fa fa-check"></i><b>11.1</b> Knowing your data</a></li>
<li class="chapter" data-level="11.2" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#visual-inspection-of-linear-trends"><i class="fa fa-check"></i><b>11.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="11.3" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#pearsons-r"><i class="fa fa-check"></i><b>11.3</b> Pearson´s r</a></li>
<li class="chapter" data-level="11.4" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#ols-regression"><i class="fa fa-check"></i><b>11.4</b> OLS regression</a></li>
<li class="chapter" data-level="11.5" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#standardizing-coefficients"><i class="fa fa-check"></i><b>11.5</b> Standardizing coefficients</a></li>
<li class="chapter" data-level="11.6" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#multiple-regression"><i class="fa fa-check"></i><b>11.6</b> Multiple regression</a></li>
<li class="chapter" data-level="11.7" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#standardized-multiple-regression"><i class="fa fa-check"></i><b>11.7</b> Standardized multiple regression</a></li>
<li class="chapter" data-level="11.8" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#take-aways-7"><i class="fa fa-check"></i><b>11.8</b> Take Aways</a></li>
<li class="chapter" data-level="11.9" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#additional-tutorials-6"><i class="fa fa-check"></i><b>11.9</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="12" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html"><i class="fa fa-check"></i><b>12</b> Exercise 4: Test your knowledge</a>
<ul>
<li class="chapter" data-level="12.1" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-1-3"><i class="fa fa-check"></i><b>12.1</b> Task 1</a></li>
<li class="chapter" data-level="12.2" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-2-3"><i class="fa fa-check"></i><b>12.2</b> Task 2</a></li>
<li class="chapter" data-level="12.3" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-3-3"><i class="fa fa-check"></i><b>12.3</b> Task 3</a></li>
<li class="chapter" data-level="12.4" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-4-2"><i class="fa fa-check"></i><b>12.4</b> Task 4</a></li>
<li class="chapter" data-level="12.5" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-5-2"><i class="fa fa-check"></i><b>12.5</b> Task 5</a></li>
<li class="chapter" data-level="12.6" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-6-1"><i class="fa fa-check"></i><b>12.6</b> Task 6</a></li>
</ul></li>
<li class="chapter" data-level="13" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html"><i class="fa fa-check"></i><b>13</b> Tutorial: Mediation analysis</a>
<ul>
<li class="chapter" data-level="13.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#introduction-to-mediation"><i class="fa fa-check"></i><b>13.1</b> Introduction to mediation</a></li>
<li class="chapter" data-level="13.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#difference-between-mediation-and-moderation"><i class="fa fa-check"></i><b>13.2</b> Difference between mediation and moderation</a></li>
<li class="chapter" data-level="13.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#two-step-process-of-mediation"><i class="fa fa-check"></i><b>13.3</b> Two-step process of mediation</a></li>
<li class="chapter" data-level="13.4" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#statistical-representation-and-equations"><i class="fa fa-check"></i><b>13.4</b> Statistical representation and equations</a>
<ul>
<li class="chapter" data-level="13.4.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#direct-effect-c"><i class="fa fa-check"></i><b>13.4.1</b> Direct effect <em>c′</em></a></li>
<li class="chapter" data-level="13.4.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#indirect-effect-ab"><i class="fa fa-check"></i><b>13.4.2</b> Indirect effect <em>ab</em></a></li>
<li class="chapter" data-level="13.4.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#total-effect"><i class="fa fa-check"></i><b>13.4.3</b> Total effect</a></li>
</ul></li>
<li class="chapter" data-level="13.5" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#example"><i class="fa fa-check"></i><b>13.5</b> Example</a>
<ul>
<li class="chapter" data-level="13.5.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#knowing-your-data-1"><i class="fa fa-check"></i><b>13.5.1</b> Knowing your data</a></li>
<li class="chapter" data-level="13.5.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#visual-inspection-of-linear-trends-1"><i class="fa fa-check"></i><b>13.5.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="13.5.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#pearsons-r-1"><i class="fa fa-check"></i><b>13.5.3</b> Pearson’s r</a></li>
<li class="chapter" data-level="13.5.4" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#fit-models"><i class="fa fa-check"></i><b>13.5.4</b> Fit models</a></li>
<li class="chapter" data-level="13.5.5" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#using-processr"><i class="fa fa-check"></i><b>13.5.5</b> Using processR</a></li>
</ul></li>
<li class="chapter" data-level="13.6" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#take-aways-8"><i class="fa fa-check"></i><b>13.6</b> Take Aways</a></li>
<li class="chapter" data-level="13.7" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#additional-tutorials-7"><i class="fa fa-check"></i><b>13.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="14" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html"><i class="fa fa-check"></i><b>14</b> Exercise 5: Test your knowledge</a>
<ul>
<li class="chapter" data-level="14.1" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-1-4"><i class="fa fa-check"></i><b>14.1</b> Task 1</a></li>
<li class="chapter" data-level="14.2" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-2-4"><i class="fa fa-check"></i><b>14.2</b> Task 2</a></li>
<li class="chapter" data-level="14.3" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-3-4"><i class="fa fa-check"></i><b>14.3</b> Task 3</a></li>
<li class="chapter" data-level="14.4" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-4-3"><i class="fa fa-check"></i><b>14.4</b> Task 4</a></li>
<li class="chapter" data-level="14.5" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-5-3"><i class="fa fa-check"></i><b>14.5</b> Task 5</a></li>
<li class="chapter" data-level="14.6" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-6-2"><i class="fa fa-check"></i><b>14.6</b> Task 6</a></li>
<li class="chapter" data-level="14.7" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-7-1"><i class="fa fa-check"></i><b>14.7</b> Task 7</a></li>
</ul></li>
<li class="chapter" data-level="15" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html"><i class="fa fa-check"></i><b>15</b> Tutorial: Moderation analysis</a>
<ul>
<li class="chapter" data-level="15.1" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#introduction-to-moderation"><i class="fa fa-check"></i><b>15.1</b> Introduction to moderation</a></li>
<li class="chapter" data-level="15.2" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#one-step-process-of-moderation"><i class="fa fa-check"></i><b>15.2</b> One-step process of moderation</a></li>
<li class="chapter" data-level="15.3" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#statistical-representation-and-equations-1"><i class="fa fa-check"></i><b>15.3</b> Statistical representation and equations</a></li>
<li class="chapter" data-level="15.4" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#example-1"><i class="fa fa-check"></i><b>15.4</b> Example</a>
<ul>
<li class="chapter" data-level="15.4.1" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#knowing-your-data-2"><i class="fa fa-check"></i><b>15.4.1</b> Knowing your data</a></li>
<li class="chapter" data-level="15.4.2" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#visual-inspection-of-linear-trends-2"><i class="fa fa-check"></i><b>15.4.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="15.4.3" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#fit-models-1"><i class="fa fa-check"></i><b>15.4.3</b> Fit models</a></li>
<li class="chapter" data-level="15.4.4" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#standardization-and-mean-centering"><i class="fa fa-check"></i><b>15.4.4</b> Standardization and mean-centering</a></li>
<li class="chapter" data-level="15.4.5" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#follow-up-analysis-pobing-the-interaction"><i class="fa fa-check"></i><b>15.4.5</b> Follow-up analysis: Pobing the interaction</a></li>
<li class="chapter" data-level="15.4.6" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#using-processr-1"><i class="fa fa-check"></i><b>15.4.6</b> Using processR</a></li>
</ul></li>
<li class="chapter" data-level="15.5" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#take-aways-9"><i class="fa fa-check"></i><b>15.5</b> Take Aways</a></li>
<li class="chapter" data-level="15.6" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#additional-tutorials-8"><i class="fa fa-check"></i><b>15.6</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="16" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html"><i class="fa fa-check"></i><b>16</b> Exercise 6: Test your knowledge</a>
<ul>
<li class="chapter" data-level="16.1" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-1-5"><i class="fa fa-check"></i><b>16.1</b> Task 1</a></li>
<li class="chapter" data-level="16.2" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-2-5"><i class="fa fa-check"></i><b>16.2</b> Task 2</a></li>
<li class="chapter" data-level="16.3" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-3-5"><i class="fa fa-check"></i><b>16.3</b> Task 3</a></li>
<li class="chapter" data-level="16.4" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-4-4"><i class="fa fa-check"></i><b>16.4</b> Task 4</a></li>
<li class="chapter" data-level="16.5" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-5-4"><i class="fa fa-check"></i><b>16.5</b> Task 5</a></li>
<li class="chapter" data-level="16.6" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-6-3"><i class="fa fa-check"></i><b>16.6</b> Task 6</a></li>
</ul></li>
<li class="chapter" data-level="17" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html"><i class="fa fa-check"></i><b>17</b> Tutorial: CPA and model fit</a>
<ul>
<li class="chapter" data-level="17.1" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#what-is-cpa"><i class="fa fa-check"></i><b>17.1</b> What is CPA?</a></li>
<li class="chapter" data-level="17.2" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#fitting-models-with-lavaan"><i class="fa fa-check"></i><b>17.2</b> Fitting models with lavaan</a></li>
<li class="chapter" data-level="17.3" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#example-evaluate-model-fit-for-complex-models"><i class="fa fa-check"></i><b>17.3</b> Example: Evaluate model fit for complex models</a>
<ul>
<li class="chapter" data-level="17.3.1" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#theory-driven-hypotheses"><i class="fa fa-check"></i><b>17.3.1</b> Theory-driven hypotheses</a></li>
<li class="chapter" data-level="17.3.2" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#model-fit-and-evaluation"><i class="fa fa-check"></i><b>17.3.2</b> Model fit and evaluation</a></li>
</ul></li>
<li class="chapter" data-level="17.4" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#take-aways-10"><i class="fa fa-check"></i><b>17.4</b> Take-Aways</a></li>
<li class="chapter" data-level="17.5" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#additional-tutorials-9"><i class="fa fa-check"></i><b>17.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="18" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html"><i class="fa fa-check"></i><b>18</b> Exercise 7: Test your knowledge</a>
<ul>
<li class="chapter" data-level="18.1" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html#task-1-6"><i class="fa fa-check"></i><b>18.1</b> Task 1</a></li>
<li class="chapter" data-level="18.2" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html#task-2-6"><i class="fa fa-check"></i><b>18.2</b> Task 2</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html"><i class="fa fa-check"></i>Solutions</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-1"><i class="fa fa-check"></i>Solutions for Exercise 1</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-7"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-7"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-6"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-5"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-5"><i class="fa fa-check"></i>Task 5</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-2"><i class="fa fa-check"></i>Solutions for Exercise 2</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-8"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-8"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-7"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-6"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-6"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-4"><i class="fa fa-check"></i>Task 6</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-7-2"><i class="fa fa-check"></i>Task 7</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-3"><i class="fa fa-check"></i>Solutions for Exercise 3</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-9"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-9"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-8"><i class="fa fa-check"></i>Task 3</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-4"><i class="fa fa-check"></i>Solutions for Exercise 4</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-10"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-10"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-9"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-7"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-7"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-5"><i class="fa fa-check"></i>Task 6</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-5"><i class="fa fa-check"></i>Solutions for Exercise 5</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-11"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-11"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-10"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-8"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-8"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-6"><i class="fa fa-check"></i>Task 6</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-7-3"><i class="fa fa-check"></i>Task 7</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-6"><i class="fa fa-check"></i>Solutions for Exercise 6</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-12"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-12"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-11"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-9"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-9"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-7"><i class="fa fa-check"></i>Task 6</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-7"><i class="fa fa-check"></i>Solutions for Exercise 7</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-13"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-13"><i class="fa fa-check"></i>Task 2</a></li>
</ul></li>
</ul></li>
<li class="divider"></li>
<li><a href="https://github.com/LKobilke/CPA-Seminar" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">R for Conditional Process Analysis</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="tutorial-moderation-analysis" class="section level1" number="15">
<h1><span class="header-section-number"> 15</span> Tutorial: Moderation analysis</h1>
<p>After working through Tutorial 15, you’ll…</p>
<ul>
<li>have a good idea about what problems are best solved with moderation analysis</li>
<li>know how to test & probe an interaction, i.e. perform and interpret a moderation analysis</li>
<li>know how to visualize interaction effects</li>
</ul>
<div id="introduction-to-moderation" class="section level2" number="15.1">
<h2><span class="header-section-number">15.1</span> Introduction to moderation</h2>
<p>Most of you will have had contact with moderation analysis before. Often, students are first exposed to moderation analysis / interactions in “Statistics I” when they learn how to perform an ANOVA (ANalysis Of VAriance) and how to probe an interaction, i.e., test whether the effect of an independent variable on the dependent variable differs at different levels of a second independent variable. ANOVAs are often used in experimental studies, for example, to test the effect of three different ad placements in newspapers (front page, middle section, ad page) on readers’ recall. You might test an interaction in this experiment by adding another independent variable that influences the relationship between ad placement and recall, e.g. color choice (black/white, weakly saturated colors, strongly saturated colors). But even if you haven’t had any exposure to moderation analysis and experimental designs before, you should become familiar with the procedure very quickly with the following tutorial. In this tutorial, we will continue to use linear regression techniques because ANOVA is basically nothing more than a linear regression with an independent variable that is a categorical/factor variable.</p>
<p>Before we start, recall again what linear regression is all about: Linear regression allows you to quantify the relationship between variables and answer the question <strong>whether two (or more) variables</strong> share a linear relationship. As mentioned in earlier chapters, it is of limited use to know that two variables are related, i.e., to ask <strong>whether</strong> two variables share a relationship. Just like asking <strong>why and how</strong> two variables are related (<em>mediation analysis</em>), asking <strong>when and under what circumstances</strong> two variables are related (<em>moderation analysis</em>) can be much more informative. Therefore, moderation analysis asks <strong>whether the effect size of this linear relationship depends on third variables</strong>, e.g., events or personality traits.</p>
<p>The variable W is called a moderator of the relationship between a <em>focal</em> independent variable X and a dependent variable Y, when the size, sign, or strength of the effect of X on Y is dependent on the size of W. This effect of a moderating variable on the relationship between X and Y is also called <strong>interaction effect</strong>. Finding a moderator / interaction for an effect can help you to determine the situations, events, or groups of people for which the impact of X on Y is significant or non-significant (i.e. absent vs. present), small or strong, and even positive or negative.</p>
<p><strong>Example for moderation:</strong> Knowing moderator variables can be critical, especially in clinical medical research. Imagine that a drug shows a strong positive, curative effect in one group of patients (e.g., men) and a small negative, toxic effect in another group (e.g., women). When prescribing this drug, it is essential that doctors pay attention to the moderator variable <em>sex</em>! However, a multiple linear regression may have overlooked this moderating effect of <em>sex</em>, finding only a (small) positive effect of drug use in the overall population, e.g., if your sample includes more men than women. Therefore, searching for moderator variables is an important step for researchers.</p>
</div>
<div id="one-step-process-of-moderation" class="section level2" number="15.2">
<h2><span class="header-section-number">15.2</span> One-step process of moderation</h2>
<p>Unlike mediation analysis, moderation analysis assumes a one-step process: The moderator W influences the relationship between X and Y directly. To see an illustration of how this relationship is influenced by W, see this conceptual diagram of a simple moderation process<a href="#fn7" class="footnote-ref" id="fnref7"><sup>7</sup></a>:</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>Image: A simple mediation model <a href="http://afhayes.com/introduction-to-mediation-moderation-and-conditional-process-analysis.html">(Source: Andrew F. Hayes, p. 235)</a></td>
</tr>
<tr class="even">
<td><img src="images/Tut15_moderation_model.JPG" /></td>
</tr>
</tbody>
</table>
<p><strong>In summary, a simple moderation model contains a dependent variable (Y), a <em>focal</em> independent variable (X), and a moderator variable (W), where the relationship (e.g., effect size, effect direction, effect significance) between X and Y depends on the magnitude of W.</strong></p>
</div>
<div id="statistical-representation-and-equations-1" class="section level2" number="15.3">
<h2><span class="header-section-number">15.3</span> Statistical representation and equations</h2>
<p>When the effect of X is dependent on W, this means that for different values of W, X’s effect on Y is different. Statistically, we can rewrite the values of X, that depend on W, as a multiplication of X and W with an own coefficient (e.g., b * XW). Of course, we want to control for the pure effect of X on Y and for the pure effect of W on Y at the same time, which leads to this statistical representation of moderation effects that looks like this:</p>
<ol style="list-style-type: decimal">
<li>Y = i<sub>[Y]</sub> + b<sub>1</sub> * X + b<sub>2</sub> * W + b<sub>3</sub> * XW,</li>
</ol>
<p>where i<sub>[Y]</sub> represent the intercept, <em>b<sub>1</sub></em>, <em>b<sub>2</sub></em>, and <em>b<sub>3</sub></em> are the respective regression coefficients, and XW is a variable constructed as the product of X and W.</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>Image: Statistical diagram of a simple moderation model <a href="http://afhayes.com/introduction-to-mediation-moderation-and-conditional-process-analysis.html">(Source: Andrew F. Hayes, p. 241)</a></td>
</tr>
<tr class="even">
<td><img src="images/Tut15_moderation_model2.png" /></td>
</tr>
</tbody>
</table>
<p><strong>Interpreting <em>b<sub>3</sub></em>, the interaction effect:</strong> Since the product XW will always look the same, no matter whether you consider X as the moderator or W as the moderator, <em>b<sub>3</sub></em> can have two different meanings, depending on your moderator choice (X or W). when W is considered to be the moderator of X’s influence on Y, <em>b<sub>3</sub></em> quantifies how the effect of X on Y changes as W changes by one unit. However, if X is thought of as the moderator of W’s impact on Y, then <em>b<sub>3</sub></em> predicts how the effect of W on Y changes as X changes by one unit. The mathematics are unconcerned with the variable you consider to be the moderator in your study, that’s the concern of your theory. So depending on your theoretical assumptions, both interpretations can be accurate.</p>
<table>
<tbody>
<tr class="odd">
<td><strong><span style="color: darkred;">A generic interpretation of the interaction effect in a moderation analysis would be that two individuals who differ by one unit on X are estimated to differ by XW’s regression coefficient units on Y as W changes by one unit.</span></strong></td>
</tr>
</tbody>
</table>
<p><strong>Interpreting <em>b<sub>1</sub></em> and <em>b<sub>2</sub></em>, the conditional effects:</strong>
You might have already noticed that when W = 0, then most parts of the above equation can be deleted (because multiplications with 0 result in 0). Therefore, we refer to <em>b<sub>1</sub></em> as the conditional effect of X on Y. This means that <em>b<sub>1</sub></em> quantifies how much two cases that differ by one unit on X, but are W = 0, are estimated to differ on Y. <em>The conditional effect quantifies the association between X and Y conditioned on W = 0.</em> Please, do not interpret <em>b<sub>1</sub></em> as the relationship between X and Y “controlling for W on average” or “controlling for W and XW”, which are common phrases in scientific papers but are incorrect. In addition, it is also not correct to call the conditional effect the “main effect of X”, which is a term that is often used in ANOVA and you might already be familiar with it, but it is incorrect for a regression-based moderation analysis. <em>Conditional effects are not the same as main effects.</em>
Like <em>b<sub>1</sub></em>, <em>b<sub>2</sub></em> is a conditional effect and it quantifies how much two cases that differ by one unit on W are estimated to differ on Y conditioned on X = 0.</p>
<table>
<tbody>
<tr class="odd">
<td><strong><span style="color: darkred;">A generic interpretation of the conditional effect in a moderation analysis would be that two individuals who differ by one unit on X are estimated to differ by X’s regression coefficient units on Y when W = 0.</span></strong></td>
</tr>
</tbody>
</table>
<p><strong>Comparing these interpretations with multiple linear regression:</strong> It’s worth noting that the interpretations of <em>b1</em> and <em>b2</em> in moderation analysis differ significantly from the the interpretation of the <em>b1</em> and <em>b2</em> coefficients that you obtain when you run a multiple linear regression, i.e. when XW is not included as an antecedent variable and the regression equation looks like this: Y = i<sub>[Y]</sub> + b<sub>1</sub> * X + b<sub>2</sub> * W. In a multiple linear regression, <em>b1</em> and <em>b2</em> quantify how much two cases that differ by one unit on X are estimated to differ on Y holding W constant (<em>b<sub>1</sub></em>) and how much two cases that differ by one unit on W are estimated to differ on Y holding X constant (<em>b<sub>2</sub></em>). The meaning of conditional effects (conditioned on W = 0) and unconditional effects (controlling for W, i.e. holding W constant) are completely different. Please, try to not confuse the concept of <strong>conditioning</strong> with <strong>controlling</strong>.</p>
<p><em>Interpretation of controlling, i.e. multiple linear regression:</em> Two individuals who differ by one unit on X but are equal on W are estimated to differ by X’s regression coefficient units on Y.</p>
<p><em>Interpretation of conditioning, i.e. moderation analysis:</em> Two individuals who differ by one unit on X but have a zero score in W (W = 0) are estimated to differ by X’s regression coefficient units on Y.</p>
<p><strong>Tip for advanced students:</strong> As a general rule, when XW is in the model and <em>b<sub>3</sub></em> is statistically significant, keep X and W in the model as well (even if inferential tests suggest otherwise). There are very little exceptions from this rule and you can read all about them in <a href="http://afhayes.com/introduction-to-mediation-moderation-and-conditional-process-analysis.html">Hayes, 2022</a>, if this should ever become relevant for you. However, if <em>b<sub>3</sub></em> is not statistically significant, you should omit XW altogether and perform multiple linear regression instead.</p>
</div>
<div id="example-1" class="section level2" number="15.4">
<h2><span class="header-section-number">15.4</span> Example</h2>
<p>That was a lot of high-level statistical input! Let’s take a mental break and turn to an actual example to help you understand the main concepts and how to interpret the model. Once again, we’ll use to the <em>glbwarm</em> data. This time, we’ll create two new variables for our tutorial, so please run this code first:</p>
<div class="sourceCode" id="cb282"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb282-1"><a href="tutorial-moderation-analysis.html#cb282-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(processR)</span>
<span id="cb282-2"><a href="tutorial-moderation-analysis.html#cb282-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb282-3"><a href="tutorial-moderation-analysis.html#cb282-3" aria-hidden="true" tabindex="-1"></a>data <span class="ot"><-</span> processR<span class="sc">::</span>glbwarm</span>
<span id="cb282-4"><a href="tutorial-moderation-analysis.html#cb282-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb282-5"><a href="tutorial-moderation-analysis.html#cb282-5" aria-hidden="true" tabindex="-1"></a>data <span class="ot"><-</span> data <span class="sc">%>%</span> </span>
<span id="cb282-6"><a href="tutorial-moderation-analysis.html#cb282-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ideology_ext =</span> <span class="fu">case_when</span>(</span>
<span id="cb282-7"><a href="tutorial-moderation-analysis.html#cb282-7" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">1</span> <span class="sc">~</span> <span class="dv">4</span>,</span>
<span id="cb282-8"><a href="tutorial-moderation-analysis.html#cb282-8" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">2</span> <span class="sc">~</span> <span class="dv">3</span>,</span>
<span id="cb282-9"><a href="tutorial-moderation-analysis.html#cb282-9" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">3</span> <span class="sc">~</span> <span class="dv">2</span>,</span>
<span id="cb282-10"><a href="tutorial-moderation-analysis.html#cb282-10" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">4</span> <span class="sc">~</span> <span class="dv">1</span>,</span>
<span id="cb282-11"><a href="tutorial-moderation-analysis.html#cb282-11" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">5</span> <span class="sc">~</span> <span class="dv">2</span>,</span>
<span id="cb282-12"><a href="tutorial-moderation-analysis.html#cb282-12" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">6</span> <span class="sc">~</span> <span class="dv">3</span>,</span>
<span id="cb282-13"><a href="tutorial-moderation-analysis.html#cb282-13" aria-hidden="true" tabindex="-1"></a> ideology <span class="sc">==</span> <span class="dv">7</span> <span class="sc">~</span> <span class="dv">4</span>)) <span class="sc">%>%</span></span>
<span id="cb282-14"><a href="tutorial-moderation-analysis.html#cb282-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">conservative_voter =</span> <span class="fu">case_when</span>(</span>
<span id="cb282-15"><a href="tutorial-moderation-analysis.html#cb282-15" aria-hidden="true" tabindex="-1"></a> partyid <span class="sc">==</span> <span class="dv">1</span> <span class="sc">~</span> <span class="st">"Liberal voter"</span>,</span>
<span id="cb282-16"><a href="tutorial-moderation-analysis.html#cb282-16" aria-hidden="true" tabindex="-1"></a> partyid <span class="sc">==</span> <span class="dv">2</span> <span class="sc">~</span> <span class="st">"Liberal voter"</span>,</span>
<span id="cb282-17"><a href="tutorial-moderation-analysis.html#cb282-17" aria-hidden="true" tabindex="-1"></a> partyid <span class="sc">==</span> <span class="dv">3</span> <span class="sc">~</span> <span class="st">"Conservative voter"</span>)) <span class="sc">%>%</span> </span>
<span id="cb282-18"><a href="tutorial-moderation-analysis.html#cb282-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">conservative_voter =</span> <span class="fu">factor</span>(conservative_voter, <span class="at">levels =</span> <span class="fu">c</span>(<span class="st">"Liberal voter"</span>, <span class="st">"Conservative voter"</span>))) <span class="sc">%>%</span></span>
<span id="cb282-19"><a href="tutorial-moderation-analysis.html#cb282-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">conservative_voter_bin =</span> <span class="fu">case_when</span>(</span>
<span id="cb282-20"><a href="tutorial-moderation-analysis.html#cb282-20" aria-hidden="true" tabindex="-1"></a> conservative_voter <span class="sc">==</span> <span class="st">"Liberal voter"</span> <span class="sc">~</span> <span class="dv">0</span>,</span>
<span id="cb282-21"><a href="tutorial-moderation-analysis.html#cb282-21" aria-hidden="true" tabindex="-1"></a> conservative_voter <span class="sc">==</span> <span class="st">"Conservative voter"</span> <span class="sc">~</span> <span class="dv">1</span>))</span></code></pre></div>
<div id="knowing-your-data-2" class="section level3" number="15.4.1">
<h3><span class="header-section-number">15.4.1</span> Knowing your data</h3>
<p>You now have three variables in this data set that we want to continue working with because they are great for learning moderation analysis:</p>
<ol style="list-style-type: decimal">
<li><strong>govact</strong> (= support for government action):
The variable is an index of how each participant answered five questions regarding how supportive he or she is of different policies or activities taken by the US government to address the threat of global climate change (e.g. “How much do you support or oppose increasing government investment for developing alternative energy like biofuels, wind, or solar by 25%?”).<br />
Response options were scaled from “Strongly opposed” (coded 1) or ”Strongly support” (7).</li>
<li><strong>ideology_ext</strong> (= viewpoint extremity):
The political ideology of respondents was measured on a liberalism-conservatism scale. Viewpoint extremity was calculated as the absolute difference of each respondents’ individual score from the liberalism-conservatism scale mean (4), resulting in an extremity score that ranged from 1 “no extremity” to 4 “maximum extremity”,</li>
<li><strong>conservative_voter</strong> (= being Republican, yes/no):
This variable measured self-identification as a voter of the U.S. Republican party, i.e. being a conservative voter. It is a binary / dichotomous variable with 1 = “Conservative voter” and 0 = “Liberal voter”.</li>
</ol>
<p>Throughout this chapter, the following research question will guide us on our way to master moderation analysis:</p>
<p><strong>Research Question:</strong> Is the relationship between viewpoint extremity and support for government action against climate change dependent on vote choice, i.e. on voting for the Republican party? In other words, does the relationship between holding extreme viewpoints and support for government action on climate change differ between conservative and liberal voters?</p>
</div>
<div id="visual-inspection-of-linear-trends-2" class="section level3" number="15.4.2">
<h3><span class="header-section-number">15.4.2</span> Visual inspection of linear trends</h3>
<p>Our interest is in whether the effect of viewpoint extremity (X) on support for government action against climate change (Y) depends on voting for the Republican party (W). Once again, to answer a research question, it’s extremely useful to have a look at your variables prior to your analysis. So let’s start by examining the relationship between <em>viewpoint extremity</em>, i.e. holding extreme political viewpoints, and <em>support for government action against climate change</em>:</p>
<div class="sourceCode" id="cb283"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb283-1"><a href="tutorial-moderation-analysis.html#cb283-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggpubr)</span>
<span id="cb283-2"><a href="tutorial-moderation-analysis.html#cb283-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb283-3"><a href="tutorial-moderation-analysis.html#cb283-3" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%>%</span> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span>ideology_ext, <span class="at">y=</span>govact)) <span class="sc">+</span> </span>
<span id="cb283-4"><a href="tutorial-moderation-analysis.html#cb283-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_count</span>() <span class="sc">+</span> </span>
<span id="cb283-5"><a href="tutorial-moderation-analysis.html#cb283-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>() <span class="sc">+</span> </span>
<span id="cb283-6"><a href="tutorial-moderation-analysis.html#cb283-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x=</span><span class="st">"Viewpoint extremity"</span>, <span class="at">y=</span><span class="st">"Support for government action against climate change"</span>) <span class="sc">+</span></span>
<span id="cb283-7"><a href="tutorial-moderation-analysis.html#cb283-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_smooth</span>(<span class="at">method=</span><span class="st">'lm'</span>, <span class="at">formula=</span> y<span class="sc">~</span>x,<span class="at">se=</span><span class="cn">FALSE</span>, <span class="at">color =</span> <span class="st">"darkred"</span>) <span class="sc">+</span></span>
<span id="cb283-8"><a href="tutorial-moderation-analysis.html#cb283-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_regline_equation</span>(<span class="at">label.y =</span> <span class="fl">1.4</span>)</span></code></pre></div>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-116-1.png" width="672" /></p>
<p><strong>Evaluation:</strong> It is evident that <em>viewpoint extremity</em> and <em>support for government action against climate change</em> share a negative relationship.Individuals who hold more extreme political viewpoints are less likely to support for government action against climate change.</p>
<p><em>What could be the explanation for a negative relationship?</em> Perhaps U.S. citizens with extreme ideological attitudes have a poorer relationship with governments in general? It could be that radicalized citizens distrust government more and therefore do not want to support government action, even in the case of climate change. To test this hypothesis, we would need to conduct a mediation analysis with a mediator variable called “distrust in government” to determine whether distrust in government is indeed the missing link. However, our data does not provide such a variable. Too bad.</p>
<p><em>But there might also be another explanation.</em> Liberal voters care more about climate change, while conservative voters do not think climate change is an important political issue. Maybe the support for government action on climate change might differ between these to voter groups? Let’s make a visual check of this hypothesis by looking at the regression lines of both voter groups:</p>
<div class="sourceCode" id="cb284"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb284-1"><a href="tutorial-moderation-analysis.html#cb284-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggpubr)</span>
<span id="cb284-2"><a href="tutorial-moderation-analysis.html#cb284-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb284-3"><a href="tutorial-moderation-analysis.html#cb284-3" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%>%</span> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span>ideology_ext, <span class="at">y=</span>govact, <span class="at">color =</span> conservative_voter)) <span class="sc">+</span> </span>
<span id="cb284-4"><a href="tutorial-moderation-analysis.html#cb284-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_count</span>() <span class="sc">+</span></span>
<span id="cb284-5"><a href="tutorial-moderation-analysis.html#cb284-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"Liberal voter"</span> <span class="ot">=</span> <span class="st">"mediumblue"</span>, <span class="st">"Conservative voter"</span> <span class="ot">=</span> <span class="st">"#CC0000"</span>)) <span class="sc">+</span></span>
<span id="cb284-6"><a href="tutorial-moderation-analysis.html#cb284-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>() <span class="sc">+</span></span>
<span id="cb284-7"><a href="tutorial-moderation-analysis.html#cb284-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"none"</span>) <span class="sc">+</span></span>
<span id="cb284-8"><a href="tutorial-moderation-analysis.html#cb284-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x=</span><span class="st">"Viewpiont extremity"</span>, <span class="at">y=</span><span class="st">"Support for government action against climate change"</span>) <span class="sc">+</span></span>
<span id="cb284-9"><a href="tutorial-moderation-analysis.html#cb284-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_smooth</span>(<span class="at">method=</span><span class="st">'lm'</span>, <span class="at">formula=</span> y<span class="sc">~</span>x,<span class="at">se=</span><span class="cn">FALSE</span>, <span class="at">color =</span> <span class="st">"#404040"</span>) <span class="sc">+</span></span>
<span id="cb284-10"><a href="tutorial-moderation-analysis.html#cb284-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_regline_equation</span>(<span class="at">label.y =</span> <span class="fl">1.4</span>) <span class="sc">+</span> </span>
<span id="cb284-11"><a href="tutorial-moderation-analysis.html#cb284-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>conservative_voter)</span></code></pre></div>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-117-1.png" width="672" /></p>
<p>Instead of the regressions, you can also compare the mean values of the two groups if you like this form of presentation better:</p>
<div class="sourceCode" id="cb285"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb285-1"><a href="tutorial-moderation-analysis.html#cb285-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggpubr)</span>
<span id="cb285-2"><a href="tutorial-moderation-analysis.html#cb285-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb285-3"><a href="tutorial-moderation-analysis.html#cb285-3" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%>%</span> </span>
<span id="cb285-4"><a href="tutorial-moderation-analysis.html#cb285-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggline</span>(<span class="at">x =</span> <span class="st">"ideology_ext"</span>, <span class="at">y =</span> <span class="st">"govact"</span>, <span class="at">color =</span> <span class="st">"conservative_voter"</span>,</span>
<span id="cb285-5"><a href="tutorial-moderation-analysis.html#cb285-5" aria-hidden="true" tabindex="-1"></a> <span class="at">add =</span> <span class="fu">c</span>(<span class="st">"mean_ci"</span>),</span>
<span id="cb285-6"><a href="tutorial-moderation-analysis.html#cb285-6" aria-hidden="true" tabindex="-1"></a> <span class="at">palette =</span> <span class="fu">c</span>(<span class="st">"mediumblue "</span>, <span class="st">"#CC0000"</span>),</span>
<span id="cb285-7"><a href="tutorial-moderation-analysis.html#cb285-7" aria-hidden="true" tabindex="-1"></a> <span class="at">linetype =</span> <span class="st">"conservative_voter"</span>, <span class="at">shape =</span> <span class="st">"conservative_voter"</span>, <span class="at">size=</span><span class="fl">1.0</span>,</span>
<span id="cb285-8"><a href="tutorial-moderation-analysis.html#cb285-8" aria-hidden="true" tabindex="-1"></a> <span class="at">legend =</span> <span class="st">"right"</span>,</span>
<span id="cb285-9"><a href="tutorial-moderation-analysis.html#cb285-9" aria-hidden="true" tabindex="-1"></a> <span class="at">ylab =</span> <span class="st">"Support for goverment action against climate change"</span>, <span class="at">xlab =</span> <span class="st">"Viewpiont extremity"</span>,</span>
<span id="cb285-10"><a href="tutorial-moderation-analysis.html#cb285-10" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title =</span> <span class="st">""</span>, <span class="at">title=</span><span class="st">""</span>) <span class="sc">+</span></span>
<span id="cb285-11"><a href="tutorial-moderation-analysis.html#cb285-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code></pre></div>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-118-1.png" width="672" /></p>
<p><strong>Evaluation:</strong> Obviously, there is an interaction at play here! The effect of <em>viewpoint extremity</em> on <em>support for government action against climate change</em> seems to be dependent on voting for the U.S. Republican party, i.e. being a liberal or a conservative voter. To be precise, moderate liberal and conservative voters, i.e. those who have low viewpoint extremity, do not differ in their support for government action against climate change. But extreme liberal and conservative voters, i.e. those who have high viewpoint extremity, differ significantly in their support for government action against climate change. While extreme liberal voters become more supportive of government action, extreme conservative voters become more opposed against government actions. In fact, <em>viewpoint extremity</em> has a positive effect on <em>support for government action against climate change</em> for liberal voters (b = 0.18), but a negative effect on <em>support for government action against climate change</em> for conservative voters (b = -0.53).</p>
<p>Before we move on to fitting the models and interpreting coefficients, let’s investigate how Y changes on different levels of X and W. This way, we will get a better feeling for the interaction effect that is happening in our data. The first plot treats viewpoint extremity as the focal predictor and vote choice as the moderator. The second plot treats vote choice as focal predictor and viewpoint extremity as moderator:</p>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-119-1.png" width="672" /></p>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-120-1.png" width="672" /></p>
<p><strong>Evaluation:</strong> It seems that viewpoint extremity has a way greater impact on support for government action for conservative voters than for liberal voters. I think we now know enough about our data and are ready to fit some models!</p>
</div>
<div id="fit-models-1" class="section level3" number="15.4.3">
<h3><span class="header-section-number">15.4.3</span> Fit models</h3>
<p>Now that we have a visual indicator that voting for the Republican party might be a relevant moderator of the relationship between <em>viewpoint extremity</em> and <em>support for government action against climate change</em> (it does change the direction of influence from negative to positive!), we should run a linear regression model to test these effects for their statistical significance. The linear model must include both the X (<em>viewpoint extremity</em>) and the W variable (<em>conservative_voter</em>) and their product XW (<em>viewpoint extremity</em> * <em>conservative_voter</em>). Let’s run such a model with the <code>lm()</code> function.</p>
<div class="sourceCode" id="cb286"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb286-1"><a href="tutorial-moderation-analysis.html#cb286-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(<span class="fu">lm</span>(govact <span class="sc">~</span> ideology_ext<span class="sc">+</span>conservative_voter<span class="sc">+</span>ideology_ext<span class="sc">*</span>conservative_voter,<span class="at">data=</span>data))</span></code></pre></div>
<pre><code>##
## Call:
## lm(formula = govact ~ ideology_ext + conservative_voter + ideology_ext *
## conservative_voter, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2790 -0.7421 0.0789 0.8579 3.6728
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.56317 0.11337 40.249 < 0.0000000000000002 ***
## ideology_ext 0.17895 0.05268 3.397 0.000715 ***
## conservative_voterConservative voter 0.67547 0.22961 2.942 0.003356 **
## ideology_ext:conservative_voterConservative voter -0.70680 0.09098 -7.769 0.0000000000000239 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.237 on 811 degrees of freedom
## Multiple R-squared: 0.1767, Adjusted R-squared: 0.1737
## F-statistic: 58.02 on 3 and 811 DF, p-value: < 0.00000000000000022</code></pre>
<p><strong>Evaluation:</strong> We can infer the regression equation from this output: Y = 4.563 + 0.178 * X + 0.675 * W - 0.706 * XW, where i<sub>[Y]</sub> = 4.563, <em>b<sub>1</sub></em> = 0.178, <em>b<sub>2</sub></em> = 0.675, and <em>b<sub>3</sub></em> = -0.706.</p>
<p><em>Interpretation of b<sub>3</sub>’s significance:</em> Most importantly, <em>b<sub>3</sub></em> is statistically different from zero, t(811) = -7.769, <em>p</em> < .001. This means that we can conclude that the effect of viewpoint extremity on support for government action against climate change is moderated by vote choice, i.e. voting for the Republican party. We now know that viewpoint extremity has a different effect on support for government action for different political groups. That’s an important finding! Had there been no evidence of moderation (i.e., <em>b<sub>3</sub></em> was not statistically different from zero), the most sensible approach would be to reestimate the model excluding the product XW (i.e. running a multiple linear regression!), thereby allowing X’s effect to be invariant across W.</p>
<p><em>Interpretation of b<sub>3</sub>’s coefficient:</em> The interaction effect’s <em>b<sub>3</sub></em> coefficient quantifies how the effect of X on Y changes as W changes by one unit. If <em>b<sub>3</sub></em> is negative, as is here the case, then this shows that the effect of X on Y will get more negative (get smaller) as W gets larger, and that the effect of W on Y will get more negative (get smaller) as X gets larger. This becomes more obvious when we plug in actual values in the regression equation and watch how Y behaves for different values of X and W. To this end, take a look at the following moderation analysis output of <code>processR</code>, because <code>processR</code> has a handy function that inserts the values automatically, so you don`t have to do this manually (output section: “Data for visualizing the conditional effect of the focal predictor”).</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Table 1: Change in the focal predictors X conditioned on W:</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut15_ideology_ext_as_fp.JPG" /></td>
</tr>
</tbody>
</table>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Table 2: Change in the focal predictors W conditioned on X:</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut15_vote_choice_as_fp.JPG" /></td>
</tr>
</tbody>
</table>
<p>As you can see in the first table, support for government action decreases with larger values of viewpoint extremity for conservative voters (W = 1), but increases with larger values of viewpoint extremity for liberal voters (W = 0). Like table 1, table 2 shows that the difference in support for government action between conservative and liberal voters becomes greater as viewpoint diversity increases (from X= 1 to X = 3), i.e. the decrease in support for government action becomes greater. It is this pattern that is meant when we learn that the effect of X on Y will get more negative (get smaller) as W gets larger, and that the effect of W on Y will get more negative (get smaller) as X gets larger. In fact, we can interpret <em>b<sub>3</sub></em> as a “difference between differences” (Hayes, 2022, p. 255): Here, the effect of viewpoint extremity on support for government action depends on vote choice, i.e., support for government action decreases by -0.706 with every one-point increase in viewpoint extremity for conservative voters (W = 1).</p>
<p><em>General interpretation of b<sub>1</sub> and b<sub>2</sub>:</em> <em>b<sub>1</sub></em> and <em>b<sub>2</sub></em> are conditional effects. These regression coefficients estimate the effect of X when W = 0 and the effect of W when X = 0, respectively. You’ll realize soon that these coefficients aren’t always sensible, for instance, viewpoint extremity (X) can’t even become 0 on our chosen scale that ranges from 1 to 4. We’ll discuss that in a second.</p>
<p><em>Interpretation of b<sub>1</sub>’s coefficient:</em> The regression coefficient for the conditional effect of X is <em>b<sub>1</sub></em> = 0.178 (<em>p</em> < .001). This is the estimated difference in support for government action against climate change between two individuals who differ by one unit in their viewpoint extremity, but both score zero on the <em>conservative_voter</em> variable, i.e. are liberal voters. This score is positive, which implies that liberals who have a one unit increase in their viewpoint extremity are estimates to have a 0.178 increase in their support for government action.</p>
<p><em>Interpretation of b<sub>2</sub>’s coefficient:</em> The regression coefficient for the conditional effect of W is <em>b<sub>2</sub></em> = 0.675 (<em>p</em> < .01).This is the estimated difference in support for government action against climate change between liberals and conservatives who score zero on viewpoint extremity (X = 0), i.e. they are estimated to differ by 0.675 points. Although this interpretation is mathematically correct, substantively it is nonsense because the measure of viewpoint extremity in this study is mathematically bound between 1 and 4. An estimate of the effect of vote choice conditioned on a score of zero on viewpoint extremity has no meaning because no such people could even exist.</p>
<p>Finally, let’s look at a visual representation of our effects and the respective coefficients to develop an intuitive understanding of what they mean:</p>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-122-1.png" width="672" /></p>
<p>Try to keep this visual representation in mind or refer back to it whenever you have trouble to interpret your coefficients in a moderation analysis.</p>
</div>
<div id="standardization-and-mean-centering" class="section level3" number="15.4.4">
<h3><span class="header-section-number">15.4.4</span> Standardization and mean-centering</h3>
<p>You might already have guessed it, but a good way to get meaningful regression coefficients for variables that are not mathematically between 0 and a finite value is to standardize. Let’s run the model again with a standardized <em>viewpoint extremity</em> (do not standardize the binary vote choice variable <em>conservative_voter</em>!):</p>
<div class="sourceCode" id="cb288"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb288-1"><a href="tutorial-moderation-analysis.html#cb288-1" aria-hidden="true" tabindex="-1"></a>data<span class="sc">$</span>ideology_ext_st <span class="ot"><-</span> <span class="fu">scale</span>(data<span class="sc">$</span>ideology_ext)</span>
<span id="cb288-2"><a href="tutorial-moderation-analysis.html#cb288-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb288-3"><a href="tutorial-moderation-analysis.html#cb288-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(<span class="fu">lm</span>(govact <span class="sc">~</span> ideology_ext_st<span class="sc">+</span>conservative_voter<span class="sc">+</span>ideology_ext_st<span class="sc">*</span>conservative_voter,<span class="at">data=</span>data))</span></code></pre></div>
<pre><code>##
## Call:
## lm(formula = govact ~ ideology_ext_st + conservative_voter +
## ideology_ext_st * conservative_voter, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2790 -0.7421 0.0789 0.8579 3.6728
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.93797 0.05362 92.100 < 0.0000000000000002 ***
## ideology_ext_st 0.18709 0.05508 3.397 0.000715 ***
## conservative_voterConservative voter -0.80491 0.09758 -8.248 0.000000000000000645 ***
## ideology_ext_st:conservative_voterConservative voter -0.73895 0.09512 -7.769 0.000000000000023933 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.237 on 811 degrees of freedom
## Multiple R-squared: 0.1767, Adjusted R-squared: 0.1737
## F-statistic: 58.02 on 3 and 811 DF, p-value: < 0.00000000000000022</code></pre>
<p><strong>Evaluation:</strong> With a standardized <em>viewpoint extremity</em> variable, you can now interpret scores of X = 0 as the mean (because standardization includes centering variables on their mean, i.e. X = 0 when X = mean(X) = 2.094). <em>b<sub>2</sub></em> = -0.804 (<em>p</em> < .001) is the estimated difference in support for government action against climate change between liberals and conservatives who score <strong>average</strong> on viewpoint extremity (X = 0). Conservatives who score <strong>average</strong> on viewpoint extremity are estimated to score -0.804 points lower on support for government action than liberals who score <strong>average</strong> on viewpoint extremity.</p>
<p><strong>Note:</strong> Please remember that when you standardize a variable, the meaning of a one unit increase in that variable changes, i.e. it becomes a one-standard deviation increase. For example, <em>b<sub>1</sub></em> = 0.187 (<em>p</em> < .001) now changes it’s meaning: Two liberal voters who have a one point standard deviation difference in their viewpoint extremity are estimated to differ by 0.187 points in their support for government action against climate change.</p>
<p><strong>Mean-centering:</strong> An alternative to standardization is mean-centering. For standardization, you remove the mean from each observed value of the variable and divide by its standard deviation. Therefore, all changes in units must be interpreted in terms of standard deviations from the mean. However, mean centering removes the mean from each observed value of the variable, but <em>without dividing by the standard deviation of the variable</em>. Therefore, the advantage of mean-centering is the ease of interpretation, since a change of one unit is still a change of one unit, not a change of one standard deviation.</p>
<div class="sourceCode" id="cb290"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb290-1"><a href="tutorial-moderation-analysis.html#cb290-1" aria-hidden="true" tabindex="-1"></a>data<span class="sc">$</span>ideology_ext_mc <span class="ot"><-</span> <span class="fu">scale</span>(data<span class="sc">$</span>ideology_ext, <span class="at">center =</span> <span class="cn">TRUE</span>, <span class="at">scale=</span><span class="cn">FALSE</span>)</span>
<span id="cb290-2"><a href="tutorial-moderation-analysis.html#cb290-2" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(data<span class="sc">$</span>ideology_ext)</span></code></pre></div>
<pre><code>## [1] 2.094479</code></pre>
<div class="sourceCode" id="cb292"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb292-1"><a href="tutorial-moderation-analysis.html#cb292-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(<span class="fu">lm</span>(govact <span class="sc">~</span> ideology_ext_mc<span class="sc">+</span>conservative_voter<span class="sc">+</span>ideology_ext_mc<span class="sc">*</span>conservative_voter,<span class="at">data=</span>data))</span></code></pre></div>
<pre><code>##
## Call:
## lm(formula = govact ~ ideology_ext_mc + conservative_voter +
## ideology_ext_mc * conservative_voter, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2790 -0.7421 0.0789 0.8579 3.6728
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.93797 0.05362 92.100 < 0.0000000000000002 ***
## ideology_ext_mc 0.17895 0.05268 3.397 0.000715 ***
## conservative_voterConservative voter -0.80491 0.09758 -8.248 0.000000000000000645 ***
## ideology_ext_mc:conservative_voterConservative voter -0.70680 0.09098 -7.769 0.000000000000023933 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.237 on 811 degrees of freedom
## Multiple R-squared: 0.1767, Adjusted R-squared: 0.1737
## F-statistic: 58.02 on 3 and 811 DF, p-value: < 0.00000000000000022</code></pre>
<p><strong>Evaluation:</strong> The reparameterization has changed the meaning of <em>b<sub>2</sub></em>, i.e., you can now interpret scores of X = 0 as the mean because now X = 0 when X = mean(X) = 2.094. This means that <em>b<sub>2</sub></em> now estimates the difference in support for government action against climate change between liberals and conservatives who score <strong>average</strong> on viewpoint extremity (X = 0). With mean-centering you do not need to interpret <em>b<sub>2</sub></em> in standard deviation units.</p>
</div>
<div id="follow-up-analysis-pobing-the-interaction" class="section level3" number="15.4.5">
<h3><span class="header-section-number">15.4.5</span> Follow-up analysis: Pobing the interaction</h3>
<p>Testing an interaction has its limits because it only allows us to say that viewpoint extremity affects U.S. citizens differently depending on whether or not they vote for the Republican party. But that’s not a very precise claim to make. Therefore, once we have determined that an interaction effect exists, that is, once we have tested for a moderation effect and found it to be statistically significant, we should investigate that interaction further. This is referred to as <strong>“probing the interaction”</strong>, and it entails determining if the conditional effect of X on Y is greater than zero for particular levels of W. If we select two or more values of W and then test to see if the effect of X on Y is different from zero at those specific values, then we can get to know where in the distribution of W X exerts its effect on Y—and where in the distribution it does not.</p>
<p>I personally like the package <code>Interactions</code> very much to investigate interactions in R. So I recommend to install the package and run the following code. However, the <code>Interactions</code> package does not work with factor variables, so we need to recode <em>conservative_voter</em> to 0s and 1s and save this new variable as <em>conservative_voter_bin</em>.</p>
<div class="sourceCode" id="cb294"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb294-1"><a href="tutorial-moderation-analysis.html#cb294-1" aria-hidden="true" tabindex="-1"></a><span class="co"># install.packages("interactions") # to install the package (only first time)</span></span>
<span id="cb294-2"><a href="tutorial-moderation-analysis.html#cb294-2" aria-hidden="true" tabindex="-1"></a><span class="co"># install.packages("sandwich") # the interactions package needs this one to work, so please install it, too (only first time)</span></span>
<span id="cb294-3"><a href="tutorial-moderation-analysis.html#cb294-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(interactions) <span class="co"># a package that allows you to inspect interaction effects graphically</span></span>
<span id="cb294-4"><a href="tutorial-moderation-analysis.html#cb294-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb294-5"><a href="tutorial-moderation-analysis.html#cb294-5" aria-hidden="true" tabindex="-1"></a>data <span class="ot"><-</span> data <span class="sc">%>%</span> </span>
<span id="cb294-6"><a href="tutorial-moderation-analysis.html#cb294-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">conservative_voter_bin =</span> <span class="fu">case_when</span>(</span>
<span id="cb294-7"><a href="tutorial-moderation-analysis.html#cb294-7" aria-hidden="true" tabindex="-1"></a> conservative_voter <span class="sc">==</span> <span class="st">"Liberal voter"</span> <span class="sc">~</span> <span class="dv">0</span>,</span>
<span id="cb294-8"><a href="tutorial-moderation-analysis.html#cb294-8" aria-hidden="true" tabindex="-1"></a> conservative_voter <span class="sc">==</span> <span class="st">"Conservative voter"</span> <span class="sc">~</span> <span class="dv">1</span>))</span>
<span id="cb294-9"><a href="tutorial-moderation-analysis.html#cb294-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb294-10"><a href="tutorial-moderation-analysis.html#cb294-10" aria-hidden="true" tabindex="-1"></a><span class="co"># Run your moderation analysis and save it to a source object:</span></span>
<span id="cb294-11"><a href="tutorial-moderation-analysis.html#cb294-11" aria-hidden="true" tabindex="-1"></a>intrct_model <span class="ot"><-</span> <span class="fu">lm</span>(govact <span class="sc">~</span> ideology_ext<span class="sc">+</span>conservative_voter_bin<span class="sc">+</span>ideology_ext<span class="sc">*</span>conservative_voter_bin,<span class="at">data=</span>data)</span></code></pre></div>
<p>First, let’s investigate the change in the focal predictors X (viewpoint extremity) conditioned on different levels of W (vote choice). You have seen this kind of analysis before: in Table 1 in <a href="tutorial-moderation-analysis.html#fit-models-1">Fit models</a>.</p>
<div class="sourceCode" id="cb295"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb295-1"><a href="tutorial-moderation-analysis.html#cb295-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Viewpoint extremity as focal predictor, vote choice as moderator:</span></span>
<span id="cb295-2"><a href="tutorial-moderation-analysis.html#cb295-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sim_slopes</span>(intrct_model, <span class="at">pred=</span>ideology_ext, <span class="at">modx=</span>conservative_voter_bin)</span></code></pre></div>
<pre><code>## JOHNSON-NEYMAN INTERVAL
##
## When conservative_voter_bin is OUTSIDE the interval [0.12, 0.37], the slope of ideology_ext is p < .05.
##
## Note: The range of observed values of conservative_voter_bin is [0.00, 1.00]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of ideology_ext when conservative_voter_bin = 0.00 (0):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.18 0.05 3.40 0.00
##
## Slope of ideology_ext when conservative_voter_bin = 1.00 (1):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.53 0.07 -7.12 0.00</code></pre>
<p><strong>Evaluation:</strong> The results show that for both levels of voting choice, i.e., liberal (W = 0) and conservative (W = 1) voters, the effect of X on Y is different from zero, i.e. significant. That is, the extremity of viewpoint affects support for government action on climate change for both liberal and conservative voters.</p>
<p>Next, let’s do the same analysis for the change of W (vote choice) conditioned on different levels of X (viewpoint extremity). Again, you have seen this kind of analysis before: in Table 2 in <a href="tutorial-moderation-analysis.html#fit-models-1">Fit models</a>.</p>
<div class="sourceCode" id="cb297"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb297-1"><a href="tutorial-moderation-analysis.html#cb297-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Vote choice as focal predictor, viewpoint extremity as moderator</span></span>
<span id="cb297-2"><a href="tutorial-moderation-analysis.html#cb297-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sim_slopes</span>(intrct_model, <span class="at">pred=</span>conservative_voter_bin, <span class="at">modx=</span>ideology_ext)</span></code></pre></div>
<pre><code>## JOHNSON-NEYMAN INTERVAL
##
## When ideology_ext is OUTSIDE the interval [0.41, 1.32], the slope of conservative_voter_bin is p < .05.
##
## Note: The range of observed values of ideology_ext is [1.00, 4.00]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of conservative_voter_bin when ideology_ext = 1.048999 (- 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.07 0.15 -0.44 0.66
##
## Slope of conservative_voter_bin when ideology_ext = 2.094479 (Mean):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.80 0.10 -8.25 0.00
##
## Slope of conservative_voter_bin when ideology_ext = 3.139959 (+ 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -1.54 0.12 -12.55 0.00</code></pre>
<p><strong>Evaluation:</strong> These results show that vote choice of citizens who score low on viewpoint extremity (here: -1 standard deviation from the mean, which is a score of X = 1.04) does not affect how much they support government action on climate change (estimated difference in support for government action between conservatives and liberals is -0.07, which is not statistically different from zero, <em>p</em> = .66). However, the more extreme citizens’ viewpoints become, the more important their vote choice is in determining how much they support government action against climate change. For citizens that score average on viewpoint extremity (Mean = 2.09), vote choice does affect how much they support government action on climate change (estimated difference in support for government action between conservatives and liberals is -0.80, which is statistically different from zero, <em>p</em> < .001). The same holds true for citizens who score high on viewpoint extremity (<em>p</em> < .001).</p>
<p>We can visualize these trends with the so-called <strong>Johnson-Neyman plot</strong> that plots the two values of the moderator at which the slope of the focal predictor X changes from non-significant to significant:</p>
<div class="sourceCode" id="cb299"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb299-1"><a href="tutorial-moderation-analysis.html#cb299-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Creating a Johnson-Neyman Plot for viewpoint extremity as focal predictor, vote choice as moderator:</span></span>
<span id="cb299-2"><a href="tutorial-moderation-analysis.html#cb299-2" aria-hidden="true" tabindex="-1"></a><span class="fu">jnPlot</span>(intrct_model, <span class="at">pred=</span><span class="st">"ideology_ext"</span>, <span class="at">modx=</span><span class="st">"conservative_voter_bin"</span>, <span class="at">plot =</span> <span class="cn">FALSE</span>,<span class="at">mode=</span><span class="dv">1</span>,<span class="at">addEq=</span><span class="cn">FALSE</span>)</span></code></pre></div>
<pre><code>## JOHNSON-NEYMAN INTERVAL
##
## When conservative_voter_bin is OUTSIDE the interval [0.122, 0.373], the slope of ideology_ext is p < .05.
##
## Note: The range of observed values of conservative_voter_bin is [0.000, 1.000]</code></pre>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-128-1.png" width="160%" /></p>
<p><strong>Evaluation:</strong> Again, we can infer that for both levels of vote choice, i.e., liberal (W = 0) and conservative (W = 1), the effect of X on Y is different from zero, i.e. significant. The effect only becomes non-significant between W = 0.122 and W = 0.373. However, these two limits of W are nonsensical, since there are no individuals who can score these values, as our scale is binary and can only take the values 0 and 1.</p>
<p>Next, let’s plot the Johnson-Neyman plot for W as focal predictor:</p>
<div class="sourceCode" id="cb301"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb301-1"><a href="tutorial-moderation-analysis.html#cb301-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Creating a Johnson-Neyman Plot for vote choice as focal predictor, viewpoint extremity as moderator:</span></span>
<span id="cb301-2"><a href="tutorial-moderation-analysis.html#cb301-2" aria-hidden="true" tabindex="-1"></a><span class="fu">jnPlot</span>(intrct_model, <span class="at">pred=</span><span class="st">"conservative_voter_bin"</span>, <span class="at">modx=</span><span class="st">"ideology_ext"</span>, <span class="at">plot =</span> <span class="cn">FALSE</span>,<span class="at">mode=</span><span class="dv">1</span>,<span class="at">addEq=</span><span class="cn">FALSE</span>)</span></code></pre></div>
<pre><code>## JOHNSON-NEYMAN INTERVAL
##
## When ideology_ext is OUTSIDE the interval [0.411, 1.318], the slope of conservative_voter_bin is p < .05.
##
## Note: The range of observed values of ideology_ext is [1.000, 4.000]</code></pre>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-129-1.png" width="100%" /></p>
<p><strong>Evaluation:</strong> This plot shows that the effect of vote choice on support for government action turns insignificant for citizens who score lower on viewpoint extremity than < 1.318. This means that for citizens who score very low on viewpoint extremity, support for government actions against climate change is independent of viewpoint extremity.</p>
<p>Of course, the <code>interactions</code> package allows you to visualize the interaction effects, too. You can use these plots if you don’t want to build them with <code>ggplot</code> and <code>ggpubr</code>, like we did in the section on <a href="tutorial-moderation-analysis.html#visual-inspection-of-linear-trends-2">Visual inspection of linear trends</a>:</p>
<div class="sourceCode" id="cb303"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb303-1"><a href="tutorial-moderation-analysis.html#cb303-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Interaction plot for viewpoint extremity as focal predictor, vote choice as moderator:</span></span>
<span id="cb303-2"><a href="tutorial-moderation-analysis.html#cb303-2" aria-hidden="true" tabindex="-1"></a><span class="fu">interact_plot</span>(intrct_model, <span class="at">pred=</span>ideology_ext, <span class="at">modx=</span>conservative_voter_bin,</span>
<span id="cb303-3"><a href="tutorial-moderation-analysis.html#cb303-3" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.points =</span> <span class="cn">FALSE</span>, <span class="at">interval =</span> <span class="cn">TRUE</span>, <span class="at">int.type =</span> <span class="fu">c</span>(<span class="st">"confidence"</span>,<span class="st">"prediction"</span>), <span class="at">int.width =</span> <span class="fl">0.95</span>, <span class="at">outcome.scale =</span> <span class="st">"response"</span>,</span>
<span id="cb303-4"><a href="tutorial-moderation-analysis.html#cb303-4" aria-hidden="true" tabindex="-1"></a> <span class="at">x.label =</span> <span class="st">"Viewpoint extremity"</span>, <span class="at">y.label =</span> <span class="st">"Support for government action against climate change"</span>, </span>
<span id="cb303-5"><a href="tutorial-moderation-analysis.html#cb303-5" aria-hidden="true" tabindex="-1"></a> <span class="at">modx.labels =</span> <span class="fu">c</span>(<span class="st">"Liberal Voter"</span>, <span class="st">"Conservative voter"</span>),</span>
<span id="cb303-6"><a href="tutorial-moderation-analysis.html#cb303-6" aria-hidden="true" tabindex="-1"></a> <span class="at">main.title =</span> <span class="cn">NULL</span>, <span class="at">legend.main =</span> <span class="st">"Vote choice"</span>,</span>
<span id="cb303-7"><a href="tutorial-moderation-analysis.html#cb303-7" aria-hidden="true" tabindex="-1"></a> <span class="at">colors =</span> <span class="fu">c</span>(<span class="st">"mediumblue"</span>, <span class="st">"#CC0000"</span>), <span class="at">line.thickness =</span> <span class="fl">1.1</span>, <span class="at">vary.lty =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-130-1.png" width="672" /></p>
<div class="sourceCode" id="cb304"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb304-1"><a href="tutorial-moderation-analysis.html#cb304-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Interaction plot for vote choice as focal predictor, viewpoint extremity as moderator:</span></span>
<span id="cb304-2"><a href="tutorial-moderation-analysis.html#cb304-2" aria-hidden="true" tabindex="-1"></a><span class="fu">interact_plot</span>(intrct_model, <span class="at">pred=</span>conservative_voter_bin, <span class="at">modx=</span>ideology_ext,</span>
<span id="cb304-3"><a href="tutorial-moderation-analysis.html#cb304-3" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.points =</span> <span class="cn">FALSE</span>, <span class="at">interval =</span> <span class="cn">TRUE</span>, <span class="at">int.type =</span> <span class="fu">c</span>(<span class="st">"confidence"</span>,</span>
<span id="cb304-4"><a href="tutorial-moderation-analysis.html#cb304-4" aria-hidden="true" tabindex="-1"></a> <span class="st">"prediction"</span>), <span class="at">int.width =</span> <span class="fl">0.95</span>, <span class="at">outcome.scale =</span> <span class="st">"response"</span>,</span>
<span id="cb304-5"><a href="tutorial-moderation-analysis.html#cb304-5" aria-hidden="true" tabindex="-1"></a> <span class="at">x.label =</span> <span class="st">"Vote choice"</span>, <span class="at">y.label =</span> <span class="st">"Support for government action against climate change"</span>,</span>
<span id="cb304-6"><a href="tutorial-moderation-analysis.html#cb304-6" aria-hidden="true" tabindex="-1"></a> <span class="at">main.title =</span> <span class="cn">NULL</span>, <span class="at">legend.main =</span> <span class="st">"Viewpoint extremity"</span>,</span>
<span id="cb304-7"><a href="tutorial-moderation-analysis.html#cb304-7" aria-hidden="true" tabindex="-1"></a> <span class="at">colors =</span> <span class="fu">c</span>(<span class="st">"#F7BA83"</span>, <span class="st">"#EF6547"</span>, <span class="st">"#7F1C15"</span>), <span class="at">line.thickness =</span> <span class="fl">1.1</span>, <span class="at">vary.lty =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<p><img src="CPA-Seminar_files/figure-html/unnamed-chunk-131-1.png" width="672" /></p>
<p><strong>Final evaluation</strong>: After having probed the interaction, we now can make more accurate claims than just stating that viewpoint extremity affects U.S. citizens differently depending on whether or not they vote for the Republican party. We now know that this only holds true for citizens that score average to high on viewpoint extremity, i.e. have a viewpoint extremity greater than > 1.318.</p>
</div>
<div id="using-processr-1" class="section level3" number="15.4.6">
<h3><span class="header-section-number">15.4.6</span> Using processR</h3>
<p>Finally, you can use the easy road and do everything with the <code>processR</code> function. Before using the function, you need to (maybe download again, here’s the <a href="https://www.processmacro.org/download.html">link</a>, and) run the <code>processR</code> script again (this can take a few minutes) that you’ve already used in the 13th <a href="tutorial-mediation-analysis.html#tutorial-mediation-analysis">Tutorial: Mediation analysis</a>.</p>
<p>Once you’ve created the <code>process</code> function, we’ll perform the moderation analysis again, but this time we will use <code>processR</code>. Unfortunately, <code>processR</code> does not like factor variables either, so we will use the 0/1 binary <em>conservative_voter_bin</em> variable again.</p>
<div class="sourceCode" id="cb305"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb305-1"><a href="tutorial-moderation-analysis.html#cb305-1" aria-hidden="true" tabindex="-1"></a><span class="fu">process</span>(<span class="at">data=</span>data,<span class="at">y=</span><span class="st">"govact"</span>,<span class="at">x=</span><span class="st">"ideology_ext"</span>,<span class="at">w=</span><span class="st">"conservative_voter_bin"</span>,<span class="at">model=</span><span class="dv">1</span>,<span class="at">plot=</span><span class="dv">1</span>)</span>
<span id="cb305-2"><a href="tutorial-moderation-analysis.html#cb305-2" aria-hidden="true" tabindex="-1"></a><span class="co"># model 1 -> tells R that you want to estimate a simple moderation model</span></span>
<span id="cb305-3"><a href="tutorial-moderation-analysis.html#cb305-3" aria-hidden="true" tabindex="-1"></a><span class="co"># plot = 1 -> tells R that you want to have output for Y, X and W for different values of these respective variables to see how they behave</span></span></code></pre></div>
<p><img src="images/Tut15_processR_1.JPG" /></p>
<p>The output of <code>process</code> is pretty much self-explanatory when you’ve run the moderation model manually before.</p>
<ol style="list-style-type: decimal">
<li><p><strong>Section “Model Summary”:</strong> We can infer the regression equation: Y = 4.563 + 0.178 * X + 0.675 * W -0.706 * XW, where i<sub>[Y]</sub> = 4.563, <em>b<sub>1</sub></em> = 0.178, <em>b<sub>2</sub></em> = 0.675, and <em>b<sub>3</sub></em> = -0.706 and you can see which of these coefficients are significant (<em>p</em>-values).</p></li>
<li><p><strong>Section “Test(s) of highest order unconditional interaction(s)”:</strong> This section gives you information about whether the inclusion of the interaction effect XW does significantly increase your R<sup>2</sup> value. In this case, it does. Compared to a multiple linear regression model, including XW, i.e. assuming a moderation, does enhance R<sup>2</sup> by +0.0613 (<em>p</em> < .001). Obviously, the model that includes the interaction is the better fitting model!</p></li>
<li><p><strong>Section “Conditional effects of the focal predictor at values of the moderator(s)”:</strong> Here, you can see the mean values (conditioned on X = 0, which is nonsensical without standardization!) for liberals (W = 0) and conservatives (W = 1) and whether these mean differences are statistically significant (<em>p</em>-values).</p></li>
<li><p><strong>Section “Data for visualizing the conditional effect of the focal predictor”:</strong> Down below, you also get values that show you how X, W, and Y behave on different levels of the other variables, which can be really helpful for interpreting your coefficients (e.g., see how we used them in Table 1 and Table 2 in <a href="tutorial-moderation-analysis.html#fit-models-1">Fit models</a>). In addition, you can copy-paste these values, create a data frame with them and use them to plot diagrams.</p></li>
</ol>
</div>
</div>
<div id="take-aways-9" class="section level2" number="15.5">
<h2><span class="header-section-number">15.5</span> Take Aways</h2>
<ul>
<li><strong>explaning the when and the circumstances</strong>: a moderation model helps you to determine the situations, events, or groups of people for which the impact of X on Y changes</li>
<li><strong><code>process</code></strong>: calculate the moderation model either by using the classic <code>lm()</code> function (multiple linear regression with a product of X and W) or by using the <code>process</code> function of the <code>process</code> script by A. F. Hayes</li>
<li><strong>conditioning vs. controlling</strong>: do not confuse conditioning (W = 0) and controlling (W = constant)</li>
<li><strong>testing vs. probing</strong>: testing an interaction only shows <em>that</em> X affects Y at different levels of W, but probing an interaction tells exactly <em>in which way</em> the effect of X changes Y at different levels of W</li>
<li><strong>standardization & mean-centering</strong>: a great way to get meaningful regression coefficients for variables that are not mathematically bound between 0 and a finite value</li>
</ul>
</div>
<div id="additional-tutorials-8" class="section level2" number="15.6">
<h2><span class="header-section-number">15.6</span> Additional tutorials</h2>
<p>You still have questions? The following book can help you with that:</p>
<ul>
<li>Hayes, A. F. (2022). <em>Introduction to Mediation, Moderation
and Conditional Process Analysis</em> (p. 233-318) <a href="http://afhayes.com/introduction-to-mediation-moderation-and-conditional-process-analysis.html">Link</a></li>
</ul>
<p>Now let’s see what you’ve learned so far: <a href="exercise-6-test-your-knowledge.html#exercise-6-test-your-knowledge">Exercise 6: Test your knowledge</a>.</p>
</div>
</div>
<div class="footnotes">
<hr />
<ol start="7">
<li id="fn7"><p>You should be aware that unlike mediation, where statistical equations and conceptual diagrams match perfectly, the conceptual diagram of a moderation model is different from the corresponding statistical diagram.<a href="tutorial-moderation-analysis.html#fnref7" class="footnote-back">↩︎</a></p></li>
</ol>
</div>
</section>
</div>
</div>
</div>
<a href="exercise-5-test-your-knowledge.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="exercise-6-test-your-knowledge.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/LKobilke/CPA-Seminar/edit/main/index.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": ["CPA Seminar.pdf"],
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "subsection"
}
});
});
</script>
</body>
</html>