Apply and Practice Activity

APA-style papers with Quarto

Introduction

In this Apply and Practice, you are going to learn how to use Quarto to write an APA-style manuscript. We’ll use the results of our Blair replication as the case study. For this activity, I adapted the APA template developed by Joel Schneider and colleagues, which can be found here.

Step I

Set up your files.

Open us the new Posit Cloud project called blair_replication_APAmanuscript from my Posit Cloud account. You should see that the project is a TEMPORARY COPY (there will be a red warning at the top of your window). YOU MUST now save your own permanent copy. Click on Save a Permanent Copy at the top of the window.

Explore the file structure a bit. Notice that in the Files tab of RStudio (lower right quadrant) there is a folder called programs that includes an analysis notebook called fit_models.qmd. This file fits the five models from the paper and creates two tables and a figure. Open up the fit_models.qmd file, and render it. Scroll though the output to refamiliarize yourself with the steps. Notice the creation of two tables and a figure, we’ll input these into our manuscript later on. Notice that when you render the file, the tables and figure are created (see the Files section of RStudio). These are .png files that we will drop into our manuscript once created. Click on them to have a look. You might notice that I left off titles and captions as these will be created when we render the APA manuscript.

Study the results of Model 3 – this is the same model you fit in the Blair Replication – Fit Models Apply and Practice Activity. In this activity, you are going to write a formal description of the results of this model.

Next, in the Files tab, click back to project, then on the manuscript folder. Inside this folder is a .qmd file called blair_replication_manuscript.qmd. Open up that file. This is a template file that will produce a word document in APA style. This is a convenient way to produce an APA-style report or paper that is ready to submit for review (i.e., to an APA journal).

Modify the YAML meta data

The YAML meta data (i.e., the part at the very top, between the two sets of three dashes ---) looks a bit different than usual because this is a template that produces a very specific type of output. Please be very careful to follow the directions precisely in this section.

  1. First, find the section called author. Replace my name with your name.

  2. A couple lines down, replace my email address with your email address.

  3. Last replace the key words (i.e., keyword1, keyword2, keyword3) – with the following: criminal sentencing, racism, hidden bias.

Step 2

Write your own abstract.

Find the section labeled abstract:. Replace the original study abstract, with one written by you (in your own words). Follow these guidelines for writing your abstract.

Step 3

Add citations.

RStudio can help you build the citations for a paper. If you’re not already there, you will need to enter into a different screen of the RStudio session for this – it’s called the visual markdown editor, and the icon to get into it is circled in pink in the image below.

Click on the visual markdown editor icon. Then scroll to the part of your R notebook that is just above the section labeled Hypotheses, Aims and Objectives. There is a paragraph just above that section, the first sentence starts with: Structural racism is the discrimination…. The end of that sentence ends in three X’s (XXX). Highlight and delete those X’s – and leave your cursor at the spot of deletion. Now, click Insert then choose Citation – please see screen shot below.

This will open up a new window. On the side bar, click on PubMed. Then, in the search bar called Search Pubmed for Citations type: Structural racism and health inequities in the USA: evidence and interventions. This will bring up a list of matching articles. The first article in the list should be a Lancet article published in April 2017. Click on the plus icon just to the right of the article. Then, click insert (bottom of screen). This will take you back to your notebook, but now a citation identifier will appear where your cursor was located. When we render the report, this will turn into an in-text reference to the Lancet article, and the full citation will appear in the Reference section of your report.

Let’s add one more reference. In the same paragraph, there is a second sentence that starts with Blair, Judd and Chapleau, and is followed by XXX. This is in reference to the article we replicated. Delete those X’s, but leave your cursor in the spot of deletion. Click Insert then Citation again. As before, choose PubMed, but in the search bar type: Blair, Judd, Chapleau. The Psychological Science paper should come up first. Click on the plus icon, then click insert. A citation identifier for this article should now appear. In this example, we have already referred to the author names in the text, therefore, we don’t want the names to reappear in the in-text citation. To make this change, we just need to insert a minus sign into the citation marker so it looks like this: [-@Blair2004].

