• PIE Lab Manual
    • 0.1 Updating the manual
  • 1 Welcome
  • 2 What we do and why we do it
    • 2.1 Philosophy of scientific principles
    • 2.2 Chronological and academic history
    • 2.3 Things we’ve been reading
      • 2.3.1 Papers by the PIE lab
      • 2.3.2 Papers etc. by others
  • 3 Roles and expectations
    • 3.1 People
      • 3.1.1 Principal Investigators
      • 3.1.2 Graduate students
      • 3.1.3 Undergraduate Research Assistants
      • 3.1.4 Alumni
    • 3.2 Mentorship philosophy
      • 3.2.1 Primary mentors
      • 3.2.2 Recommendation Letters
      • 3.2.3 Individual Development Plans (IDPs)
    • 3.3 Expectations
      • 3.3.1 Principal Investigators
      • 3.3.2 Graduate Students
      • 3.3.3 Undergraduate students
  • 4 Communication
    • 4.1 Slack
    • 4.2 Email
    • 4.3 Response time
    • 4.4 Phone
  • 5 Logistics
    • 5.1 Lab contact information
    • 5.2 Psych IT
    • 5.3 Getting locked out
    • 5.4 Being in the lab
    • 5.5 Holidays and vacations
  • 6 Day-to-day Information
    • 6.1 Lab use
    • 6.2 Pet Policy
    • 6.3 Sickness policy
    • 6.4 Respect space
    • 6.5 Be professional
  • 7 Code of Conduct
    • 7.1 Scientific integrity
    • 7.2 Code of Conduct
      • 7.2.1 Sexual Harassment and Assault
    • 7.3 Managing Conflict
  • 8 SAPA project website
    • 8.1 Introduction
      • 8.1.1 Infrastructure
      • 8.1.2 How to connect to database
      • 8.1.3 Connecting from R
  • 9 Recurring events
    • 9.1 Lab Meetings
    • 9.2 Departmental talks
    • 9.3 Regular Check-Ins
    • 9.4 PI PIE
  • 10 Internal Resources (PIE LAB)
    • 10.1 Talapas
    • 10.2 Server
      • 10.2.1 Accessing the drive on a Mac
      • 10.2.2 Accessing the drive on a PC
    • 10.3 Website
      • 10.3.1 Details
      • 10.3.2 Purpose
      • 10.3.3 Current sections
      • 10.3.4 How to update
    • 10.4 Manual
      • 10.4.1 Clone lab manual to your computer
      • 10.4.2 Updating the manual [using the RStudio GUI]
      • 10.4.3 Updating the manual [using the terminal in Rstudio]
      • 10.4.4 Requesting updates
    • 10.5 GitHub
    • 10.6 Research Assistants
      • 10.6.1 Joining the PIE lab
    • 10.7 Lab logo
  • 11 External Resources
    • 11.1 Psychology Department
      • 11.1.1 Graduate Training
      • 11.1.2 Resources
    • 11.2 Support at the University of Oregon
      • 11.2.1 Technology
      • 11.2.2 Financial support
      • 11.2.3 Professional Societies
  • 12 Tutorials and Links
    • 12.1 R and RMarkdown
      • 12.1.1 Beginners
      • 12.1.2 Cheatsheets
      • 12.1.3 Data Visualization
      • 12.1.4 Markdown
      • 12.1.5 Using Zotero with RMarkdown
      • 12.1.6 GitHub
      • 12.1.7 Downloading direct from source
      • 12.1.8 Text Analysis
      • 12.1.9 Iteration
      • 12.1.10 Writing functions
      • 12.1.11 Making tables
      • 12.1.12 Reproducibility
      • 12.1.13 US Census API
    • 12.2 Writing
      • 12.2.1 Grammar and syntax
      • 12.2.2 Finding articles
      • 12.2.3 Bibliography
      • 12.2.4 Reviewing the literature
      • 12.2.5 Responding to reviews
    • 12.3 Survey Building
      • 12.3.1 Qualtrics
    • 12.4 Presentations
    • 12.5 Authorship
    • 12.6 Statistics
      • 12.6.1 Probability
      • 12.6.2 Generalized Linear Model
      • 12.6.3 Machine learning+
      • 12.6.4 Text analysis
      • 12.6.5 Statistical Power
      • 12.6.6 Structural Equation Modeling
      • 12.6.7 Mediation and Moderation
      • 12.6.8 Longitudinal data analysis
      • 12.6.9 Item response theory
    • 12.7 Graduate School
    • 12.8 Life
  • 13 Onboarding
    • 13.1 Everyone
    • 13.2 Graduate Students
    • 13.3 Undergraduate (RA and Honors Students)
  • 14 Data
    • 14.1 SAPA project website
      • 14.1.1 Introduction
    • 14.2 Ethics
    • 14.3 SAPA Data
    • 14.4 Collecting data
      • 14.4.1 Amazon Mechanical Turk
      • 14.4.2 Prolific
    • 14.5 Storing and Managing
    • 14.6 Codebooks
    • 14.7 Analyzing
  • 15 Publications
    • 15.1 Authorship
    • 15.2 Pre-publication checklist
    • 15.3 Preprints and open access
    • 15.4 Where we submit
  • 16 Conferences
    • 16.1 Conferences we typically attend
    • 16.2 How/why to give a talk
    • 16.3 Travel expenses
      • 16.3.1 Conference fees
      • 16.3.2 Flights
      • 16.3.3 Hotels
      • 16.3.4 Other expenses
    • 16.4 Poster printing
  • 17 Offboarding
    • 17.1 Checklist
    • 17.2 Unfinished projects and intellectual property
    • 17.3 Staying in touch
  • Published with bookdown

