Walkthroughs

← All Courses Walkthroughs

Narrated Walkthroughs

The HEAL Learning Lab

This page lists the narrated walkthroughs that accompany the course modules. Each walkthrough plays as a series of narrated scenes with captions and a transcript, and each R walkthrough runs a downloadable script line by line so that the analysis can be repeated in R or RStudio. The R walkthroughs are grouped by the HSCI 410 lesson they support, the survival analysis walkthrough for HSCI 341 Lesson 8 has its own section, and the writing walkthroughs appear in the final section.

The collection contains 20 walkthroughs, of which 17 demonstrate analyses in R and 3 demonstrate academic writing. Together they provide approximately 10 hours of narration, and the running time shown for each walkthrough refers to playback at normal speed.

Getting started and planning

HSCI 410 · Lesson 1
R walkthroughHSCI 41026 min28 scenes

Getting Started with R and RStudio

The walkthrough installs R and RStudio, introduces objects, functions, packages and help files, and shows how an AI assistant can help to plan, write and debug code. The running example compares mean depressive symptom scores by gender in the 2021 Canadian Social Connection Survey.

Data
Canadian Social Connection Survey, 2021 wave
Packages
psych
Module
HSCI 410, Lesson 1: A Structured Approach to Data Analysis
Download
CSCS data (.RData)
10 chapters
  1. Getting started
  2. Installing R and RStudio
  3. R as a calculator
  4. Objects
  5. Functions
  6. Packages
  7. Real data
  8. Help files
  9. An AI coding buddy
  10. Bringing it together
WalkthroughHSCI 41028 min27 scenes

From a Research Question to an Analysis Plan

The walkthrough turns a broad topic into a PECO question, judges the question against the FINER criteria, checks its feasibility in the survey data, and draws the causal diagram in the CSCS data dictionary and in R with dagitty. It closes with a written analysis plan and planned sensitivity analyses, and the running example asks whether living with a dog is associated with lower loneliness.

Data
Canadian Social Connection Survey, 2021 wave
Packages
dagitty
Modules
HSCI 410, Lesson 1: A Structured Approach to Data Analysis
HSCI 207, Lesson 2: Developing a Research Question
HSCI 207, Lesson 3: Causal Webs and Directed Acyclic Graphs
9 chapters
  1. Getting started
  2. From a topic to a question
  3. Is it a good question?
  4. Drawing the causal model
  5. Checking feasibility in R
  6. The DAG in R
  7. An initial analysis plan
  8. Planning sensitivity analyses
  9. Wrapping up

Data cleaning and missing data

HSCI 410 · Lesson 2
R walkthroughHSCI 41047 min50 scenes

Data Cleaning and Descriptive Statistics in R

The script keeps the rows and columns that the analysis needs, explores each variable before recoding it, checks every recode, and describes the analysis dataset with summary statistics, plots, stratified tables and a Table 1. The running example describes how loneliness varies by age, gender, mental health and living situation among adults in Canada.

Data
Canadian Social Connection Survey, public release
Packages
moments tableone
Module
HSCI 410, Lesson 2: Data Cleaning and Descriptive Analyses
11 chapters
  1. Getting started
  2. Loading the data
  3. Selecting rows and columns
  4. Exploring each variable
  5. Recoding variables
  6. Descriptive statistics
  7. Descriptive plots
  8. Stratified tables
  9. Subsets and the analysis dataset
  10. Table 1
  11. Bringing it together
R walkthroughHSCI 41041 min39 scenes

Missing Data and Multiple Imputation in R

The script measures how much information is missing and for whom, and then compares complete-case analysis, single imputation and multiple imputation with 40 completed datasets pooled by Rubin's rules. The running example estimates the association between social support and loneliness after adjustment for age, gender and household income.

Data
Canadian Social Connection Survey, 2021 wave
Packages
mice
Module
HSCI 410, Lesson 2: Data Cleaning and Descriptive Analyses
10 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. How much is missing?
  5. Who is missing?
  6. Complete-case analysis
  7. Single imputation
  8. Multiple imputation
  9. Pooling the results
  10. Bringing it together

Linear and logistic regression

HSCI 410 · Lesson 3
R walkthroughHSCI 41070 min67 scenes

Linear and Logistic Regression in R

