You can find the solutions for this exercise as well as the following
ones in the exercises
folder in the workshop material. You
can also navigate the workshop material online (including
exercises and solutions).
You can copy code from the exercise and solution files by clicking on the small blue clipboard icon in the upper right corner of the boxes showing the code.
Some of the exercise require you to add text and R code. Feel free to
copy from the example paper in the folder
exercises/example_manuscript
. We do, however, encourage you
to use material from a project of your own, if possible. It will be a
lot more fun.
In this exercise, you will create a first papaja document. The example data we use here is taken from the example manuscript provided with the workshop material. However, we encourage you to use your own data for this and the following exercises.
File > New File > R Markdown… > From Template
In the YAML front matter, thenote
field and each author’s
role
field can simply be omitted.
# The following is taken from the example article.
title: "Distorted estimates of implicit and explicit learning in applications of the process-dissociation procedure to the SRT task"
shorttitle: "Distorted PD estimates in sequence learning"
author:
- name: "Christoph Stahl"
affiliation: ""
corresponding: yes
address: "Herbert-Lewin-Straße 2, 50931 Köln"
email: "christoph.stahl@uni-koeln.de"
- name: "Marius Barth"
affiliation: ""
- name: "Hilde Haider"
affiliation: ""
affiliation:
- id: ""
institution: "University of Cologne"
authornote: |
This work was funded by Deutsche Forschungsgemeinschaft grants STA-1269/1-1 and HA-5447/8-1.
abstract: |
We investigated potential biases affecting the validity of the process-dissociation (PD) procedure when applied to sequence learning.
Participants were or were not exposed to a serial reaction time task (SRTT) with two types of pseudo-random materials.
Afterwards, participants worked on a free or cued generation task under inclusion and exclusion instructions.
Results showed that pre-experimental response tendencies,
non-associative learning of location frequencies,
and the usage of cue locations introduced bias to PD estimates.
These biases may lead to erroneous conclusions regarding the presence of implicit and explicit knowledge.
Potential remedies for these problems are discussed.
keywords: "implicit learning, serial reaction time task, process-dissociation procedure, response bias"
wordcount: "8,167"
Make your manuscript “preprint-ready”:
"doc"
class option), anddraft
and linenumbers
options in the
YAML front matter.
draft: yes
linenumbers: no
classoption: "doc"
Now let’s report some results.
apa_print()
.
If you are working with the example manuscript, locate and open the
R-script analyses.R
and data folder data
accompanying the example manuscript in the folder
exercises/3_papaja_example_manuscript
.
If you are unsure, whether your analysis is supported,
methods(apa_print)
provides a list of supported
classes.
apa_print()
you will need to manually
pick numerical results from your results object. str()
may
help to find the numbers you are looking for and apa_num()
,
apa_p()
, apa_df()
, and
apa_confint()
will facilitate formatting.
The following is an excerpt of the example manuscript. We first load and filter the data before performing an analysis of variance.
```{r}
#| load-data
acquisition <- readRDS("data/acquisition-task.rds")
```
...
```{r}
#| acquisition-rt
# within the permuted-material group, high vs. low frequency locations can be distinguished
tmp.perm <- acquisition[
acquisition$error == 0 &
acquisition$trial > 1 &
acquisition$included_participant &
acquisition$material == "Permuted" &
!is.na(acquisition$frequency),
]
out.perm <- apa_print(
aov_ez(data = tmp.perm, dv = "SRI", within = c("block", "frequency"), id = "id")
)
```
A 2 (*frequency*: high vs. low) $\times$ 6 (*block number*) ANOVA revealed a main effect of *frequency*, `r out.perm$full_result$frequency`; high-frequency responses were faster than low-frequency responses.
The main effect of *block number* was also significant, `r out.perm$full_result$block`, but not the interaction, `r out.perm$full_result$block_frequency`.
You can use apa_factorial_plot()
(or one of the
short-hands apa_barplot()
, apa_beeplot()
, and
apa_lineplot()
) or try our ggplot2-theme
theme_apa()
, if applicable.
Handles used to cross-reference figures and tables are generated automatically from the chunk label:
fig:chunk-label
ortab:chunk-label
.(ref:reference-name)
.
The following are excerpts fromm the example manuscript.
This first section is an example of a figure. Note that the chunk from the previous exercise is continued here (same chunk label, accesses same data object).
(ref:acquisition-rt) Mean reaction times for permuted material, split by high-frequency (filled circles) vs. low-frequency locations (open circles). Error bars represent 95% within-subjects CIs.
```{r}
#| acquisition-rt
#| fig.cap: "(ref:acquisition-rt)"
apa_lineplot(
data = tmp.perm
, id = "id"
, dv = "SRI"
, factors = c("block", "frequency")
, dispersion = wsci
, ylab = ""
, args_lines = list(lty = c("solid", "solid"))
, args_points = list(pch = c(21, 21))
, args_legend = list(legend = c("High", "Low"), title = "Location frequency")
, ylim = c(475, 650)
, jit = .05
)
```
Figure\ \@ref(fig:acquisition-rt) shows the mean RTs for these two types of stimuli.
The following sections are an example of a table that is given in the appendix of the example manuscript. The first chunk puts together the to-be-presented summary statistics in a data.frame.
```{r}
#| proportion-correct-table-df
tmp <- generation[
generation$included_participant &
generation$repetition == 0 &
generation$post_repetition == 0,
]
# calculate proportion of regular transitions per participant
agg <- aggregate(
formula = correct_SOC ~ material + generation + order + PD_instruction + id
, data = tmp
, FUN = mean
, na.rm = TRUE
)
# calculate condition means and standard errors
means <- aggregate(
formula = cbind(M = correct_SOC) ~ material + generation + order + PD_instruction
, data = agg
, FUN = mean
)
SEs <- aggregate(
formula = cbind(`SE` = correct_SOC) ~ material + generation + order + PD_instruction
, data = agg
, FUN = se
)
# merge means and CI width
tab <- merge(means, SEs)
# bind Inclusion and Exclusion side-by-side
tab <- cbind(tab[tab$PD_instruction == "Inclusion", ], tab[tab$PD_instruction == "Exclusion", c("M", "SE")])
tab$PD_instruction <- NULL
tab$material <- gsub(tab$material, pattern = "-", replacement = " ", fixed = TRUE)
tab$generation <- as.character(tab$generation)
tab$generation[duplicated(paste0(tab$material, tab$generation))] <- ""
tab$material[duplicated(tab$material)] <- ""
```
This second chunk generates the table that is included in the appendix.
(ref:table-caption) Means ($M$) and standard errors ($\mathit{SE}$) of proportion of correctly generated second-order conditionals (SOCs).
```{r}
#| proportion-correct-table
apa_table(
tab
, row.names = FALSE
, col_spanners = list(Inclusion = c(4, 5), Exclusion = c(6, 7))
, midrules = c(4, 8, 12)
, caption = "(ref:table-caption)"
, placement = NULL
)
```
Table\ \@ref(tab:proportion-correct-table) shows the proportion of correctly generated second-order conditionals.
apa6_docx()
.
output: papaja::apa6_docx
To start an appendix, use the following special heading:
# (APPENDIX) Appendix {-}
\newpage
# References
::: {#refs custom-style="Bibliography"}
:::
\newpage
# (APPENDIX) Appendix {-}
This is the content of the appendix
Manually (i.e. without using apa_print()
) report the
results for the following one-sided t-test according to the APA
guidelines.
t.test(extra ~ 1, data = sleep, alternative = "greater")
Report
str()
may help to find the numbers you are looking for and
apa_num()
, apa_p()
, apa_df()
, and
apa_confint()
will facilitate formatting.
Calculate the t-test in a code chunk and pick the required information from the resulting object.
```{r}
#| t-test
ttest_res <- t.test(
extra ~ 1
, data = sleep
, alternative = "greater"
)
```
The mean difference of `r ttest_res$estimate` `r apa_confint(ttest_res$conf.int)` we observedd was significant, $t(`r apa_df(ttest_res$parameter)`) = `r ttest_res$statistic`$, $p `r apa_p(ttest_res$p.value, add_equals = TRUE)`$.
After you have tried yourself, feel free to have a look at our solutions.