Introduction

What this course is about — and how to get set up

Merlin Schaeffer · Department of Sociology

2026-09-09

By the end of today you can …

  1. say what an explanatory research question is — the kind this course teaches you to answer;

  2. explain how the course works — the weekly rhythm, the quizzes, and what I assume you know;

  3. run R code inside your own course project — set up today, together.

One part of today’s lecture per goal.

What is this course about?

Part 1 of 3

Sociology asks many kinds of questions.

This course is about one kind: what is the effect of X?

My research agenda

How does international immigration transform societies?

Some of my current work

Source: Schaeffer, Romarri, Rosenberg, and Krakowski (2025)

Some of my current work

Source: Schaeffer, Romarri, Rosenberg et al. (2025)

Some of my current work

Source: Wiedner, Schaeffer, Carol, and Böller (2025)

Some of my current work

Source: Schaeffer and Andersen (2025)

Some of my current work

Source: Schaeffer and Andersen (2025)

Some of my current work

Source: Schaeffer and Andersen (2025)

4 types of research questions

(1) Ontological: what is the nature of X?

  • What is power?
  • What is gender; how is it different from sex?
  • What is a state? “A human community that (successfully) claims the monopoly of the legitimate use of physical force within a given territory.” — Max Weber, “Politics as a Vocation” (1918)

(2) Critical: is X (un-)just?

  • Is home office exploitation?
  • Is the colorblind ideology a new form of racism?

Discuss: think of the last exam you wrote — which type of research question did it engage with?

(3) Descriptive: what types of X exist, and how frequent are they?

  • What are the survival strategies of the poor?
  • How did Danes structure their days during the COVID-19 lockdowns?

(4) Explanatory: what is the effect of X?

  • What are the consequences of anomie? Why does the suicide rate vary across societies?
  • How does capitalism affect us?
  • How does urbanization affect us?

This course is about explanatory questions: what is the effect of X?

Goal of empirical sociology

Use data to discover patterns,
and the social mechanisms that bring them about.

Three learning goals

(1) Multiple OLS regression

  • Multiple predictors & confounder adjustment (Frisch-Waugh),
  • Interaction effects,
  • Polynomials.

(2) Visualization of regression results

  • Model predictions,
  • Coefficient plots.

(3) Fundamentals of causal inference

  • Potential outcomes & directed acyclical graphs (DAG),
  • Randomised Controlled Trials (RCT),
  • Intention to treat (ITT) & instrument variable (IV) regression,
  • Multiple regression,
  • 2-SLS instrument variable regression,
  • Regression discontinuity designs (RDD).

Example: regression discontinuity design

Example: regression discontinuity design

Municipalities where far-right candidates ran versus where they won

Source: Romarri (2020)

Example: regression discontinuity design

Source: Romarri (2020)

Discuss: why compare municipalities where the far-right barely won with those where it barely lost?

Near the threshold, winning is almost random — so the two groups are comparable, like in an experiment. The full logic comes in Lecture 13.

Example: regression discontinuity design

Source: Schaeffer, Romarri, Rosenberg et al. (2025)

Break

How the course works

Part 2 of 3

The weekly rhythm, the quizzes that qualify you for the exam, and what I assume you already know.

Course structure

TA Fridays Room
Sofie 8 am CSS 2-2-49
Natalie 10 am CSS 2-0-30
Joakim 10 am CSS 2-0-42

Recommendations

  • Activate email notifications on Absalon.
  • Regularly check your KU email, or forward it to your personal email.
  • Ask and answer questions in the t-R-ouble forum on Absalon.

Weekly Absalon online quizzes

  • 13 online quizzes on Absalon, designed by Epinion & us.

  • Based on data Epinion collects for the municipality of Copenhagen, DR, Skat, etc.

  • Made available online Wednesdays after the lecture.

Beware: submit at least 10 completed quizzes — individually, each within two weeks of release — or you do not qualify for the exam.

Consequently, this course assumes

  1. You have basic R coding skills and know how to use RStudio.
  1. You know basic statistics:
    • Descriptive statistics: \(\%\), \(\bar{x}\), \(\text{SD}(x)\).
    • Associations:
      • Correlation: \(r_{y,x}\),
      • OLS regression: \(y_{i} = \alpha + \beta x_{i} + \epsilon_{i}\).
    • Inference: confidence intervals, \(t\)-values & \(p\)-values.

Rusty on any of this? Part 3 of today gets your tools ready, and the first weeks refresh the statistics.