PIE Lab Manual

Chapter 12 Tutorials and Links

12.1 R and RMarkdown

  • Big Book of R – A collection of every book using R!

12.1.1 Beginners

  • R for Data Science
  • YaRrr! The Pirate’s Guide to R – this one is great for undergraduates
  • Learning Statistics with R
  • Cookbook for R
  • R for Psychological Science

12.1.2 Cheatsheets

All cheatsheets can be downloaded here.

Especially useful cheatsheets include:

  • RMarkdown Reference
  • Data Viz
  • Transformation
  • Iteration
  • Purrr
  • Stringr

12.1.3 Data Visualization

  • How to make better spaghetti plots
  • DiagrammR – flowcharts and diagrams
  • DAG models
  • Twitter thread of tutorials by @CedScherer

12.1.4 Markdown

  • RMarkdown: The Definitive Guide

    • See the section on Websites
  • Advanced R Markdown (customization and extensions) – lots of useful tips in here, once you’re familiar with Markdown.

  • Awesome tables with kable (PDF)

  • Awesome tables with kable (HTML)

  • How to convert a Google doc to RMarkdown

  • Making slides

12.1.5 Using Zotero with RMarkdown

  1. Download and install Zotero.
  2. Download and install the Better BibTex add-on.
  3. Open Zotero, and go to Preference.
    • Under the Export tab, make sure Default Format is “Better BibTex Citation Key Quick Copy.”
    • Under the Better BibTex tab, make sure the Citation key format is something you’ll find useful. (I recommend [auth:lower][veryshorttitle:lower:alphanum][year]).
  4. At this point, you can choose to export your Zotero library to a .bib file, save it to the working directory of your RMarkdown file, and make sure the bibliography line is pointing to that file. Once that’s done, you can simply drag from Zotero to your RMarkdown file, to create in-line citations, and the references section at the end will be created for you.

OR, you can install the citr package, which works with your Zotero library, so you don’t need to create a new .bib file manually for each paper. Seems really convenient! (More information here.)

12.1.6 GitHub

  • Happy Git with GitHub and R
  • Cheatsheet for terminal commands

12.1.7 Downloading direct from source

  • Downloading surveys into R directly from Qualtrics.

12.1.8 Text Analysis

  • Text mining Twitter with TidyText – includes n-gram network plot
  • Word vectors with tidy data principles

12.1.9 Iteration

  • Purrr

12.1.10 Writing functions

  • Non-standard evaluation

12.1.11 Making tables

  • Awesome tables with kable (PDF)
  • Awesome tables with kable (HTML)
  • gt package
  • The tableby package is excellent for descriptive statistics, as it can calculate central tendency/variability for continuous variables and counts for categorical variables and integrate them into a single table. If you want descriptives by group (e.g., a treatment/control or by gender), it will also calculate those and statistical tests (\(t\) and \(\chi^s\) both!).
  • The modelsummary package seems very useful and customizable. May also work with all outputs from Markdown and Quarto, unlike sjPlot.

