Statistics 1 (MATH11400) unit website Statistics 1 - (MATH11400) - 2019


Lectures are taking place on Tuesdays 9-10 (PHYS BLDG 1.11 TYNDALL) and Fridays 12-13 (PHYS BLDG 1.11 TYNDALL).

There are bi-weekly one hour tutorials, as in teaching block 1, starting in week 14--check your calendar.

R plays an important role in the course and being able to programme is definitely a plus on the job market.

Fortnightly homework involves coding using the statistical software package R (embedded in R studio).

There will be a computing assignment to complete during Weeks 19 and 20. This will count 10% towards your final mark.

R support will be provided fortnightly by Samuel Touchard, in room G9 (main Mathematics building). Your time slot should appear in your electronic calendar. These sessions will start in week 13 and you are encouraged to attend from the beginning to familiarize yourself with the R studio interface--do not leave this till the last minute.

Additional R information can be found below.

Formal details of this course are available on the unit description page.

Drop-in sessions: Tuesdays, right after the lecture. I will be in my office (Room 4.1, main building) if you would like to ask about the course.

Lecture notes and homework

Paper copies of the lecture notes are distributed at the beginning of the course only, together with the problems sheets.

With n=14,16,18,20 and 22, homework n is to be handed in to your tutor in week n and covers the material of weeks n-1 and n-2 (except for week 14!).

Solutions to the problems sheets will be made available in week n+1.

Lecture notes (with gaps filled in the lectures by me) will be made available at the end of each week.

This should not give you a false sense of security and encourage you to miss lectures. Experience shows that attending lectures is the best way to remain engaged with the material covered in this course.

There are 10 weeks of lectures, followed by revision sessions.

Week 13 (starting 28/1)
Week 14 (starting 4/2)
Week 15 (starting 11/2)
Week 16 (starting 18/2)
Week 17 (starting 25/2)

Week 18 (starting 4/3)
Week 19 (starting 11/3)
Week 20 (starting 18/3)

Week 21 (starting 25/3)
Week 22 (starting 1/4)

Week 24 problems sheet solutions.

If you misplace your lecture notes here is a pdf file of the lecture notes, with gaps. I will not provide you with a second set of printed lecture notes.

R support

We use the open-source Statistical Computing Environment R, whose homepage is This gives access to the source code, which you can also get directly at, and also to documentation. We will be using R studio, which provides a nice and intuitive environment.

R support will be provided for the first 6 weeks by Samuel Touchard, in room G9 (main Mathematics building). However the best way is to use free resources available from the internet.

You might be interested in the document 
An Introduction to R, which despite its name is fairly comprehensive and goes far beyond what you are expected to learn in year 1. For a more gentle introduction, try R: A self-learn tutorial written for undergraduates or Simon Wood's book

When you become an R power-user, you will want to access the contributed packages on CRAN, the Comprehensive R Archive Network (see below how to install packages).

Installing R studio

R studio should already be installed on the School of Mathematics computers. The basic version is free, and you may want to install it on your own computer (Windows/Mac/Linux). Note that R is also available on the School computers, but you should use R studio. You can get an idea of how the interface looks like when you open it here.

R homework

In order to ease your work and that of your tutor, you are asked to prepare your answers to the homework R questions using the R package knitr. This will allow you to produce neat documents similar to Problems sheet 0, where your code, comments and output appear together. You should take this seriously as you will be asked to hand in your R homework and assignment in this format. This may be used in subsequent years in statistical units in order to produce reports.

Note that this concerns your R code and associated comments only--for the rest of your homework you should use pen and paper, and hand this in to your tutor directly.

Installing packages

What makes R very useful to statisticians is that there are numerous packages developed by others in order to solve various statistical problems, and available to you. Not all packages are available by default, and must therefore be installed when needed. You can install a package by clicking on the "Tools" menu, and then click "Install Packages" (see the knitr example below).

Note that depending on the default setup of your computer other libraries may be needed. You will discover this when you run (execute) your code or when you try to use knitr (see below) and messages will appear in the Console warning you that libraries are missing.

Installing knitr

In order to produce documents similar to Problems sheet 0, you should ensure that the knitr library is installed in R studio--this is simple and just requires a few clicks.

Note however that you may have to go through some the steps below every time you use a computer in G9. This is unfortunate, but beyond my control.

To check whether knitr is already installed you can type help(knitr) in the console. If a help page for knitr appears in the Help tab then there is no need to install knitr, and you can start your homework. Otherwise,

On macOS and Windows
  1. In the menu "Tools" click "Install Packages"
  2. A pop-up menu appears and you should type "knitr" in the "Packages" field.
  3. Click "Install" -- if a message appears saying that knitr is already installed, then simply cancel. 
Note that you will have to type library(knitr) in the console to use the package.
In some cases you may have to restart R studio for the library to work (more below).

Preparing your answers to the homework R questions

You should first download and save the template in your favourite folder (right click on the link and choose the right option in the menu) change its name to yoursurname-yourfirstname-HW-XX.Rmd, where XX is the homework number, and open this file in R studio. Note that depending on how it is set up, your browser may save your file with a different extension (e.g. .txt), which you should change to .Rmd

In R studio go into "File" and click "Open File" and look for the file you have just saved. If you just want to check whether knitr and R studio are properly set up you can go to "Exporting your work..." below directly. Otherwise...

You can type your code in the relevant places (see the examples in the template)

and, where relevant, add your comments in the blanks indicated as


It is important that you insert your R code between ```{r} and ```

Note that you can test your code line by line in the console, check variable values etc., by simply cutting and pasting into the console, or more conveniently you can click the green triangle in the top right corner of the editor to execute the code. The latter will run your code in the corresponding "chunk" and insert the output right after.

Do not forget to save your work regularly!!

Exporting your work in a document and handing it in

The simplest methods consists of exporting as a pdf or Word (if installed on your computer-- it is installed on School of Mathematics computers) or an html document (I discourage  you from using this option). You can get these options by clicking on the wool ball to get the drop down menu, and then select a method. You can then save this document and save a copy as a pdf file (option available in Word in "Save as", followed by changing the format to pdf). In some cases R may ask to install additional packages, just say "yes" or install them by hand if the message is a warning.

Following some tests it seems that you may have to install a subset of the following packages:
Word: backports, stringi, magrittr and tinytex
Pdf (tex): knitr

If you decide to export in a pdf file directly from R studio on your own computer, you will have to make sure that Miktex (Windows) or Mactex (Apple) is installed (these are not R packages and you should just follow the links).  Both are free, but this may add an extra layer of complication for you. There should not be any need to do this on the computers in G9 in the School of Mathematics.

Note that on computers (in fact terminals) in G9 it may take a while for the document to appear on your screen the first time you run this.

In order to limit paper usage you are strongly encouraged to submit your R homework via Blackboard or via a shared folder set up by your tutor. Your tutor will let you know what their preferred method is.

Do not send your homework by email, unless instructed to do so.

Here is how to submit your homework via Blackboard:

  1. Go to the Probability and Statistics Blackboard course page.
  2. Click on ‘Statistics Assessments’ on the left-hand navigation pane.
  3. Upload your homework in the relevant week.

R demos

You can find a set of R demos which illustrate some of the concepts covered in the lecture notes here. This is under repair!


Statistics 1 - (MATH11400)