Quantitative Methods I
Seminar materials, autumn 2026
Introduction
These materials belong to the course Quantitative Methods (SHRG.03.024) at the Johan Skytte Institute of Political Studies.
The course has two aims. The first is to give you a working understanding of the most common statistical methods in the social sciences — what they do, when they apply, and what their results mean. The second is to show you how to actually carry them out, using R.
There is also a third aim, which runs underneath both of the others and which is easy to overlook: to make you think about numbers before you compute with them. A great deal of quantitative social science consists of running a model on whatever variables are at hand and reporting whatever comes out. That is not the same thing as understanding. Some of the most useful thinking you can do about a relationship happens before you touch any data at all.
The course assumes no prior knowledge. We start from an empty screen. General computer skills help, and so does whatever secondary-school mathematics is still lodged somewhere in your memory. We will not go deep into the mathematics behind the methods — the focus is on the logic of each method, the conditions under which it applies, and how to use it in R.
How the seminars work
Each seminar is an hour and a half, and it has two halves.
The first 45 to 60 minutes is a lecture. This is where the methods, functions and techniques for that week are introduced.
The remaining half hour is hands-on. We work through a swirl lesson together — an interactive exercise that runs inside R itself and that covers the core of the week’s topic. You type the commands, R checks them, and you get immediate feedback on whether they worked.
These written materials are the third part, and you do them on your own. We will not read through them in class. Their job is to contain everything you need: the background to each topic, the reasoning behind each method, worked examples with real output, and the R code that produces it. The lecture introduces the ideas, the swirl lesson gives you practice, and these materials are what you go back to when you actually have to do something.
The lecture slides are not these materials, and neither replaces the other. The slides carry the parts worth talking through out loud, and they are posted on Moodle after each session. They are a record of what was said in class, not a summary of the chapter — everything you actually need is here.
This course does not work without independent effort. The hour and a half a week we spend together is not enough on its own to get you to the point where you can run an analysis and defend it. That comes from working through the materials, redoing the examples with your own variables, and getting stuck on your own and unstuck again.
Simple first, then harder
Each session is built as one line, not two. It starts with the simplest form of the idea and the shortest code that does the job, and then adds the complications one at a time. The same holds inside each topic within a session: the plain case first, then the awkward ones.
This is deliberate, and it has a consequence worth knowing about. If you read half of a section and stop, you should have something whole — a version of the method that is simple but not wrong. What comes after is not a correction of what came before; it is the next layer on top of it.
It also means that none of the material is optional. Later parts of a section are harder, but they are not extras. Where a formula appears, it appears after the idea has already been explained in words and pictures, because the formula is easier to read once you know what it is for — not because the words were a simplified stand-in for it.
The data
Throughout the course we use data from the Comparative Study of Electoral Systems (CSES), Module 6, and specifically the Swedish study conducted after the 2022 general election. There are 2,845 respondents.
CSES is a collaborative project that runs a common set of questions in post-election surveys across many countries, which makes the results comparable. It is free, widely used, and a perfectly reasonable choice for your own thesis.
Sweden is a good case to learn on for one particular reason: it has eight parties in parliament, and the survey asks about all of them. Respondents rate every party and every party leader on a scale from 0 to 10, and place every party on a left-right scale. That gives us something that a two-party system cannot: a vote choice with eight real categories, and a set of variables with genuine structure in them. A surprising amount of this course — crosstabs, comparing means, correlation, factor analysis, dummy variables — becomes more interesting when there are eight parties rather than two.
The parties, in left-to-right order as the respondents themselves place them:
| Party | Placed at | ||
|---|---|---|---|
| V | Vänsterpartiet | Left Party | 0.8 |
| MP | Miljöpartiet | Greens | 2.5 |
| S | Socialdemokraterna | Social Democrats | 3.1 |
| C | Centerpartiet | Centre Party | 4.7 |
| L | Liberalerna | Liberals | 6.4 |
| KD | Kristdemokraterna | Christian Democrats | 8.0 |
| M | Moderaterna | Moderates | 8.5 |
| SD | Sverigedemokraterna | Sweden Democrats | 8.5 |
In the 2022 election the Social Democrat government led by Magdalena Andersson lost its majority, and Ulf Kristersson formed a government of M, KD and L supported from outside by the Sweden Democrats. That is why the data has a bloc variable splitting the eight parties into the two sides that formed around government formation.
We use one country rather than all eighteen for a simple reason: nearly everything in this course is about relationships between variables measured on individuals. Adding countries adds a second level to the data, and that is a topic for a later course.
Citation. If you use these data, you must cite them:
The Comparative Study of Electoral Systems (www.cses.org). CSES MODULE 6 SECOND ADVANCE RELEASE [dataset and documentation]. December 16, 2025 version. doi:10.7804/cses.module6.2025-12-16
Note the words advance release. The data are published before the module is complete, which means some variables have not been harmonised yet and some countries are still missing. One consequence shows up in the weights: the CSES harmonised weights have not been calculated yet, so the only weight available is the one Statistics Sweden supplied, wt. It rakes the sample to the known population distribution of gender, age and education. That is worth having — it cuts the average error in the reported vote shares from 2.0 to 1.4 percentage points — but it corrects for who answered, not for what they said.
A survey is not an election. In our data 35.1% say they voted for the Social Democrats and 14.4% for the Sweden Democrats. The actual result was 30.3% and 20.5%. The Sweden Democrats are under-reported by 6.1 percentage points, which is a well-documented pattern: people are less willing to tell an interviewer they voted for a radical right party than they are to do it in a voting booth.
Turnout is stranger still. 97.3% of our respondents say they voted, when real turnout in 2022 was 84.2%. That is not a fault in the Swedish study — every one of the 18 election studies in CSES Module 6 over-reports turnout, by between 5.2 and 30.5 percentage points. When every measurement is wrong in the same direction, the problem is not bad luck. Session 6 is about telling those two things apart.
Keep this in mind every time we calculate something from these data. A sample tells you about a sample, and getting from there to a population takes work.
The files
Everything the course uses is here. These links are permanent, so you can point a script at one instead of downloading it by hand — session 2 shows how, and where the files belong once you have them.
| File | What it is |
|---|---|
swe.rds |
The analysis data set. Used from session 4 onwards. |
swe.csv |
The same, as plain text, for other software. |
codebook.csv |
Every variable, what it is, and how it is coded. Also as a table. |
cses6_swe_raw.csv |
The survey as it comes from the archive. Sessions 2 and 3. |
cses6_swe_raw.sav |
The same in SPSS format, with labels. |
counties.csv |
The 21 Swedish counties. Used for joining in session 3. |
world.csv |
119 countries from the World Bank. Sessions 4 and 5. |
turnout.csv |
Reported against official turnout, all 18 CSES studies. Session 6. |
build_swe.R |
The script that turns the raw file into the clean one. Read it in session 3. |
Quantitative_Methods_I.zip |
The swirl lessons. You do not need to download this — see below. |
Put the data files in a data folder inside your course project, which is how every path in these materials is written. Each file’s address is the same beginning followed by its name, for example:
https://martinmolder.github.io/quantitative-methods-i/data/swe.rds
The swirl lessons install themselves from that same address. You do not download or unzip anything — run this once in the console, and again whenever a new version is posted:
library(swirl)
install_course_url(
"https://martinmolder.github.io/quantitative-methods-i/data/Quantitative_Methods_I.zip"
)Session 1 covers this in full, including what to do if your network blocks the download.
How to use these materials
These materials are meant to be worked through, not read. Every code example is there for you to run on your own machine. Reading R code and understanding R code feel very similar and are not the same thing; the difference shows up the moment you have to write some yourself.
You will find two kinds of boxes throughout.
A question. These mark places where the answer should already be available to you from what came before, and where the text deliberately stops short of giving it. They are the discussion points in the seminar.
The swirl practical. At the end of each chapter, the lesson we do together in the second half of the seminar.
Readings
- Rein Taagepera. 2015. Logical Models and Basic Numeracy in Social Sciences. Required. The basis for sessions 2, 4 and 5.
- Andy Field et al. 2012. Discovering Statistics Using R. Sage. Strongly recommended.
- Gravetter, F.J. and Wallnau, L.B. 2016. Statistics for the Behavioral Sciences. Cengage. If you need to build up or refresh the basics.
- Agresti, A. and Finlay, B. 2008. Statistical Methods for the Social Sciences. Prentice Hall. If you want to go considerably further.
All of these are available on Moodle.
Schedule
| Date | Topic | |
|---|---|---|
| 1 | 02.09.2026 | Introduction: the course, R and RStudio, swirl |
| 2 | 09.09.2026 | Data and data management I: base R |
| 3 | 16.09.2026 | Data and data management II: the tidyverse |
| 4 | 23.09.2026 | Data visualisation with ggplot |
| 5 | 30.09.2026 | Thinking logically and visually about data |
| 6 | 07.10.2026 | The logic of hypothesis testing |
| 7 | 14.10.2026 | Analysing categorical data |
| 8 | 21.10.2026 | Comparing means |
| 9 | 28.10.2026 | Correlation |
| 10 | 04.11.2026 | Factor analysis |
| 11 | 11.11.2026 | Regression: the basic model |
| 12 | 18.11.2026 | Regression: presenting results |
| 13 | 25.11.2026 | Regression: dummy variables |
| 14 | 02.12.2026 | Regression: interactions and non-linear associations |
| 15 | 09.12.2026 | Logistic regression |
| 16 | 16.12.2026 | Final test |
How these materials were made
The 2026 version of these materials was put together with the help of artificial intelligence — specifically Anthropic’s language model Claude.
The model helped with the following:
- reviewing the previous year’s materials and working out what had to change;
- restructuring them to the new session plan and drafting the text;
- writing the R code and checking it against the new Swedish data;
- building the data preparation scripts and the
swirllessons; - checking the result by machine — that every function and argument is explained before it is used, that no number in the text is typed by hand rather than computed, and that the rules about measurement scales are applied consistently;
- finding mistakes, including several in the previous version.
All of the content has been reviewed, checked and edited by the author, and responsibility for these materials rests with the author.
Why mention it here? Because the same transparency is expected of you. Using AI is not forbidden, but it has to be declared — see the University of Tartu guidelines on using AI in teaching and studies.
There is also a narrower point, which this course is partly about. A language model will write you code that runs and produces a number. Whether that number answers the question you asked is not something it can tell you, and not something you can see by looking at the output. Everything in these materials about checking your work — the limits of a scale, comparing a result against what it would be if nothing were going on, reading the residuals — applies with more force, not less, when the code was not written by you.
Using these materials
These materials are published under the CC BY 4.0 licence.
They may be freely used, copied, shared and adapted — in teaching and elsewhere — provided the author is cited:
Mölder, M. (2026). Quantitative Methods I: seminar materials. University of Tartu.
This covers the materials themselves: the text, the code examples and the figures.
The data is not covered by that licence. CSES sets its own terms, and the citation requirement given in The data applies whenever the data is used, whether on its own or together with these materials.