The script fits linear and logistic regression models and checks the assumptions of each in turn, including linearity, equal spread, normality of residuals, influential observations, independence and collinearity. The running example asks whether loneliness differs by age and whether any difference remains once gender is taken into account.

Data
Canadian Social Connection Survey
Packages
lmtest car regclass ResourceSelection pscl pROC
Module
HSCI 410, Lesson 3: Linear and Logistic Regression
15 chapters
  1. Getting started
  2. Loading the data
  3. Exploring the data
  4. Fitting linear models
  5. How model checking works
  6. Linearity
  7. Equal spread
  8. Normality of residuals
  9. Influential observations
  10. Independence
  11. Collinearity
  12. Linear model verdict
  13. Logistic regression
  14. Checking the logistic model
  15. Bringing it together
R walkthroughHSCI 41018 min25 scenes

Comparing Models and Selecting Variables in R

The script holds the analytic sample constant, compares models chosen by the analyst with F-tests, adjusted R-squared, the AIC and the BIC, and then examines backward elimination, forward selection and the limits of automatic selection. The running example considers which of seven candidate variables help to predict loneliness.

Data
Canadian Social Connection Survey, 2021 wave
Packages
Base R only
Module
HSCI 410, Lesson 3: Linear and Logistic Regression
11 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. The same people in every model
  5. Comparing models we choose
  6. The full model
  7. Backward elimination
  8. Forward selection
  9. Comparing the candidates
  10. What selection cannot tell us
  11. Bringing it together

Generalized linear models

HSCI 410 · Lesson 4
R walkthroughHSCI 41029 min33 scenes

Ordinal Logistic Regression in R

The script orders a five-level outcome, fits a proportional odds model, reports odds ratios and predicted probabilities, and examines the proportional odds assumption with the Brant test. The running example asks whether age and smoking are associated with self-rated health.

Data
PHAA outcomes teaching dataset (795 adults)
Packages
MASS brant
Module
HSCI 410, Lesson 4: Generalized Linear Models
10 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. Looking before modelling
  5. The ordinal model
  6. Odds ratios
  7. Predicted probabilities
  8. Checking the assumptions
  9. Inside the Brant test
  10. Bringing it together
R walkthroughHSCI 41022 min26 scenes

Multinomial Logistic Regression in R

The script fits a model for an outcome with four unordered categories, reports relative risk ratios and predicted probabilities, shows how the results change with a different reference category, and checks the assumptions of the model. The running example asks whether age and smoking are associated with where people usually go for health care.

Data
PHAA outcomes teaching dataset (795 adults)
Packages
nnet
Module
HSCI 410, Lesson 4: Generalized Linear Models
10 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. Looking before modelling
  5. The multinomial model
  6. Relative risk ratios
  7. Predicted probabilities
  8. The reference category
  9. Checking the assumptions
  10. Bringing it together
R walkthroughHSCI 41025 min30 scenes

Poisson and Negative Binomial Regression in R

The script fits a Poisson regression to a count outcome, checks the model for overdispersion, fits a negative binomial regression and compares the two models, and finishes with an example in which follow-up time differs between people. The running example models the number of urgent care and emergency department visits in the past year.

Data
PHAA outcomes teaching dataset (795 adults)
Packages
MASS
Module
HSCI 410, Lesson 4: Generalized Linear Models
10 chapters
  1. Getting started
  2. Loading the data
  3. Looking at the counts
  4. Poisson regression
  5. Checking for overdispersion
  6. Negative binomial regression
  7. Comparing the two models
  8. Linearity of age
  9. Different follow-up times
  10. Bringing it together

Dependent data

HSCI 410 · Lesson 5
R walkthroughHSCI 41031 min27 scenes

Mixed Models and GEE in R

A whiteboard primer on dependent data precedes a script that measures clustering with the intraclass correlation, fits linear and generalized linear mixed models and generalized estimating equations, and treats repeated visits in a trial as clusters within people. The running examples compare urban and rural clinics and the two arms of a wellness trial.

Data
Clinic (966 patients in 30 clinics) and wellness-trial teaching datasets
Packages
lmerTest geepack
Module
HSCI 410, Lesson 5: Modelling Dependent Data
8 chapters
  1. Getting started
  2. Concept primer
  3. The clinic data
  4. Measuring the clustering
  5. The linear mixed model
  6. A binary outcome
  7. Repeated measures
  8. Bringing it together

