nl en

Statistical computing with R


Admission requirements

Make sure you have a laptop available during each lecture with the latest version of R and RStudio (for details see Blackboard)

  1. Either you are at least first-year student in the Statistical Science program, or the Computer Science: Data Science specialization and you follow the courses Statistics & Probabiltiy and Generalized Linear Models and Linear Algebra,


  1. You are familiar with elementary calculus and statistics, e.g. integration, derivation, law of large numbers, central limit theorem, probability distributions, z and t-tests, chi-square tests, analysis of variance, generalized linear models (e.g. linear, logistic, and probit regression).


In this course we familiarize students with programming and statistical computation in the R(md) environment. Topics that will be covered include amongst others: datahandling, fitting statistical models, performing statistical tests, producing graphics, reproducible reports, the basics of programming in R and programming basic statistical algorithms.

Course objectives


At the end of the course the student can program in R for the purpose of Statistics and Data Science. The student can recognize several basic statistical problems as statistical computational problems, and translate and solve these problems into R code, and communicate the solutions with reproducible reports set up with R markdown.

Specific objectives:

  • master the basics of R in RStudio;

  • produce reproducible reports using R markdown;

  • perform and implement basic statistical procedures such as tests and analyses;

  • processing raw data into formatted data;

  • visualize data and (intermediate) results;

  • implement resampling methods to evaluate or create statistical tests and algorithms;

Mode of Instruction

A combination of self-study, lectures, lab and live-coding sessions.

Assessment method

The course consists of two examinations. One examination is an home assignment (1/3 of your final grade), the other examination consists of two written tests (2/3 of your final grade).

A = grade of the home assignment
E_1 = grade for first written test 1 (programming exercises for which you should have your own laptop)
E_2 = grade for second written test 2 (programming exercises for which you should have your own laptop)

Your final grade, denoted with G, will be composed as follows

G = A * (1 / 3) + max( E_1 * 0.5 + E_2 * 0.5 , E_2) * (2 / 3)

When you have actively participated in the home assignments and the written exams, then there is the possible to attend in two types of resits: 1) one home assignment resit for both home assignments, and 2) one written resit exam for both written tests.


A_r = the grade for the home assignment.
E_r = the grade for the written resit exam of both written tests.

and let G_r be the final grade that takes into account the resits, then

G_r = max(A, A_r) * (1/3) + max( E1 * 0.5 + E2 * 0.5, E2, E_r) * (2 / 3).

The grades max(A, A_r) and max( E1 * 0.5 + E2 * 0.5, E2, E_r) should be at least a 5.5, and the final grade should be at least a 6 to obtain course credits.

NB. The examinations consist of programming exercises for which your own laptop should be used.

Time and Exam Table

See the Leiden University students' website for the Statistical Science programme -> Schedules 2018-2019

Non-compulsory reading list

A capita selecta (to be announced on blackboard) from the books:

The art of R programming. Norman Matloff, No Starch Press 2011, ISBN: 978-1-59327-384-2

Resampling Methods: A Practical Guide to Data Analysis Phillip I. Good, Birkhauser Boston 2006, 3rd edition, ISBN: 978-0-8176-4386-7

Permutation, Parametric and Bootstrap Tests of Hypotheses Phillip I. Good, Springer Series in Statistics 2005, ISBN: 978-0-387-27158-3.

The Elements of Statistical Learning Trevor Hastie, Robert Tibshirani, and Jerome Friedman, Springer Series in Statistics 2009

Course Registration

Enroll in Blackboard for the course materials and course updates (the blackboard becomes available in the last week of August 2018).

To be able to obtain a grade and the EC for the course, sign up for the (re-)exam in uSis ten calendar days before the actual (re-)exam will take place. Note, the student is expected to participate actively in all activities of the program and therefore participates in and registers for the first exam opportunity.

Exchange and Study Abroad students, please see the Prospective students website for information on how to apply.

Contact information

MKampert [at] math [dot] leidenuniv [dot] nl


  • This is a compulsory course of the Master Statistical Science for the Life and Behavioural sciences / Data Science.

  • This course is a prerequisite for the course Advance Statistical Computing [4433ADSTCY].