12.1.12 Reproducibility

  • 8 things to make research more findable
  • Ensure that the correct versions of packages are loaded using the groundhog package.

12.1.13 US Census API

This is a short tutorial on using the US Census API in word.

You’ll need the following: * an API key. You can request one at https://api.census.gov/data/key_signup.html. * the R package censusapi

Your key is used to access the API when working in R. It’s not recommended that you share your key with anyone, nor is anyone allowed to use your key to access the API. For that reason, we recommend creating an R script (census-api-key.R) inside your project folder that assigns your key to an object. This script only needs to contain a single line of code:

census_key = "Your Key Here"

Do not share this script with anyone. If using GitHub, add the path to this script to the .gitignore file. You can see the .gitignore for this project as an example.

To use the API, load the censusapi package and source the key script. Then add the key to your R environment.

library(censusapi)
source("census-api-key.R")
Sys.setenv(CENSUS_KEY=census_key)

There are many datasets in the API. You can see them by running the code:

apis <- listCensusApis()

You can View() this object to sort through the datsets. The set of datasets most useful for linking with SAPA data are those from the American Community Survey, especially the 5-year surveys. Look for datasets with acs in the name or acs5 for the 5-year files specifically. If there are surveys in multiple years, you’ll need to know which year (vintage) you would like data from.

You can see the variables available in a survey using the listCensusMetadata function.

vars = listCensusMetadata(
  name = "acs/acs5",
  vintage = 2019,
  type = "variables"
)
head(vars)
name label concept predicateType group limit predicateOnly hasGeoCollectionSupport attributes required
for Census API FIPS ‘for’ clause Census API Geography Specification fips-for N/A 0 TRUE NA NA NA
in Census API FIPS ‘in’ clause Census API Geography Specification fips-in N/A 0 TRUE NA NA NA
ucgid Uniform Census Geography Identifier clause Census API Geography Specification ucgid N/A 0 TRUE TRUE NA NA
B24022_060E Estimate!!Total:!!Female:!!Service occupations:!!Food preparation and serving related occupations SEX BY OCCUPATION AND MEDIAN EARNINGS IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) FOR THE FULL-TIME, YEAR-ROUND CIVILIAN EMPLOYED POPULATION 16 YEARS AND OVER int B24022 0 NA NA B24022_060EA,B24022_060M,B24022_060MA NA
B19001B_014E Estimate!!Total:!!$100,000 to $124,999 HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS) (BLACK OR AFRICAN AMERICAN ALONE HOUSEHOLDER) int B19001B 0 NA NA B19001B_014EA,B19001B_014M,B19001B_014MA NA
B07007PR_019E Estimate!!Total:!!Moved from different municipio:!!Foreign born:!!Naturalized U.S. citizen GEOGRAPHICAL MOBILITY IN THE PAST YEAR BY CITIZENSHIP STATUS FOR CURRENT RESIDENCE IN PUERTO RICO int B07007PR 0 NA NA B07007PR_019EA,B07007PR_019M,B07007PR_019MA NA

You’ll also need to know the geography you’re collecting from. You can see the available geographies with similar code:

geo = listCensusMetadata(
  name = "acs/acs5",
  vintage = 2019,
  type = "geography"
)
head(geo)
name geoLevelDisplay referenceDate requires wildcard optionalWithWCFor
us 010 2019-01-01 NULL NULL NA
region 020 2019-01-01 NULL NULL NA
division 030 2019-01-01 NULL NULL NA
state 040 2019-01-01 NULL NULL NA
county 050 2019-01-01 state state state
county subdivision 060 2019-01-01 state , county county county

To match with SAPA data, you’ll want to use the ZCTA or zip code tabulation area geography. Then use the getCensus function to import data using the API. For example, if I wanted to extract the total number of households and people in each ZCTA to match with SAPA, I would use the following:

uscensus <- getCensus(
    name = "acs/acs5/profile",
    vars = c("NAME", 
             "DP02_0001E",  # number of households
             "DP05_0001E"  # number of persons
             ), 
    region = "zip code tabulation area", regionin = "state:*",
    vintage = 2019)

See more in the censusapi vignette.

12.2 Writing

  • Dan Simons – writing guide
  • EJ Wagenmakers – Teaching graduate students how to write clearly
  • Writing Workshop – includes both tips on how to write (content), as well as the practice of writing regularly. This book also provide the foundation for starting a writing group.
  • Practical Typography

