-
Notifications
You must be signed in to change notification settings - Fork 1
/
SuppMaterials-MBCO-rev1.tex
1517 lines (1336 loc) · 65.2 KB
/
SuppMaterials-MBCO-rev1.tex
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
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[11pt,]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
pdftitle={Supplemental Materials},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}
%%% Change title format to be more compact
\usepackage{titling}
% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
\posttitle{
\begin{center}\large#1\end{center}
}
}
\setlength{\droptitle}{-2em}
\title{Supplemental Materials}
\pretitle{\vspace{\droptitle}\centering\huge}
\posttitle{\par}
\author{}
\preauthor{}\postauthor{}
\date{}
\predate{}\postdate{}
\begin{document}
\maketitle
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{knitr}\OperatorTok{::}\NormalTok{opts_chunk}\OperatorTok{$}\KeywordTok{set}\NormalTok{(}
\DataTypeTok{echo =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{message =} \OtherTok{FALSE}\NormalTok{,}
\DataTypeTok{strip.white =} \OtherTok{TRUE}
\NormalTok{)}
\KeywordTok{library}\NormalTok{(OpenMx)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## To take full advantage of multiple cores, use:
## mxOption(key='Number of Threads', value=parallel::detectCores()) #now
## Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(RMediation)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Loading required package: MASS
\end{verbatim}
\begin{verbatim}
## Loading required package: lavaan
\end{verbatim}
\begin{verbatim}
## This is lavaan 0.6-5
\end{verbatim}
\begin{verbatim}
## lavaan is BETA software! Please report any bugs.
\end{verbatim}
\begin{verbatim}
##
## Attaching package: 'lavaan'
\end{verbatim}
\begin{verbatim}
## The following object is masked from 'package:OpenMx':
##
## vech
\end{verbatim}
\begin{verbatim}
## Loading required package: e1071
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(tidyverse)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## -- Attaching packages -------------------------------------------- tidyverse 1.2.1 --
\end{verbatim}
\begin{verbatim}
## v ggplot2 3.2.1 v purrr 0.3.2
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.0 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
\end{verbatim}
\begin{verbatim}
## -- Conflicts ----------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::select() masks MASS::select()
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(umx)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## For an overview type '?umx'
\end{verbatim}
\begin{verbatim}
##
## Attaching package: 'umx'
\end{verbatim}
\begin{verbatim}
## The following object is masked from 'package:stats':
##
## loadings
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(car)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Loading required package: carData
\end{verbatim}
\begin{verbatim}
##
## Attaching package: 'car'
\end{verbatim}
\begin{verbatim}
## The following object is masked from 'package:dplyr':
##
## recode
\end{verbatim}
\begin{verbatim}
## The following object is masked from 'package:purrr':
##
## some
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(ggResidpanel)}
\KeywordTok{library}\NormalTok{(DiagrammeR)}
\KeywordTok{mxOption}\NormalTok{(}\OtherTok{NULL}\NormalTok{, }\StringTok{"Default optimizer"}\NormalTok{, }\StringTok{"NPSOL"}\NormalTok{)}
\KeywordTok{source}\NormalTok{(}\StringTok{"rsq.R"}\NormalTok{) }\CommentTok{# function to compute R2 for endogenous variables}
\end{Highlighting}
\end{Shaded}
In this section, we discuss in detail the steps required to analyze our
empirical example and reproduce the results. You can run the code below
to reproduce the results discussed in the empirical example section. The
R Markdown file that contains all the code as well as the data set for
the empirical example is available from a GitHub repository
{[}\url{https://quantpsych.github.io/mbco/}{]}. When using the data set
in this example, please cite the relevant study by MacKinnon, Valente,
and Wurpts (2018).
Here are the packages required to reproduce the results in this
document:
\begin{itemize}
\tightlist
\item
\texttt{OpenMx}: To exactly replicate our results, you need to install
the OpenMx version with the \texttt{"NPSOL"} optimizer. You may use
other optimizers available in \texttt{OpenMx}, but the results might
differ from the ones presented in this document.
\item
\texttt{RMediation}: This package produces confidence intervals for a
general function of indirect effects using various methods, including
the Monte Carlo method.
\item
\texttt{tidyverse}: A set of packages including the \texttt{dplyr}
package used to facilitate working with simple and complex data sets
in \texttt{R}.
\item
\texttt{car} and \texttt{ggResidpanel}: We used these packages to
check the model assumptions of the regression equations used in
mediation analysis.
\item
\texttt{umx} and \texttt{DiagrammeR}: We used these packages to
generate figues from the fitted \texttt{OpenMx} model.
\end{itemize}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{memory_df <-}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(}\StringTok{"memory_study.csv"}\NormalTok{)}
\NormalTok{memory_df <-}
\NormalTok{memory_df }\OperatorTok{%>%}\StringTok{ }\KeywordTok{rename}\NormalTok{(}\DataTypeTok{repetition =}\NormalTok{ R,}
\DataTypeTok{imagery =}\NormalTok{ M,}
\DataTypeTok{recall =}\NormalTok{ Y) }\OperatorTok{%>%}
\KeywordTok{mutate}\NormalTok{(}\DataTypeTok{x =} \KeywordTok{factor}\NormalTok{(X, }\DecValTok{0}\OperatorTok{:}\DecValTok{1}\NormalTok{, }\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"repetition"}\NormalTok{, }\StringTok{"imagery"}\NormalTok{)))}
\end{Highlighting}
\end{Shaded}
We first gets a glimpse of the data set and it structure using the
\texttt{glimpse} function from the \texttt{dplyr} package:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{glimpse}\NormalTok{(memory_df)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Observations: 369
## Variables: 7
## $ study <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ X <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ repetition <int> 1, 1, 1, 3, 7, 2, 1, 7, 3, 6, 6, 9, 3, 1, 4, 4, 3, ...
## $ recall <int> 9, 14, 17, 8, 10, 10, 8, 12, 12, 15, 7, 10, 8, 9, 1...
## $ imagery <int> 6, 8, 9, 7, 7, 6, 3, 6, 7, 7, 8, 8, 5, 5, 8, 9, 4, ...
## $ XM <int> 6, 8, 9, 7, 7, 6, 3, 6, 7, 7, 8, 8, 5, 5, 8, 9, 4, ...
## $ x <fct> imagery, imagery, imagery, imagery, imagery, imager...
\end{verbatim}
\hypertarget{research-question-1-does-the-instruction-to-create-mental-images-of-words-increase-use-of-mental-imagery-that-then-increases-the-number-of-words-recalled}{%
\subsection{Research Question 1: Does the Instruction to Create Mental
Images of Words Increase Use of Mental Imagery that, then, Increases the
Number of Words
Recalled?}\label{research-question-1-does-the-instruction-to-create-mental-images-of-words-increase-use-of-mental-imagery-that-then-increases-the-number-of-words-recalled}}
For this research question, we were interested in testing whether the
indirect effect of Instruction of Recall through Imagery is different
from zero. We used the single-mediator model (Figure 1) to answer this
question. We followed the three steps outlined in the manuscript to
implement the MBCO procedure. We also briefly introduced the key parts
of \texttt{OpenMx} (Boker et al. 2011; Neale et al. 2016) code to
implement the MBCO procedure in \texttt{R}.
\hypertarget{step-1}{%
\subsubsection{Step 1}\label{step-1}}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{endVar <-}\StringTok{ }\KeywordTok{c}\NormalTok{(}\StringTok{'imagery'}\NormalTok{, }\StringTok{'recall'}\NormalTok{) }\CommentTok{# name the endogenous variables}
\NormalTok{maniVar <-}
\StringTok{ }\KeywordTok{c}\NormalTok{(}\StringTok{'X'}\NormalTok{, }\StringTok{'imagery'}\NormalTok{, }\StringTok{'recall'}\NormalTok{) }\CommentTok{# name the observed variables}
\NormalTok{single_med_full <-}\StringTok{ }\KeywordTok{mxModel}\NormalTok{(}
\StringTok{"Single_med_full"}\NormalTok{,}
\DataTypeTok{type =} \StringTok{"RAM"}\NormalTok{,}
\DataTypeTok{manifestVars =}\NormalTok{ maniVar,}
\CommentTok{#specify the manifest (observed) variables}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{"X"}\NormalTok{,}
\DataTypeTok{to =}\NormalTok{ endVar,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"b1"}\NormalTok{, }\StringTok{"b3"}\NormalTok{) }\CommentTok{# specify the path from X to the M (imagery) and Y (recall)}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{'imagery'}\NormalTok{,}
\DataTypeTok{to =} \StringTok{'recall'}\NormalTok{,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \StringTok{"b2"} \CommentTok{# specify the path from M to Y}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =}\NormalTok{ maniVar,}
\DataTypeTok{arrows =} \DecValTok{2}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.8}\NormalTok{,}
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"s2x"}\NormalTok{, }\StringTok{"s2em"}\NormalTok{, }\StringTok{"s2ey"}\NormalTok{) }\CommentTok{# specify (residual) variances for the observed variables}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{"one"}\NormalTok{,}
\DataTypeTok{to =}\NormalTok{ endVar,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.1}\NormalTok{, }
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"int1"}\NormalTok{,}\StringTok{"int2"}\NormalTok{) }\CommentTok{# specify the intercepts for the endogenous variables}
\NormalTok{ ),}
\KeywordTok{mxAlgebra}\NormalTok{(b1 }\OperatorTok{*}\StringTok{ }\NormalTok{b2, }\DataTypeTok{name =} \StringTok{"ind"}\NormalTok{), }\CommentTok{# define the indirect effect and call it ind}
\KeywordTok{mxData}\NormalTok{(}\DataTypeTok{observed =}\NormalTok{ memory_df, }\DataTypeTok{type =} \StringTok{"raw"}\NormalTok{) }\CommentTok{# specify the data set for analysis}
\NormalTok{)}
\NormalTok{fit_single_med_full <-}\StringTok{ }\KeywordTok{mxRun}\NormalTok{(single_med_full) }\CommentTok{# run the single mediator null model}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Warning: In model 'Single_med_full' Optimizer returned a non-zero status
## code 1. The final iterate satisfies the optimality conditions to the
## accuracy requested, but the sequence of iterates has not yet converged.
## Optimizer was terminated because no further improvement could be made in
## the merit function (Mx status GREEN).
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{stat_single_med_full <-}\StringTok{ }\KeywordTok{summary}\NormalTok{(fit_single_med_full) }\CommentTok{# save the results}
\NormalTok{stat_single_med_full }\CommentTok{# print results of the full model}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Summary of Single_med_full
##
## The final iterate satisfies the optimality conditions to the accuracy requested, but the sequence of iterates has not yet converged. Optimizer was terminated because no further improvement could be made in the merit function (Mx status GREEN).
##
## free parameters:
## name matrix row col Estimate Std.Error A
## 1 b1 A 2 1 3.64018505 0.24259998
## 2 b3 A 3 1 0.04528978 0.38482959
## 3 b2 A 3 2 0.58267974 0.06507646
## 4 s2x S 1 1 0.50948343 0.03750860
## 5 s2em S 2 2 5.42736402 0.39956681
## 6 s2ey S 3 3 8.48164638 0.62442551
## 7 int1 M 1 2 3.80662759 0.17316342
## 8 int2 M 1 3 8.74326503 0.32898072
##
## Model Statistics:
## | Parameters | Degrees of Freedom | Fit (-2lnL units)
## Model: 8 1099 4305.727
## Saturated: 9 1098 NA
## Independence: 6 1101 NA
## Number of observations/statistics: 369/1107
##
## Information Criteria:
## | df Penalty | Parameters Penalty | Sample-Size Adjusted
## AIC: 2107.727 4321.727 4322.127
## BIC: -2190.239 4353.013 4327.632
## To get additional fit indices, see help(mxRefModels)
## timestamp: 2019-09-30 21:15:29
## Wall clock time: 0.06009293 secs
## optimizer: NPSOL
## OpenMx version number: 2.14.11.15
## Need help? See help(mxSummary)
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(fit_single_med_full, }\DataTypeTok{means=}\OtherTok{FALSE}\NormalTok{, }\DataTypeTok{resid =} \StringTok{"line"}\NormalTok{, }\DataTypeTok{digits =} \DecValTok{3}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] "?plot.MxModel options: std, means, digits, strip_zero, file, splines=T/F, min=, max =, same = , fixed, resid= 'circle|line|none'"
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{DiagrammeR}\OperatorTok{::}\KeywordTok{grViz}\NormalTok{(}\StringTok{"Single_med_full.gv"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\hypertarget{htmlwidget-7404136e1bfc36c2f9fa}{}
something
Figure~@ref(fig:single-med-plot)
In the first two lines of the script above, before specifying the model
parts with \texttt{mxModel}, we can simplify the process by grouping the
names of variables as a vector that will be used in model specification.
For example, we specified a vector of the names of observed variables
and saved them as \texttt{maniVar.} Then, we specified a vector of the
names of endogenous variables and saved them as \texttt{endVar}. Next,
we specified the full single-mediator model.
The main command to specify an SEM is \texttt{mxModel.} The arguments
provided to the \texttt{mxModel} function specified all the elements of
the mediation model. For the single-mediator example, we specified the
manifest (observed) and latent variables, the paths (regression
coefficients), the indirect effect to be tested (or any function of
model parameters), the constraint distinguishing the full and null
models, and the variances and covariances among the variables.
The first argument to \texttt{mxModel} is \texttt{single\_med\_full},
which is a name we chose for the single-mediator model. The next
argument, type=``RAM'', specifies that \texttt{OpenMx} uses the
reticular action model (RAM; McArdle and McDonald (1984)), a symbolic
algebraic notation to specify an SEM. In the argument
\texttt{manifestVars}, we introduced the vector of the names of the
observed (manifest) variables. The variable names must match the names
in the data set \texttt{memory\_df}, as shown earlier in the output from
the \texttt{glimpse} function.
Next, we specify the paths between the variables using
\texttt{mxPath()}. The function \texttt{mxPath()} corresponds to the
graphical representation of paths in an SEM. For example, we use
\texttt{mxPath()}to indicate a path (coefficient) corresponding to an
arrow between the two variables specified in the arguments \texttt{from}
(predictors) and \texttt{to} (response variables) in a single-mediator
model. The argument \texttt{arrows=1} indicates a unidirectional arrow
that starts from the variable in the argument \texttt{from} and ends at
the variable specified in the argument \texttt{to}; that is, a
unidirectional arrow indicates a path coefficient between the two
variables. The argument \texttt{arrows=2} indicates a bidirectional
arrow representing a covariance between the two variables. The argument
\texttt{free\ =\ TRUE} indicates that the parameter is freely estimated;
otherwise, \texttt{free\ =\ FALSE} indicates that the parameter is fixed
at the values set by the argument \texttt{values}. If the parameter is
freely estimated, the argument \texttt{values} would provide starting
values. The argument \texttt{labels} provides labels for the
coefficients. Because we specified more than one coefficient in the
arguments \texttt{to}and \texttt{from}, we would provide more than one
label corresponding to the stated order of the coefficients. For our
example, \texttt{b1} is the coefficient for \(X \rightarrow\) Imagery
and \texttt{b3} is the coefficient for \(X \rightarrow\) Recall.
We use \texttt{mxAlgebra()} to define the indirect effect or, in
general, a function of model parameters. In general, a function may
include mathematical operations \texttt{+,-,*,/} (e.g.,
\texttt{b1*b2/(b1*b2+b3)}), exponential (e.g., \texttt{exp()}), and
logarithms (e.g., \texttt{log()}). The first argument to
\texttt{mxAlgebra()} is the product of two coefficients,
\texttt{b1\ *\ b2}, in which \texttt{b1} and \texttt{b2} had been
defined in \texttt{mxPtah()}. The argument \texttt{name\ =\ "ind"} is
used to name the indirect effect.
Next, we specified the data set for the model. The \texttt{mxData}
identified the data set to be analyzed. The argument
\texttt{observed=memory\_df} specified the name of the data set in
\texttt{R}. The second argument, \texttt{type="raw"}, indicated that the
data set was in the raw format, which meant that the data set included
observations on the participants as opposed to being a summary statistic
such as a covariance matrix.
Finally, we run the model using \texttt{mxRun()}, where the first
argument is the name of the \texttt{mxModel} that is then saved as
\texttt{fit\_single\_med\_full}. After getting no warning about whether
the model estimation and convergence criterion are satisfied, we use the
function \texttt{summary()} to save or print the summary of the results.
We save the summary of the results as \texttt{stat\_single\_med\_full}
and then print the summary. Below, we present the relevant part of the
summary results.
\begin{verbatim}
Model Statistics:
| Parameters | Degrees of Freedom | Fit (-2lnL units)
Model: 8 1099 4305.727
Saturated: 9 1098 NA
Independence: 6 1101 NA
Information Criteria:
| df Penalty | Parameters Penalty | Sample-Size Adjusted
AIC: 2107.727 4321.727 4322.127
BIC: -2190.239 4353.013 4327.632
\end{verbatim}
Below the title \texttt{Model\ Statistics}, the row that starts with
\texttt{Model}, gives the pertinent information for the full model. The
output shows that the full single-mediator model has eight free
parameters, with \(df_{Full}=1099\) and \(\mathcal{D}_{Null}=\)
4305.726. Under \texttt{Information\ Criteria} and
\texttt{Parameters\ Penalty}, we get the estimates of the information
fit indices. For the full model, the information fit indices are
AIC\textsubscript{Full}= 4321.727 and BIC\textsubscript{Full}= 4353.013.
Alternatively, we can compute deviance, the AIC, and the BIC using the
following functions:
\begin{Shaded}
\begin{Highlighting}[]
\DecValTok{-2}\OperatorTok{*}\KeywordTok{as.vector}\NormalTok{(}\KeywordTok{logLik}\NormalTok{(fit_single_med_full))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 4305.727
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{AIC}\NormalTok{(fit_single_med_full)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 4321.727
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{BIC}\NormalTok{(fit_single_med_full)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 4353.013
\end{verbatim}
\hypertarget{checking-model-assumptions}{%
\paragraph{Checking Model
Assumptions}\label{checking-model-assumptions}}
Before proceeding further, after fitting a mediation model, it is
important to check the statistical assumptions about normality of the
residuals and the presence of outliers (Cohen et al. 2003) . Because
\texttt{OpenMx} does not offer checking residuals facilities, we fit the
single-mediator model using two regression equations with the
\texttt{lm()} function.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{lm_image <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(imagery }\OperatorTok{~}\StringTok{ }\NormalTok{x, }\DataTypeTok{data =}\NormalTok{ memory_df)}
\NormalTok{lm_recall <-}\StringTok{ }\KeywordTok{lm}\NormalTok{(recall }\OperatorTok{~}\StringTok{ }\NormalTok{x }\OperatorTok{+}\StringTok{ }\NormalTok{repetition, }\DataTypeTok{data =}\NormalTok{ memory_df)}
\end{Highlighting}
\end{Shaded}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{ggResidpanel}\OperatorTok{::}\KeywordTok{resid_panel}\NormalTok{(lm_image)}
\end{Highlighting}
\end{Shaded}
\includegraphics{SuppMaterials-MBCO-rev1_files/figure-latex/rq1-diagplots-1.pdf}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{ggResidpanel}\OperatorTok{::}\KeywordTok{resid_panel}\NormalTok{(lm_recall)}
\end{Highlighting}
\end{Shaded}
\includegraphics{SuppMaterials-MBCO-rev1_files/figure-latex/rq1-diagplots-2.pdf}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{outlierTest}\NormalTok{(lm_image)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## No Studentized residuals with Bonferroni p < 0.05
## Largest |rstudent|:
## rstudent unadjusted p-value Bonferroni p
## 285 -2.792633 0.0055027 NA
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{outlierTest}\NormalTok{(lm_recall)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## No Studentized residuals with Bonferroni p < 0.05
## Largest |rstudent|:
## rstudent unadjusted p-value Bonferroni p
## 248 2.848921 0.0046354 NA
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{influenceIndexPlot}\NormalTok{(lm_image)}
\end{Highlighting}
\end{Shaded}
\includegraphics{SuppMaterials-MBCO-rev1_files/figure-latex/unnamed-chunk-3-1.pdf}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{influenceIndexPlot}\NormalTok{(lm_recall)}
\end{Highlighting}
\end{Shaded}
\includegraphics{SuppMaterials-MBCO-rev1_files/figure-latex/unnamed-chunk-3-2.pdf}
We checked for normality of the residuals using QQ plots which indicated
that the normality assumption for the residuals was reasonable. We also
checked for the outliers using the influence plots and \(t\)-tests (Fox
2016). The results showed there were no outliers.
\hypertarget{step-2}{%
\subsubsection{Step 2}\label{step-2}}
We ran the null (restricted) model, which is the single-mediator model
in which the indirect effect of Instruction on Recall through Imagery is
constrained to zero, \(\beta_1 \beta_2 =0\). The code for the null model
shown below.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{single_med_null <-}
\StringTok{ }\KeywordTok{mxModel}\NormalTok{(}\DataTypeTok{model =}\NormalTok{ single_med_full,}
\DataTypeTok{name =} \StringTok{"single_med_null"}\NormalTok{,}
\KeywordTok{mxConstraint}\NormalTok{(ind }\OperatorTok{==}\StringTok{ }\DecValTok{0}\NormalTok{, }\DataTypeTok{name =} \StringTok{"b1b2_equals_0"}\NormalTok{))}
\NormalTok{fit_single_med_null <-}\StringTok{ }\KeywordTok{mxRun}\NormalTok{(single_med_null)}
\NormalTok{stat_single_med_null <-}\StringTok{ }\KeywordTok{summary}\NormalTok{(fit_single_med_null)}
\NormalTok{stat_single_med_null}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Summary of single_med_null
##
## free parameters:
## name matrix row col Estimate Std.Error A
## 1 b1 A 2 1 9.522179e-23 1.038197e-23 !
## 2 b3 A 3 1 4.529096e-02 3.656067e-01
## 3 b2 A 3 2 5.826781e-01 6.352900e-02
## 4 s2x S 1 1 5.094816e-01 3.749345e-02 !
## 5 s2em S 2 2 8.738891e+00 6.423770e-01
## 6 s2ey S 3 3 8.481638e+00 6.234669e-01
## 7 int1 M 1 2 5.661250e+00 1.538597e-01
## 8 int2 M 1 3 8.743274e+00 3.282580e-01
##
## Model Statistics:
## | Parameters | Degrees of Freedom | Fit (-2lnL units)
## Model: 8 1100 4481.493
## Saturated: 9 1099 NA
## Independence: 6 1102 NA
## Number of observations/statistics: 369/1108
##
## Constraint 'b1b2_equals_0' contributes 1 observed statistic.
##
## Information Criteria:
## | df Penalty | Parameters Penalty | Sample-Size Adjusted
## AIC: 2281.493 4497.493 4497.893
## BIC: -2020.384 4528.779 4503.398
## To get additional fit indices, see help(mxRefModels)
## timestamp: 2019-09-30 21:15:32
## Wall clock time: 0.04202414 secs
## optimizer: NPSOL
## OpenMx version number: 2.14.11.15
## Need help? See help(mxSummary)
\end{verbatim}
Note that instead of specifying all the parts of the null mediation
model using \texttt{MxModel} in the above code, we modified the full
model \texttt{single\_med\_full}, as specified in the argument model.
Next, we specified the non-linear constraint for the indirect effect
through \texttt{mxConstraint}. The first argument \texttt{ind\ ==\ 0}
constrains the indirect effect defined in the \texttt{mxAlgebra}
statement to zero. The argument \texttt{name} assigns a name to the
constraint. Finally, we saved the null model to
\texttt{single\_med\_null}. Next, we ran the null model and saved the
results to \texttt{fit\_single\_med\_null}. Relevant parts of the
summary of the model results are shown below:
\begin{verbatim}
Model Statistics:
| Parameters | Degrees of Freedom | Fit (-2lnL units)
Model: 8 1100 4481.493
Saturated: 9 1099 NA
Independence: 6 1102 NA
Number of observations/statistics: 369/1108
Information Criteria:
| df Penalty | Parameters Penalty | Sample-Size Adjusted
AIC: 2281.493 4497.493 4497.893
BIC: -2020.384 4528.779 4503.398
\end{verbatim}
For the null model, \(df_\text{Null}= 1100\) and
\(\mathcal{D}_\text{Null}=\) 4481.492, and the information fit indices
were AIC\textsubscript{Null} = 4497.493 and BIC\textsubscript{Null} =
4528.779.
\hypertarget{step-3}{%
\subsubsection{Step 3}\label{step-3}}
We compared the full and null model both in terms of the
LRT\textsubscript{MBCO} and the information fit indices to evaluate
\(H_0: \beta_1 \beta_2 =0\). The LRT\textsubscript{MBCO} equals the
difference between the deviance of the two models. We use the function
\texttt{code\ mxCompare} to compute the LRT\textsubscript{MBCO} as
follows:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{lrt_rq1 <-}\StringTok{ }\KeywordTok{mxCompare}\NormalTok{(fit_single_med_full, fit_single_med_null) }
\NormalTok{lrt_rq1}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## base comparison ep minus2LL df AIC diffLL
## 1 Single_med_full <NA> 8 4305.727 1099 2107.727 NA
## 2 Single_med_full single_med_null 8 4481.493 1100 2281.493 175.7657
## diffdf p
## 1 NA NA
## 2 1 4.073738e-40
\end{verbatim}
The first row of the above output shows the results for the full model,
which is the single-mediator model in Figure 1. The columns \texttt{ep},
\texttt{minus2LL}, \texttt{df}, and \texttt{AIC} show the number of
estimated parameters, deviance, degrees of freedom, and AIC,
respectively. The columns \texttt{diffLL}, \texttt{diffdf}, and
\texttt{p} represent the difference in deviance (not the
log-likelihoods), the difference in degrees of freedom, and
\emph{p}-value for two models being compared. The second row shows the
results for the null model under the columns \texttt{ep},
\texttt{minus2LL}, \texttt{df}, and \texttt{AIC.} The results of
comparing the null and full model are shown under the columns
\texttt{diffLL}, \texttt{diffdf}, and \texttt{p}. The value for the test
statistic LRT\textsubscript{MBCO} = 175.766 is located under the column
\texttt{diffLL}. The degrees of freedom are \emph{df}\textsubscript{LRT}
= 1 and \emph{p}-value = \ensuremath{4.0737384\times 10^{-40}}; these
amounts are located under the columns \texttt{diffdf} and \texttt{p},
respectively.
Next, we used the following commands to compute the Monte Carlo CI for
the indirect effect. First, we used the functions \texttt{coef} and
\texttt{vcov} to extract the path coefficients and covariance matrix of
the coefficients, respectively, from the full single-mediator model.
Next, we used the \texttt{ci} function in the \texttt{RMediation}
package (Tofighi and MacKinnon 2011, 2016) to compute the 95\% Monte
Carlo CI. The first argument \texttt{mu} to this function is a vector of
the coefficient estimates, and the second argument \texttt{Sigma} is a
covariance matrix of the coefficient estimates. The argument quant
accepts a formula for the indirect effect that starts with the symbol
\texttt{“\textasciitilde{}”}.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{Mu <-}\StringTok{ }\KeywordTok{coef}\NormalTok{(fit_single_med_full) }\CommentTok{# path coefficient estimates from the full single mediator model}
\NormalTok{Sigma <-}
\StringTok{ }\KeywordTok{vcov}\NormalTok{(fit_single_med_full) }\CommentTok{#covariance matrix of the parameter estimates from the full single mediator model}
\NormalTok{mc_ci1 <-}\StringTok{ }\NormalTok{RMediation}\OperatorTok{::}\KeywordTok{ci}\NormalTok{(}\DataTypeTok{mu =}\NormalTok{ Mu,}
\DataTypeTok{Sigma =}\NormalTok{ Sigma,}
\DataTypeTok{quant =} \OperatorTok{~}\StringTok{ }\NormalTok{b1 }\OperatorTok{*}\StringTok{ }\NormalTok{b2)}
\NormalTok{mc_ci <-}\StringTok{ }\KeywordTok{t}\NormalTok{(}\KeywordTok{round}\NormalTok{(}\KeywordTok{unlist}\NormalTok{(mc_ci1[}\DecValTok{1}\OperatorTok{:}\DecValTok{3}\NormalTok{]),}\DecValTok{3}\NormalTok{ ))}
\KeywordTok{cat}\NormalTok{(}\StringTok{" Monte Carlo CI for b1*b2:}\CharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Monte Carlo CI for b1*b2:
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{knitr}\OperatorTok{::}\KeywordTok{kable}\NormalTok{(mc_ci)}
\end{Highlighting}
\end{Shaded}
\begin{longtable}[]{@{}rrrr@{}}
\toprule
2.5 \% & 97.5 \% & Estimate & SE\tabularnewline
\midrule
\endhead
1.599 & 2.682 & 2.121 & 0.276\tabularnewline
\bottomrule
\end{longtable}
We also recommend computing the difference in \(R^2\)s between the full
and null model to examine change in the effect sizes that occurs as a
result of the indirect effect through Imagery. As shown below, for
Recall, \(R^2\) remained unchanged to four decimal places while for
Imagery, \(\Delta R^2 = .3779\).
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{cat}\NormalTok{(}\StringTok{"R-Square for the full model}\CharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## R-Square for the full model
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{rsq}\NormalTok{(}\DataTypeTok{model =}\NormalTok{ fit_single_med_full, }\DataTypeTok{name =} \KeywordTok{c}\NormalTok{(}\StringTok{"imagery"}\NormalTok{,}\StringTok{"recall"}\NormalTok{) )}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## imagery recall
## 0.3806254 0.2642803
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{cat}\NormalTok{(}\StringTok{"R-Square for the null model}\CharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## R-Square for the null model
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{rsq}\NormalTok{(}\DataTypeTok{model =}\NormalTok{ fit_single_med_null, }\DataTypeTok{name =} \KeywordTok{c}\NormalTok{(}\StringTok{"imagery"}\NormalTok{,}\StringTok{"recall"}\NormalTok{) )}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## imagery recall
## 0.002711604 0.264281019
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{cat}\NormalTok{(}\StringTok{"Delta R-Square }\CharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## Delta R-Square
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{round}\NormalTok{(}\KeywordTok{rsq}\NormalTok{(}\DataTypeTok{model =}\NormalTok{ fit_single_med_full, }\DataTypeTok{name =} \KeywordTok{c}\NormalTok{(}\StringTok{"imagery"}\NormalTok{,}\StringTok{"recall"}\NormalTok{) )}\OperatorTok{-}\KeywordTok{rsq}\NormalTok{(}\DataTypeTok{model =}\NormalTok{ fit_single_med_null, }\DataTypeTok{name =} \KeywordTok{c}\NormalTok{(}\StringTok{"imagery"}\NormalTok{,}\StringTok{"recall"}\NormalTok{) ), }\DecValTok{4}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## imagery recall
## 0.3779 0.0000
\end{verbatim}
The first argument model to \texttt{rsq} specifies an \texttt{OpenMx}
model and the second argument name specifies names of endogenous
variables (i.e., variables in which a single headed arrow enters; namely
those that are a function of another variable).
\hypertarget{research-question-2-does-the-instruction-to-repeat-words-increase-use-of-repetition-to-memorize-the-words-that-in-turn-increases-the-number-of-words-recalled-over-and-above-using-mental-imagery}{%
\subsection{Research Question 2: Does the Instruction to Repeat Words
Increase Use of Repetition to Memorize the Words that, in turn,
Increases the Number of Words Recalled over and above Using Mental
Imagery?}\label{research-question-2-does-the-instruction-to-repeat-words-increase-use-of-repetition-to-memorize-the-words-that-in-turn-increases-the-number-of-words-recalled-over-and-above-using-mental-imagery}}
\hypertarget{step-1-1}{%
\subsubsection{Step 1}\label{step-1-1}}
We estimated the model with two parallel mediators in Figure 2, which is
the full model for this research question. For this model, the two
specific indirect effects associated with Imagery and Repetition were
freely estimated. Below is the \texttt{OpenMx} code for the full
parallel two mediator model:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{endVar <-}\StringTok{ }\KeywordTok{c}\NormalTok{(}\StringTok{'imagery'}\NormalTok{, }\StringTok{'repetition'}\NormalTok{, }\StringTok{'recall'}\NormalTok{)}
\NormalTok{maniVar <-}\StringTok{ }\KeywordTok{c}\NormalTok{(}\StringTok{'X'}\NormalTok{, }\StringTok{'imagery'}\NormalTok{, }\StringTok{'repetition'}\NormalTok{, }\StringTok{'recall'}\NormalTok{)}
\NormalTok{two_med_full <-}\StringTok{ }\KeywordTok{mxModel}\NormalTok{(}
\StringTok{"two_med_full"}\NormalTok{,}
\DataTypeTok{type =} \StringTok{"RAM"}\NormalTok{,}
\DataTypeTok{manifestVars =}\NormalTok{ maniVar,}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{"X"}\NormalTok{,}
\DataTypeTok{to =}\NormalTok{ endVar,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"b1"}\NormalTok{, }\StringTok{"b3"}\NormalTok{, }\StringTok{"b5"}\NormalTok{)}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{'repetition'}\NormalTok{,}
\DataTypeTok{to =} \StringTok{'recall'}\NormalTok{,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \StringTok{'b4'}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{'imagery'}\NormalTok{,}
\DataTypeTok{to =} \StringTok{'recall'}\NormalTok{,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \StringTok{"b2"}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =}\NormalTok{ maniVar,}
\DataTypeTok{arrows =} \DecValTok{2}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.8}\NormalTok{,}
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"s2x"}\NormalTok{, }\StringTok{"s2em1"}\NormalTok{, }\StringTok{"s2em2"}\NormalTok{, }\StringTok{"s2ey"}\NormalTok{)}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{'imagery'}\NormalTok{,}
\DataTypeTok{to =} \StringTok{'repetition'}\NormalTok{,}
\DataTypeTok{arrows =} \DecValTok{2}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.2}\NormalTok{,}
\DataTypeTok{labels =} \StringTok{"cov_m1m2"}
\NormalTok{ ),}
\KeywordTok{mxPath}\NormalTok{(}
\DataTypeTok{from =} \StringTok{"one"}\NormalTok{,}
\DataTypeTok{to =}\NormalTok{ endVar,}
\DataTypeTok{arrows =} \DecValTok{1}\NormalTok{,}
\DataTypeTok{free =} \OtherTok{TRUE}\NormalTok{,}
\DataTypeTok{values =} \FloatTok{.1}\NormalTok{,}
\DataTypeTok{labels =} \KeywordTok{c}\NormalTok{(}\StringTok{"int1"}\NormalTok{, }\StringTok{"int2"}\NormalTok{, }\StringTok{"int3"}\NormalTok{)}
\NormalTok{ ),}
\KeywordTok{mxAlgebra}\NormalTok{(b1 }\OperatorTok{*}\StringTok{ }\NormalTok{b2, }\DataTypeTok{name =} \StringTok{"ind1"}\NormalTok{),}
\KeywordTok{mxAlgebra}\NormalTok{(b3 }\OperatorTok{*}\StringTok{ }\NormalTok{b4, }\DataTypeTok{name =} \StringTok{"ind2"}\NormalTok{),}
\KeywordTok{mxData}\NormalTok{(}\DataTypeTok{observed =}\NormalTok{ memory_df, }\DataTypeTok{type =} \StringTok{"raw"}\NormalTok{)}