Two textbooks

\(\rightarrow\) Available at Academic Books on City Campus and at the university library.

Carried over from last semester; serves as a reference for regression and statistical inference.

Veaux, Velleman, and Bock (2021)

To learn how to identify causal effects, we use Angrist & Pischke’s textbook.

Angrist and Pischke (2014)

AI (like ChatGPT)

  1. Privacy: don’t use AI/LLMs to process sensitive information!

  2. Learning:

    • Use AI to explain, comment, debug, and improve R code while you draft it.
    • Use AI to get summaries of text passages and concepts that you do not understand.
    • Use AI to discuss your understanding of the course materials and ask about things that confuse you.
  3. Generation: don’t use AI to generate, draft, and write your R code. You need to learn how to code to assess whether the AI coded what you asked for.

Questions?

Get your tools ready

Part 3 of 3

Everyone leaves today with a working R setup — we do this together, now.

Task 1: install R & RStudio

  1. Get a recent version of R (≥ 4.6.0).

  2. Install RStudio, or update to the most recent version.

The same steps, with more detail, are on the course website under About & setup.

Task 2: get to know RStudio

Task 3: set RStudio preferences

Set these preferences to improve reproducibility!

\(\rightarrow\) RStudio / Tools / Global options.

RStudio workflow

  1. Use Projects to manage all files (scripts, data, figures, and tables) belonging to the same project.

  2. Always start your RStudio session by clicking on the Project for this course.

  3. Use the editor to write as many R scripts as you like, saved in the same folder as your Project. Thereby you can reproduce your results.

Set up your “Stats_II” project

  • Click on the Project button.

Set up your “Stats_II” project

Set up a new project in RStudio:

  1. “New Directory”
  2. “New Project”
  3. Finally, a name for the folder and — under “Browse” — where you want that folder to be located. I call mine Stats_II. This also generates a folder with the name you chose. Use that folder for everything related to this course.

Done! Now you should find an empty folder under the path where you wanted it set up.

Beware: in the future, always start RStudio by double-clicking the project icon in your folder for this course.

Set up your “Stats_II” project

Set up a new project in RStudio:

  1. “New Directory”
  2. “New Project”
  3. Finally, a name for the folder and — under “Browse” — where you want that folder to be located.

Set up your “Stats_II” project

Set up a new project in RStudio:

  1. “New Directory”
  2. “New Project”
  3. Finally, a name for the folder and — under “Browse” — where you want that folder to be located.

Set up your “Stats_II” project

Done! Now you should find an empty folder under the path where you wanted it set up.

R scripts

  1. Open a new R script.
  2. Save it in your new folder. Find it under “Files”.

R scripts

  1. Type the lines shown in the screenshot on the right.
  2. Save the file by clicking on the floppy-disc icon. I called mine “Lecture.R”.
  3. Mark all code and click “Run”.

R scripts

OK, you are good to go!

Pro tip: use the R script to take notes during the lecture!

A # defines a comment. So use it to take notes and code in one single document per lecture.

Check yourself: today’s goals

Look back at the goals from the start of the lecture. Can you tick all three?

  • Explain to your neighbour what an explanatory research question is — and give one example.
  • Name what it takes to qualify for the exam — how many quizzes, submitted how?
  • Open your Stats_II project in RStudio and run a line of R code from a saved script.

Anything feel shaky? That is what this week’s Absalon quiz and the Friday exercise class are for.

References

Angrist, J. D. and J. Pischke (2014). Mastering ’Metrics: The Path from Cause to Effect. Princeton University Press.

Romarri, A. (2020). Do Far-Right Mayors Increase the Probability of Hate Crimes? Evidence From Italy. SSRN Scholarly Paper ID 3506811. Rochester, NY: Social Science Research Network.

Schaeffer, M. and S. Andersen (2025). “Unveiling the Price of Green”. In: Unpublished manuscript.

Schaeffer, M., A. Romarri, D. Rosenberg, et al. (2025). “When Politics Enters the Waiting Room: Far-Right Electoral Victories Exacerbate Discrimination in Access to Healthcare”. In: American Political Science Review. Forthcoming.

Veaux, D., Velleman, and Bock (2021). Stats: Data and Models, Global Edition. Pearson Higher Ed.

Wiedner, J., M. Schaeffer, S. Carol, et al. (2025). “Local Communities, Distant Origins: How Cultural Distance and Local Context Shape Immigrant Ethno-Religious Infrastructures”. In: American Journal of Sociology.