Exploratory visualization

HSCI 410 · Lesson 6
R walkthroughHSCI 41032 min26 scenes

Data Visualization in Base R and ggplot2

The script takes quick looks at the data with base R graphics, rebuilds the same displays as layered plots in ggplot2, examines several variables at once, and assembles a captioned figure suitable for a manuscript. The running example describes loneliness, social support and mental health by age group and gender.

Data
Canadian Social Connection Survey, 2021 wave
Packages
ggplot2 ggExtra patchwork
Module
HSCI 410, Lesson 6: Exploratory Data Analysis and Visualization
7 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. Quick looks in base R
  5. The grammar of graphics with ggplot2
  6. Many variables and combined figures
  7. A publication-ready figure

Measurement and psychometrics

HSCI 410 · Lesson 7
R walkthroughHSCI 41034 min35 scenes

Factor Analysis and Scale Scoring in R

The script recodes and reverse-codes the six items of the De Jong Gierveld Loneliness Scale, explores their structure with exploratory factor analysis, tests that structure with confirmatory factor analysis in a separate half of the sample, estimates reliability, and scores the scale with its published rule. The running example asks whether the items measure the emotional and social forms of loneliness that the scale was designed to capture.

Data
Canadian Social Connection Survey, 2021 wave
Packages
psych GPArotation lavaan
Module
HSCI 410, Lesson 7: Measurement and Psychometrics
11 chapters
  1. Getting started
  2. Loading the data
  3. The six items
  4. Recoding the answers
  5. Looking at the items
  6. Splitting the sample
  7. Exploratory factor analysis
  8. Confirmatory factor analysis
  9. Reliability
  10. Scoring the scale
  11. Bringing it together
R walkthroughHSCI 41021 min26 scenes

Latent Class Analysis in R

The script recodes seven check-all-that-apply items, fits models with one to five classes, compares those models to choose the number of classes, assigns each person to a class, and compares the classes on loneliness and age. The running example asks whether people who feel lonely fall into groups that differ in what they miss.

Data
Canadian Social Connection Survey, 2021 wave
Packages
poLCA
Module
HSCI 410, Lesson 7: Measurement and Psychometrics
11 chapters
  1. Getting started
  2. Loading the data
  3. The seven items
  4. Recoding the items
  5. Looking at the items
  6. Latent class analysis
  7. Choosing the number of classes
  8. The three-class model
  9. Assigning people to classes
  10. Describing the classes
  11. Bringing it together

Mediation, moderation and path analysis

HSCI 410 · Lesson 8
R walkthroughHSCI 41023 min25 scenes

Mediation and Moderation in R

The script fits each path of a mediation chain with linear regression, tests the indirect effect with the bootstrap, and examines moderation with an interaction term and group-specific slopes. The running examples ask whether loneliness helps to explain the association between social support and depressive symptoms, and whether the association between support and loneliness differs between younger and older adults.

Data
Canadian Social Connection Survey, 2021 wave
Packages
mediation
Module
HSCI 410, Lesson 8: Mediation Moderation and Path Analysis
7 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. Mediation step by step
  5. Testing the indirect effect
  6. Moderation with an interaction term
  7. Bringing it together
R walkthroughHSCI 41019 min22 scenes

Path Analysis with SEM in R

The script restates the mediation model as a path model in lavaan, extends it to two outcomes, assesses model fit, compares models with and without direct paths, and reports standardized indirect effects with bootstrap confidence intervals. The running example asks whether loneliness accounts for the association between social support and both depressive and anxiety symptoms.

Data
Canadian Social Connection Survey, 2021 wave
Packages
lavaan
Modules
HSCI 410, Lesson 8: Mediation Moderation and Path Analysis
HSCI 410, Lesson 3: Linear and Logistic Regression
9 chapters
  1. Getting started
  2. Loading the data
  3. Preparing the variables
  4. Path models
  5. A first path model
  6. Two outcomes
  7. Partial mediation
  8. Results
  9. Bringing it together

Sensitivity analyses

HSCI 410 · Lessons 1 and 3
R walkthroughHSCI 41044 min37 scenes

Sensitivity Analyses in R