12.2.1 Grammar and syntax

  • Verb tenses

12.2.2 Finding articles

  • CrossRef – get DOI’s quickly
  • Connected Papers – find other articles related to a specific research article

12.2.3 Bibliography

  • Zotero
  • ZBib

12.2.4 Reviewing the literature

  • Guide from the University of South Australia

12.2.5 Responding to reviews

  • Workflow for R&R

12.3 Survey Building

12.3.1 Qualtrics

  • Did you create a matrix but wish they were separate questions? Turn on the Carousel presentation.

  • If you’re using a screener, you can set up a Contact List Trigger.

  • Building a daily diary or ESM study? These may be helpful:

    • Automated email distribution of Qualtrics surveys (specific to daily diary)
    • Use Contact List Triggers to update embedded data (e.g., how many times someone has taken the survey, etc)
    • See this article by Cui and colleagues.

12.4 Presentations

  • Public speaking for academics
  • Free PowerPoint templates

12.5 Authorship

  • tenzing – this is a useful Shiny app for creating text (for Word or papaja) that includes author affiliations and also creditorship using the CRediT system. Espescially handy for large teams.

12.6 Statistics

12.6.1 Probability

  • Seeing Theory

12.6.2 Generalized Linear Model

  • Logistic regression is not fucked
  • Melt the clock: tidy time series analysis
  • Causal Inference: What If by Miguel A. Hernán & James M. Robins – Chapter titles: A defintion of causal effect, Randomized experiments, Observational studies, Effect modification, Interaction, Graphical representation of causal effects, Confounding, Selection bias, Measurement bias, Random variability, Why model, IP weighting and marginal structural models, Standardization and the parametric g-function, G-estimation of structural nested models, Outcome regression and propensity scores, Instrumental variable estimation, Causal survival analysis, Variable selection for causal inference, Time-varying treatments, Treatment-confounder feedback, G-methods for time-varying treatments, Target trial emulation

12.6.3 Machine learning+

  • Statistical rethinking

  • Machine learning for psychologists: A gentle introduction

  • Specification curves

12.6.4 Text analysis

  • Structual Topic Models
  • Erin Buchanan (Stats of Doom) NLP

12.6.5 Statistical Power

  • Powering interactions
  • Explore researcher degrees of freedom

12.6.6 Structural Equation Modeling

  • Michael Hallquist’s SEM course
  • Erin Buchanan (Stats of Doom) SEM

12.6.7 Mediation and Moderation

  • Erin Buchanan (Stats of Doom) Mediation/Moderation

12.6.8 Longitudinal data analysis

  • Personality Development Collaborative – also includes links to datasets that may be useful.

12.6.9 Item response theory

  • Edwards (2009) – An Introduction to Item Response Theory Using the Need for Cognition Scale
    • I would recommend starting with this article. The journal is aimed at graduate student seminars, so it will be more targeted to general understanding and application among psychologists, rather than to quantitative psychologists. This covers the two-parameter model and the graded response model.
  • da Rocha et al. (2013) – An introduction to Rasch analysis for Psychiatric practice and research
    • This one will be similar to the Edwards article in terms of being aimed at a more general audience. This article will cover a third type of IRT model: the Rasch model.
  • Cook et al. (2005) – Dynamic Assessment of Health Outcomes: Time to Let the CAT Out of the Bag?
    • This is less about the practice of IRT itself but more an intro into some of the potential broader application, especially in medical and educational settings.
  • mirt vignette
    • This will walk through how to use the mirt package in R. I believe mirt can do all three types of models described above.
  • Check out the 6-video series by Karon Cook.

12.7 Graduate School

  • The Illustrated Guide to a Ph.D.
  • Raul Pacheco’s resources – a good collection of tips for everything from time management, to how to read and write, to using social media.
  • Escaping the hamster wheel by Elliot Berkman

12.8 Life

  • Note that being a GE and having a research fellowship are considered different forms of compensation. Here’s a guide to preparing your (2019) federal taxes.

  • Diverse careers among applied psychologists – contact list of psychologists working outside of academia

  • Writing up your experiences on a resume (H/T: Jin Goh) ## Applying to graduate school

  • Psych Research List – Lists of internships, virtual grad program information sessions, jobs, resources for applying to grad programs, etc.

  • Application Statement Feedback Program – A service providing feedback on research statements for those applying to Psychology graduate programs.