Statistics 1 (MATH11400) unit website Statistics 1 - (MATH11400) - 2017-2018

Overview

Lectures are taking place on Mondays 9-10 (PHYS BLDG G42 POWELL) and Wednesdays 9-10 (BIOMEDICAL BLDG E29).

R plays an important role in the course and being able to programme is definitely a plus on the job market. Have a look at this website if you are not convinced.

R support will be provided for the first 6 weeks by Skevi Michael, in room G9 (main Mathematics building) on Thursdays 11-12 and Fridays 9-10.

Weekly homework involves coding using the statistical software package R.

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

Drop-in sessions: Mondays 10-11, right after the lecture. I will be in my office (Room 4.1) 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.

Problem sheet n, n=1,...,10, covers the material seen in Chapter/Week n and should normally be completed/handed in week n+1.

Solutions to the problems sheets will be made available two weeks after they have been set.

Lecture notes (with gaps filled in the lectures) 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 1 [or 13] (starting 22/1)
Week 2 [or 14] (starting 29/1)
Week 3 [or 15] (starting 5/2)
Week 4 [or 16] (starting 12/2)
Week 5 [or 17] (starting 19/2)--Skevi Michael gives the lecture on 21/2
Week 6 [or 18] (starting 26/2)
Week 7 [or 19] (starting 5/3)
Week 8 [or 20] (starting 12/3)
Week 9 [or 21] (starting 19/3)
Week 10 (starting 16/4)

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 http://www.r-project.org/. This gives access to the source code, which you can also get directly at http://www.stats.bris.ac.uk/R/, 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 Skevi Michael, in room G9 (main Mathematics building) on Thursdays 11-12 and Fridays 9-10. However the best way is to use free resources available from the internet.

You might be interested in the document 
An Introduction to R, despite its name, this is fairly comprehensive. For a more gentle introduction, try R: A self-learn tutorial written for undergraduates or Simon Wood's book. Another good document can be found here---but this is more advanced.

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 computer, but you should use R studio.

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 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).

Installing knitr

In order to make this work, 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,

Note again that on computers in the computer lab (G9)  you may have to define the R_USER variable first. Follow this link for detailed instructions. You may have to restart R studio for this to take effect.

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.
Again the third step may not work on computers in the computer lab if you have not defined the R_USER variable (see above). You may have to restart R studio for the library to work.

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)

```{r}
# INSERT YOUR CODE HERE ...
```
and, where relevant, add your comments in the blanks indicated as

* WRITE DOWN YOUR COMMENTS HERE...

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 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. 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 libraries, just say "yes".

If you decide to export in a pdf file directly from R studio, 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. This seems to be working on the computers in G9 in the School of Mathematics.

Note that on computers 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 can 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 Statistics 1 Blackboard course page.
  2. Click on ‘Homework Submission’ on the left-hand navigation pane.
  3. Upload your homework in the relevant week i.e. Sheet n should be placed in Week n+12, for n=1,...,10.

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!

Textbooks

Statistics 1 - (MATH11400)