The script fits the primary model from the analysis-plan walkthrough and repeats it with one decision changed at a time, covering variable coding, model choice, the adjustment set, unmeasured confounding with an E-value and a negative control, and multiple imputation. It closes with subgroups and interaction terms, an exploratory mediation analysis, other measures of loneliness, a forest plot and a specification curve, and the running example asks whether living with a dog is associated with lower loneliness.

Data
Canadian Social Connection Survey, 2021 wave
Packages
sandwich lmtest EValue mice
Modules
HSCI 410, Lesson 1: A Structured Approach to Data Analysis
HSCI 341, Lesson 7: Validity and Confounding in Observational Studies
HSCI 230, Lesson 12: Integrated Appraisal of Epidemiological Research
12 chapters
  1. Getting started
  2. When to conduct a sensitivity analysis
  3. The primary analysis
  4. Coding decisions
  5. Model choice
  6. The adjustment set
  7. Unmeasured confounding
  8. Missing data
  9. Samples and subgroups
  10. Mediation
  11. Other measures of loneliness
  12. Bringing it together

Time-to-event data

HSCI 341 · Lesson 8
R walkthroughHSCI 34127 min24 scenes

Survival Analysis in R

A whiteboard primer on censoring and the Kaplan-Meier estimate precedes a script that builds a survival object, estimates and compares survival curves with the log-rank test, and fits a Cox regression model whose proportional hazards assumption is then checked. The running example uses the lung cancer data supplied with the survival package.

Data
Lung data supplied with the survival package
Packages
survival
Module
HSCI 341, Lesson 8: Time to Event Data
10 chapters
  1. Getting started
  2. Concept primer
  3. Loading the data
  4. Preparing the variables
  5. The survival object
  6. Kaplan-Meier estimates
  7. Comparing groups
  8. Cox regression
  9. Checking assumptions
  10. Bringing it together

Writing walkthroughs

HSCI 341 · HSCI 410
Writing walkthroughHSCI 34124 min24 scenes

Writing a Short Research Grant Proposal

The walkthrough reads a call for proposals, introduces logos, ethos and pathos as forms of persuasion, and works through the significance, aims, approach, team, timeline, risks and budget of a five-page proposal, with an AI assistant used for brainstorming and checking. The running example is a fictional pilot trial of telephone befriending for older adults who live alone.

Modules
HSCI 207, Lesson 6: Choosing an Approach and Managing a Research Project
HSCI 207, Lesson 2: Developing a Research Question
Downloads
Gantt Chart Template (.xlsx)
Grant Proposal Template (.docx)
10 chapters
  1. Getting started
  2. Persuasion in academic writing
  3. The significance section
  4. Aims and objectives
  5. The approach
  6. Team, partnerships and knowledge mobilization
  7. The timeline
  8. Risks, limitations and the budget
  9. AI as a thinking companion
  10. Bringing it together
Writing walkthroughHSCI 41027 min25 scenes

Writing a Research Manuscript

The walkthrough plans and drafts a short IMRaD manuscript, covering literature searching with PubMed and Elicit, each section of the paper, the relevant reporting guidelines, and the checking of AI-assisted tables against R output. The running example is a manuscript built from the linear and logistic regression walkthrough.

Module
HSCI 207, Lesson 12: Writing Up Research
Download
Research Manuscript Template (.docx)
9 chapters
  1. Getting started
  2. A question worth answering
  3. Finding the literature
  4. The introduction
  5. Drafting with an AI assistant
  6. The methods
  7. The results
  8. The discussion
  9. Bringing it together
Writing walkthroughHSCI 341HSCI 41021 min24 scenes

Citing Sources with Zotero in APA Style

The walkthrough reviews the essentials of APA citation, installs Zotero and the Zotero Connector, saves and checks references, and inserts citations and a reference list in Microsoft Word. The final chapters introduce Elicit and ResearchRabbit for finding research related to the sources already collected.

Modules
HSCI 207, Lesson 12: Writing Up Research
HSCI 241, Lesson 5: Grey Literature Web Searching and Citation Chasing
Download
Get Zotero ↗
8 chapters
  1. Getting started
  2. APA style in brief
  3. Installing Zotero
  4. The Zotero Connector
  5. Checking and organizing
  6. Zotero in Word
  7. Finding related research
  8. Bringing it together