forked from hcp4715/R4Psy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter_12.tex
349 lines (281 loc) · 16.4 KB
/
chapter_12.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
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
man]{apa6}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage{graphicx}
\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}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
% Make \paragraph and \subparagraph free-standing
\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
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{english}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
% Manuscript styling
\usepackage{upgreek}
\captionsetup{font=singlespacing,justification=justified}
% Table formatting
\usepackage{longtable}
\usepackage{lscape}
% \usepackage[counterclockwise]{rotating} % Landscape page setup for large tables
\usepackage{multirow} % Table styling
\usepackage{tabularx} % Control Column width
\usepackage[flushleft]{threeparttable} % Allows for three part tables with a specified notes section
\usepackage{threeparttablex} % Lets threeparttable work with longtable
% Create new environments so endfloat can handle them
% \newenvironment{ltable}
% {\begin{landscape}\centering\begin{threeparttable}}
% {\end{threeparttable}\end{landscape}}
\newenvironment{lltable}{\begin{landscape}\centering\begin{ThreePartTable}}{\end{ThreePartTable}\end{landscape}}
% Enables adjusting longtable caption width to table width
% Solution found at http://golatex.de/longtable-mit-caption-so-breit-wie-die-tabelle-t15767.html
\makeatletter
\newcommand\LastLTentrywidth{1em}
\newlength\longtablewidth
\setlength{\longtablewidth}{1in}
\newcommand{\getlongtablewidth}{\begingroup \ifcsname LT@\roman{LT@tables}\endcsname \global\longtablewidth=0pt \renewcommand{\LT@entry}[2]{\global\advance\longtablewidth by ##2\relax\gdef\LastLTentrywidth{##2}}\@nameuse{LT@\roman{LT@tables}} \fi \endgroup}
% \setlength{\parindent}{0.5in}
% \setlength{\parskip}{0pt plus 0pt minus 0pt}
% Overwrite redefinition of paragraph and subparagraph by the default LaTeX template
% See https://github.com/crsh/papaja/issues/292
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries\itshape\typesectitle}}
\renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-\z@\relax}%
{\normalfont\normalsize\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}}
\makeatother
% \usepackage{etoolbox}
\makeatletter
\patchcmd{\HyOrg@maketitle}
{\section{\normalfont\normalsize\abstractname}}
{\section*{\normalfont\normalsize\abstractname}}
{}{\typeout{Failed to patch abstract.}}
\patchcmd{\HyOrg@maketitle}
{\section{\protect\normalfont{\@title}}}
{\section*{\protect\normalfont{\@title}}}
{}{\typeout{Failed to patch title.}}
\makeatother
\usepackage{xpatch}
\makeatletter
\xapptocmd\appendix
{\xapptocmd\section
{\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi\\: #1}}
{}{\InnerPatchFailed}%
}
{}{\PatchFailed}
\keywords{Reproducibility, R, Teaching, Demonstration\newline\indent Word count: X}
\DeclareDelayedFloatFlavor{ThreePartTable}{table}
\DeclareDelayedFloatFlavor{lltable}{table}
\DeclareDelayedFloatFlavor*{longtable}{table}
\makeatletter
\renewcommand{\efloat@iwrite}[1]{\immediate\expandafter\protected@write\csname efloat@post#1\endcsname{}}
\makeatother
\usepackage{lineno}
\linenumbers
\usepackage{csquotes}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={Lecture 12: Preparing journal artical with papaja},
pdfauthor={Hu Chuan-Peng1 \& All Students1,2},
pdflang={en-EN},
pdfkeywords={Reproducibility, R, Teaching, Demonstration},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\title{Lecture 12: Preparing journal artical with \emph{papaja}}
\author{Hu Chuan-Peng\textsuperscript{1} \& All Students\textsuperscript{1,2}}
\date{}
\shorttitle{papaja}
\authornote{
Add complete departmental affiliations for each author here. Each new line herein must be indented, like this line.
Author Note: This is for demonstration only.
The authors made the following contributions. Hu Chuan-Peng: Conceptualization, Writing - Original Draft Preparation, Supervision; All Students: Writing - Original Draft Preparation, Writing - Review \& Editing.
Correspondence concerning this article should be addressed to Hu Chuan-Peng, \#122 Ninghai Rd, Gulou District, Nanjing. E-mail: \href{mailto:hcp4715@hotmail.com}{\nolinkurl{hcp4715@hotmail.com}}
}
\affiliation{\vspace{0.5cm}\textsuperscript{1} Nanjing Normal Unviersity\\\textsuperscript{2} Collaborators' Affiliations}
\abstract{%
Psychological science has encountered a serious replication crisis.
To make self-correction of the field, researchers actively reform the current practices and increase the opennes, transparency, and reproducibility of studies in the field. Using R language for data analyses is recommended by many. With increasingly emphases on computational reproduciblity, \emph{papaja} was developed to combine data analysis and manuscript preparation.
The current chapter aims to demonstrate how to use \emph{papaja}.
We will introduce the package and key elements of the it.
After the lecture, we expected students able to create an example APA manuscript using open data or examplary data we had provided at the beginning of the class.
This demo and practice will further enhance the student's experience in computational reproducibility.
By spreading the ideas of reproducbility and teaching papaja, this class will increase the computational reprodcubility.
}
\begin{document}
\maketitle
R language has been widely used in psychological science and social science in general. However, for most students with a background of psychology, learning R is not easy.
In the past decade, an increasingly number of psychological researchers had switched from SPSS to R. The most common suggestions from those who successfully adopted R is: learning by doing.
To fully integrate R in the life-cycle of psychological research, using R for preparing journal article is necessary.
Fortunately, we now have \emph{papaja} (Aust \& Barth, n.d.), which enable us to prepare journal article that formatted as required by APA.
Below we will demonstrate how to use \emph{papaja} to generate an APA formatted PDF. Note that we will use the data from perceptual matching task, which was from (Hu, Lan, Macrae, \& Sui, 2020). The data analysis for this dataset has been showed in previous classes.
Here we will try to reproduce what has been reported in Hu et al. (2020). Thus, we adopted the code from: \url{https://github.com/hcp4715/moralSelf_ddm}.
\hypertarget{methods}{%
\section{Methods}\label{methods}}
We report how we determined our sample size, all data exclusions (if any), all manipulations, and all measures in the study.
\hypertarget{participants}{%
\subsection{Participants}\label{participants}}
The sample size of the study was determined in a dynamic way (Schoenbrodt, Wagenmakers, Zehetleitner, \& Perugini, 2017). Specifically, we kept collecting data and analyzing the strength of evidence for the critical hypothesis, including the interaction between Self-Relevance × Valence on RT data and two Bayes factor paired \emph{t}-tests (good-self vs.~bad-self, good-self vs.~good-other). We stopped recruiting new participants when both paired \emph{t}-tests reached \(BF_{10} \le 0.1\) or \(BF_{10} \ge 10\). Participants who were already recruited at that moment continued to complete the experiment. See \url{https://osf.io/w6hrj/} for the change of Bayes factor during the data collection. In total, 44 college students (25 females, age: 20.91 \(\pm\) 2.58) were recruited. Two participants were excluded from data analysis because of procedural failures, leaving 42 participants (24 females, age: 20.71 \(\pm\) 2.38).
\hypertarget{material-and-procedure}{%
\subsection{Material and Procedure}\label{material-and-procedure}}
The data was collected using the same settings as described in the pilot study, with several differences:
\begin{itemize}
\tightlist
\item
In the shape-categorization task, the shapes were presented for 100 ms, instead of 200 ms in the pilot experiment, and feedback was Chinese character `Correct' or `Incorrect', instead of happy or sad symbolic faces.
\item
There were only two different types of blocks in the categorization task in the confirmatory study because the importance judgments resulted in unbalanced trials between participants.
\item
There were more trials per condition: 72 experimental trials for the matching task.
\item
The questionnaires were different from the pilot study.
\end{itemize}
\hypertarget{data-analysis}{%
\subsection{Data analysis}\label{data-analysis}}
We used R (Version 4.2.3; R Core Team, 2023) and the R-packages \emph{afex} (Version 1.3.0; Singmann, Bolker, Westfall, Aust, \& Ben-Shachar, 2023), \emph{dplyr} (Version 1.1.0; Wickham, François, Henry, Müller, \& Vaughan, 2023), \emph{emmeans} (Version 1.8.6; Lenth, 2023), \emph{ggplot2} (Version 3.4.2; Wickham, 2016), \emph{patchwork} (Version 1.1.2; Pedersen, 2022), and \emph{tidyr} (Version 1.3.0; Wickham, Vaughan, \& Girlich, 2023) for all our analyses. The results from Frequentist hypothesis testing (i.e., ANOVA and \emph{t}-tests) will be reported below.
\hypertarget{results}{%
\section{Results}\label{results}}
\begin{figure}
\centering
\includegraphics{chapter_12_files/figure-latex/plot1-1.pdf}
\caption{\label{fig:plot1}Interaction between identity and valence for (A) sensitivity and (B) reaction times.}
\end{figure}
\hypertarget{sensitivity-d}{%
\subsection{\texorpdfstring{Sensitivity (\emph{d'})}{Sensitivity (d')}}\label{sensitivity-d}}
A two-way repeated-measure ANOVA revealed a significant interaction between Identity and Valence. \emph{F}(1, 41) = 12.06, \emph{p} = 0.0012. We conducted follow-up simple main effect analyses. When the shapes were self-referential, \emph{d'} was significantly larger for moral condition (2.5 \(\pm\) 0.11) than for immoral condition (1.99 \(\pm\) 0.1), \emph{t}(41) = 4.29, \emph{p} \textless{} 0.001. However, this was no clear evidence that moral condition (2.11 \(\pm\) 0.116) and immoral condition (2.27 \(\pm\) 0.107) were not significantly different when the shapes are other-referential (see figure \ref{fig:plot1}).
\hypertarget{reaction-times}{%
\subsection{Reaction times}\label{reaction-times}}
{[}Please finish this part{]}
\hypertarget{discussion}{%
\section{Discussion}\label{discussion}}
In this demonstration, we examplified how to use \emph{papaja} to prepare an APA style manuscript. We highlighted the following details:
\begin{itemize}
\tightlist
\item
Installation and start a manuscript from the template.
\item
YAML front
\item
Mathematical notations
\item
Citation
\item
Insert results from code block
\item
Plot
\end{itemize}
\newpage
\hypertarget{references}{%
\section{References}\label{references}}
\hypertarget{refs}{}
\begin{CSLReferences}{1}{0}
\leavevmode\vadjust pre{\hypertarget{ref-R-papaja}{}}%
Aust, F., \& Barth, M. (n.d.). \emph{{papaja}: {Create} {APA} manuscripts with {R Markdown}}.
\leavevmode\vadjust pre{\hypertarget{ref-Hu_2020}{}}%
Hu, C.-P., Lan, Y., Macrae, C. N., \& Sui, J. (2020). Good {Me} {Bad} {Me}: {Does} {Valence} {Influence} {Self}-{Prioritization} {During} {Perceptual} {Decision}-{Making}? \emph{Collabra-Psychology}, \emph{6}(1), 20. \url{https://doi.org/10.1525/collabra.301}
\leavevmode\vadjust pre{\hypertarget{ref-R-emmeans}{}}%
Lenth, R. V. (2023). \emph{Emmeans: Estimated marginal means, aka least-squares means}. Retrieved from \url{https://CRAN.R-project.org/package=emmeans}
\leavevmode\vadjust pre{\hypertarget{ref-R-patchwork}{}}%
Pedersen, T. L. (2022). \emph{Patchwork: The composer of plots}. Retrieved from \url{https://CRAN.R-project.org/package=patchwork}
\leavevmode\vadjust pre{\hypertarget{ref-R-base}{}}%
R Core Team. (2023). \emph{R: A language and environment for statistical computing}. Vienna, Austria: R Foundation for Statistical Computing. Retrieved from \url{https://www.R-project.org/}
\leavevmode\vadjust pre{\hypertarget{ref-schoenbrodt_sequential_2017}{}}%
Schoenbrodt, F. D., Wagenmakers, E.-J., Zehetleitner, M., \& Perugini, M. (2017). Sequential hypothesis testing with {Bayes} factors: {Efficiently} testing mean differences. \emph{Psychological Methods}, \emph{22}(2), 322--339. \url{https://doi.org/10.1037/met0000061}
\leavevmode\vadjust pre{\hypertarget{ref-R-afex}{}}%
Singmann, H., Bolker, B., Westfall, J., Aust, F., \& Ben-Shachar, M. S. (2023). \emph{Afex: Analysis of factorial experiments}. Retrieved from \url{https://CRAN.R-project.org/package=afex}
\leavevmode\vadjust pre{\hypertarget{ref-R-ggplot2}{}}%
Wickham, H. (2016). \emph{ggplot2: Elegant graphics for data analysis}. Springer-Verlag New York. Retrieved from \url{https://ggplot2.tidyverse.org}
\leavevmode\vadjust pre{\hypertarget{ref-R-dplyr}{}}%
Wickham, H., François, R., Henry, L., Müller, K., \& Vaughan, D. (2023). \emph{Dplyr: A grammar of data manipulation}. Retrieved from \url{https://CRAN.R-project.org/package=dplyr}
\leavevmode\vadjust pre{\hypertarget{ref-R-tidyr}{}}%
Wickham, H., Vaughan, D., \& Girlich, M. (2023). \emph{Tidyr: Tidy messy data}. Retrieved from \url{https://CRAN.R-project.org/package=tidyr}
\end{CSLReferences}
\end{document}