If you did everything correctly, your paragraph should look like this:

Step 4

Write up results.

Scan down a fit further until you get to the Results section. Study the method used to import the two tables and figures. Notice that the here() package is used to direct R to look in the programs folder for the tables and figures created by the fit_models.qmd program.

Notice the spot that says: REPLACE THIS TEXT WITH YOUR OWN FORMAL DESCRIPTION OF MODEL 3. Highlight and delete that text, and replace it with your own description of Model 3. It should be written in a style that is suitable for a journal article. Here is the description provided by Blair and colleagues that you can use for inspiration:

In a third model, we added the degree to which the inmates manifested Afrocentric features as a predictor of sentence length, controlling for the race of the inmates and the seriousness and number of offenses they had committed. This analysis showed that Afrocentric features were a significant predictor of sentence length over and above the effects of the other factors, t(205) = 2.29, p < .025. Table 1 provides the parameter estimates from this model (Model 3). The table shows that with Afrocentric features in the model, race significantly predicted sentence length, t(205) = 52.28, p <.025, but in the direction opposite to what one might expect — with White inmates serving longer sentences than Black inmates. Figure 1 presents a residual plot of all data points and the prediction functions from the second and third models. The vertical axis is the residual sentence length for each case, partialing out effects of all criminal-history variables. The horizontal axis represents the residual Afrocentric-features variable, again partialing out the effects of all criminal history variables. This plot thus illustrates the partial relationships between sentence length, on the one hand, and race and Afrocentric features, on the other, over and above any influence of criminal history. The predicted sentence lengths in the second model, which included race (but not Afrocentric features) as a predictor along with the criminal-history variables, are given by the two gray, horizontal lines, which show that the mean residual sentence lengths for White and Black offenders were not significantly different. The predicted functions from the third model, in which Afrocentric features and race were both predictors, along with the criminal history variables, are shown by the black lines. The positive (and significant) slopes for these lines indicate that within each race, more Afrocentric features were associated with longer sentences, given equivalent criminal histories. Additionally, as the vertical distance between these two lines indicates, there was a significant difference between the two races: Given equivalent criminal histories and equivalent Afrocentric facial features, White inmates had longer sentences than Black inmates.

Step 5

Render your report.

Now, click the Render button and your report will compile. The first time you do this can be a little slow. After a few minutes, your report should download to your computer. It will be a word document that interweaves text, analysis, and tables/figures. Scan through and verify that it recorded the two in-text citations properly and also built the Reference section. Also make sure that the text you added in the YAML header and the descripiton of Model 3 is present.

If for some reason the word document doesn’t automatically download, you can find it in the manuscript folder – it is called blair_replication_manuscript.docx.

Note that if you Render more than once, you may find that the document gets hung up and doesn’t download. If this happens, in the lower left quadrant of RStudio – click on Background Jobs. You will see an icon that says Running with a stop sign to the right. Click on the stop sign, then try to Render your report again.

Note that APA style dictates sentence case rather than title case for Journal article titles. Often, the citation information from PubMed and other databases records title case, and it may be necessary to change this manually. To do so find the file called bibliography.bib in the manuscript folder in your Files tab on Posit Cloud. Click on the bibliography.bib file. It will open and you can manually change the title for the Blair article from The Influence of Afrocentric Facial Features in Criminal Sentencing (title case) to The influence of Afrocentric facial features in criminal sentencing (sentence case). Click save, the next time you render your report, it will be fixed in your References section. You don’t need to do this for this exercise, but you can if you like.

Step 6

Wrap up and submit.

Submit your assignment to Canvas Navigate to the files tab (bottom right section of your screen) of your Posit Cloud RStudio session, and find the blair_replication_manuscript.docx file that you produced – it will be in the manuscript folder. Check the box to the left of the filename. Then, click the More button (a blue gear). Choose Export. It will download to your computer, then you can move it to your desktop. Upload the word document to Canvas for the Create an APA Paper Apply and Practice Activity Assignment.