\documentclass[a4paper, 12pt]{article}

\renewcommand{\Pr}{\mbox{Pr}}
\renewcommand{\>}{$>$}

\begin{document}
\begin{Large}

\begin{LARGE}\begin{center}
MTMG37 Class Exercises\\\vspace{5mm}
Data analysis for weather and climate research\\
\end{center}\end{LARGE}
\vspace{10mm}

These exercises are designed to help you to understand the concepts
introduced in the lectures and to learn how to conduct, interpret and
present basic statistical analyses.  They are intended to be completed
in order (later exercises assume knowledge acquired in earlier ones)
and each exercise assumes that you have studied the corresponding
chapter of the lecture notes.
\begin{itemize}
\item Computing sessions: 2--5pm Thursday, weeks 17--20,\\
      in Agriculture Building, Room GL20.
\end{itemize}
The exercises can be completed according to the following schedule:
\begin{center}\begin{tabular}{l|c|c|c|c}
Week & 17 & 18 & 19 & 20 \\ \hline
Exercise & 1, 2 & 3, 4 & 5, 6 & 7, 8, 9 \\
\end{tabular}\end{center}
They will not be marked, but example solutions will be provided at the
end of each computing session.  Make sure that you collect a copy.  I
strongly recommend that during the computing sessions you concentrate
on the exercises, and work on the assignment in your own time.\\

\noindent Chris Ferro (Tutor)\hfill\verb|c.a.t.ferro@reading.ac.uk|

\newpage

\section*{Exercise 1.  Introduction}

\begin{enumerate}
\item Create a new directory for your work on this module.  Visit the
      module web-site via\\ \verb|www.met.rdg.ac.uk/cag/courses|\\ and
      download the datasets \verb|atldjf.txt| etc.
\item Open MINITAB (Start \> Statistics \> MINITAB 13 for Windows \>
      MINITAB) and familiarise yourself with the help pages (Help \>
      Help).
\item Read the data in the file \verb|temp.txt| into MINITAB.  (File
      \> Open Worksheet)
\item Produce a boxplot and a histogram of the daily mean temperatures
      in column C1 (Graph \> Boxplot; Graph \> Histogram).  What do
      these plots tell you about the shape of the distribution?  Are
      there any unusual values?  If so, can you explain their
      occurrence?  How will this affect your analysis?
\item Reproduce the histogram with the width of the intervals equal to
      5 degrees (Graph \> Histogram \> Options).  Does this affect
      your view of the distribution?  What implications does this have
      for plotting data?
\item Compute the mean and standard deviation of the daily mean
      temperatures in column C1 (Calc \> Column Statistics).  Compute
      the median, quartiles, range and inter-quartile range (Stat \>
      Basic Statistics \> Display Descriptive Statistics).  What do
      these statistics tell you about the data?  There are some
      missing values in the data: why do you think they occurred?  How
      does this affect your analysis?
\item Minimise MINITAB and open a Word document (Start \> Microsoft
      Office \> Microsoft Word).  Write a short summary of your
      analysis so far, including your answers to the earlier questions
      and any other conclusions you have drawn.  To include figures in
      your report, return to MINITAB, right click on the window
      containing the plot and select Copy Graph.  Return to Word and
      paste the graph onto the document (Edit \> Paste Special).
\item Visit the \verb|stats@met| web-site\\
      \verb|www.met.rdg.ac.uk/cag/stats|\\
      and follow the link to the `Rice Virtual Lab in Statistics'.
      Try out the demonstrations on `Mean and Median', `Histograms,
      Bin Widths, and Cross Validation' and `Comparing distributions'.
      Browse some of the other links on the \verb|stats@met|
      web-site.\\P.T.O.\newpage
\item Use a calculator, not MINITAB, to complete this question.  For
      each of the age, height and weight datasets in the lectures
      notes (also available in the file \verb|rdgmorph.txt|)
      \begin{enumerate}
      \item compute the mean and standard deviation;
      \item rank the data in increasing order;
      \item compute the median, quartiles, range and inter-quartile
      range; and
      \item describe the shape of the distribution.
      \end{enumerate}
      Record your answers below.
\end{enumerate}

\vspace{1cm}
\begin{tabular}{lccccccc}
       & Mean & SDev & Q1~ & Q2~ & Q3~ & IQR~ & Range \\ \hline
Age    &      &      &     &     &     &      &       \\
Height &      &      &     &     &     &      &       \\
Weight &      &      &     &     &     &      &       \\
\end{tabular}

\vspace{1cm}
The age distribution\ldots\\

\vspace{1cm}
The height distribution\ldots\\

\vspace{1cm}
The weight distribution\ldots\\

\clearpage

\section*{Exercise 2.  Descriptive statistics}

Produce a short report describing the daily {\em minimum} and {\em
  maximum} temperature data in \verb|temp.txt| using something like the
following approach, which can be taken as a template for exploratory
  data analysis more generally.

\begin{enumerate}
\item Make sure that you understand the data.
\item Decide what features of the data to investigate.
\item Decide what statistics and plots to use to do this.
\item Compute the statistics and plots you have chosen.
\item Interpret the results with regard to your chosen aims.
\item Do the results suggest further investigations?  If so, repeat
      steps 2 to 5.  If not, write up your findings.
\end{enumerate}

Any data analysis report should contain the following information: an
explanation of the data, a statement of the investigative aims, a
description of the statistical methods used, a commentary on the
results, and a summary of the conclusions.  Remember that you are
conducting a statistical analysis to enhance understanding, not to
produce page after page of tables and graphs.

If you have time, produce a short report describing the wind-speed
data in \verb|wind.txt| as well.

\clearpage

\section*{Exercise 3.  Probability concepts}

\begin{enumerate}
\item Let $X$ be the random variable representing the outcome of a
      single roll of a fair, six-sided die.  Write down the sample
      space for $X$.  Draw a Venn diagram showing the following three
      events: $A_1$, an odd number; $A_2$, an even number; and $A_3$,
      a number greater than four.
      \begin{enumerate}
      \item What are the values of the probabilities $\Pr(A_1)$,
      $\Pr(A_2)$ and $\Pr(A_3)$?\\

      $\Pr(A_1)=$\\
      $\Pr(A_2)=$\\
      $\Pr(A_3)=$\\

      \item Which pairs of the events do you think are mutually
      independent?  Which pairs do you think are mutually exclusive?
      Find $\Pr(A_1~\mbox{and}~A_2)$, $\Pr(A_1~\mbox{and}~A_3)$ and
      $\Pr(A_2~\mbox{and}~A_3)$, and check which pairs are independent
      and which are exclusive.\\

      $\Pr(A_1~\mbox{and}~A_2)=$\\
      $\Pr(A_1~\mbox{and}~A_3)=$\\
      $\Pr(A_2~\mbox{and}~A_3)=$\\

      \newpage
      \item Find the conditional probabilities $\Pr(A_1 | A_3)$ and
      $\Pr(A_2 | A_3)$.  Are these what you expected?  Compute the
      conditional probabilities $\Pr(A_3 | A_1)$ and $\Pr(A_3 | A_2)$
      using Bayes's Theorem.\\

      $\Pr(A_1 | A_3)=$\\
      $\Pr(A_2 | A_3)=$\\
      $\Pr(A_3 | A_1)=$\\
      $\Pr(A_3 | A_2)=$\\
      \end{enumerate}
\item To get a white Christmas in London there needs to be
      precipitation and the boundary layer needs to be below freezing
      point.  If the probability of precipitation on Christmas day is
      $1/2$ and the probability that the boundary layer will be below
      freezing is $1/3$ then calculate the probability of a white
      Christmas assuming independence of these two events.  If
      observations show that a white Christmas in London happens, on
      average, once every 10 years then calculate the conditional
      probability of precipitation given that the boundary layer is
      below freezing and compare it with the unconditional probability
      of precipitation.\newpage
\item Generate a random sample of size 10 for the random variable $X$
      in question 1 (Calc \> Random Data \> Integers).  Write down the
      proportion of times event $A_3$ occurs.  Repeat for samples of
      sizes 100, 1000, 10\,000 and 100\,000.  Are the results
      consistent with the Law of Large Numbers?\\
      \begin{center}\begin{tabular}{p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}}
       10 & 100 & 1000 & 10\,000 & 100\,000 \\ \hline
          &     &      &         &          \\
      \end{tabular}\end{center}

\item Using your sample of size 100, compute the number of times each
      of the possible values of $X$ occurs (Stat \> Tables \> Tally).
      Compare these with the expected number for each value.  Think of
      some other ways to check that MINITAB is able to generate
      seemingly random numbers, and try them out on your sample.\\
      \begin{center}
      \begin{tabular}{lp{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}}
               & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline
      Observed &   &   &   &   &   &   \\
      Expected &   &   &   &   &   &   \\
      \end{tabular}\end{center}

      \newpage
\item What are the values of the expectation and variance of $X$?\\

      $E(X)=$\\
      $\mbox{Var}(X)=$\\

      Let $Y$ be the random variable representing the outcome of a
      second, {\em independent} roll of the same die.  Write down the
      values of the following quantities without doing any
      calculations.

      \begin{center}\begin{tabular}{p{6cm}p{6cm}}
      $E(X+Y)=$ & $E(XY)=$\\
      $\mbox{Cov}(X,Y)=$ & $\mbox{Cor}(X,Y)=$\\
      $\mbox{Var}(X+Y)=$ & $\mbox{Var}(X-Y)=$\\
      \end{tabular}\end{center}

      \newpage
\item What would you guess is the chance of finding at least two
      people with the same birthday (not necessarily year) out of a
      sample of 30 people?  By counting the number of possible birthdays
      for each person, calculate the probability that all of the 30
      people have different birthdays.  What is the probability
      that two or more of the people share a birthday?  Think of
      reasons for any difference with your guess.  An interactive
      demonstration of this `Birthday Problem' is at\\
      \verb|www-stat.stanford.edu/~susan/surprise|\\
      and an explanation is at\\
      \verb|www.mste.uiuc.edu/reese/birthday|.
\end{enumerate}

\clearpage

\section*{Exercise 4.  Probability distributions}

\begin{enumerate}
\item Generate one sample of size 200 from each of the discrete
      Bernoulli, Binomial and Poisson distributions (Calc \> Random
      Data \> \ldots).  Compare the distributions of each
      sample with suitable plots.  Change the parameters in each of
      the models to see how they influence the distributions.
\item The Binomial distribution is a possible probability model for
      the number of stormy days in a season.  Do you think that
      this is a realistic model?  If there are 120 days in a winter
      and the probability of a stormy day in winter is $1/3$,
      write down the parameters, $n$ and $\pi$, of the Binomial model.
      Write down the expectation and variance of the number of
      stormy days, and compute the probability of a winter having more
      than 40 stormy days (Calc \> Probability Distributions \>
      Binomial).  Generate 100 Binomial variables to represent a
      sequence of 100 winters and plot the simulated data (Graph \>
      Time Series Plot).  What is the average number of stormy days
      simulated?
      \begin{center}\begin{tabular}{p{4cm}p{8cm}}
      $n=$   & $\mbox{Expectation}=$\\
      $\pi=$ & $\mbox{Variance}=$\\
      \end{tabular}\end{center}
      $\mbox{Probability of more than 40 stormy days}=$\\
      $\mbox{Average number of stormy days simulated}=$\\
\item Repeat question 1 with continuous Uniform, Normal and Gamma
      distributions.
\item Compare the three temperature measurements in the file
      \verb|temp.txt| to Normal distributions with means and
      variance set equal to the sample statistics.  Are there any
      noticeable departures from Normality?
\item Use the Normal distribution as a probabilistic model for daily
      mean temperatures at Reading, taking the mean and standard
      deviation of the model equal to the sample statistics.  Find the
      probability that the daily mean temperature exceeds
      15$^\circ$C.  Is this a useful estimate for the proportion of
      days on which mean temperature will exceed 15$^\circ$C in 2004?
\item Try the demonstration `Normal Approximation to the Binomial
      Distribution' in the `Rice Virtual Lab in Statistics'.
\end{enumerate}

\clearpage

\section*{Exercise 5.  Parameter estimation}

\begin{enumerate}
\item Generate 100 samples of size 100 from a Poisson distribution
      with mean 4.  Store the 100 sample means in a separate column
      (Stat \> Basic Statistics \> Store Descriptive Statistics; Manip
      \> Stack \> Stack Rows).  What distribution does the Central
      Limit Theorem say will approximate the distribution of these
      means?  Assess this claim with a suitable plot.

\item Suppose that the daily mean temperature at the Plato Cave
      weather station is precisely a sequence of independent Normal
      random variables with expectation 10$^\circ$C and standard
      deviation 5$^\circ$C.  Generate a sequence of 100 daily mean
      temperatures.  Now pretend that you do not know the true mean of
      the Normal distribution, and calculate a point estimate for it.
      By hand, also compute 90\%, 95\% and 99\% confidence intervals.
      Do any of your intervals contain the true mean?  What is the
      correct interpretation of the intervals?\\

      $\mbox{Point estimate}=$\\
      $\mbox{90\% confidence interval}=$\\
      $\mbox{95\% confidence interval}=$\\
      $\mbox{99\% confidence interval}=$\\

      \newpage
\item Simulate 99 more samples of 100 temperatures and store the 100
      sample means in a separate column.  Calculate the standard
      deviation of your sample means and compare it to the standard
      error that you would expect theoretically.  Compute a 90\%
      confidence interval from each sample, storing the lower and
      upper limits in separate columns.  What proportion of the
      intervals contain the true value, 10$^\circ$C?  What proportion
      would you expect?\\

      $\mbox{Sample standard deviation}=$\\
      $\mbox{Theoretical standard error}=$\\
      $\mbox{Proportion of intervals}=$\\
      $\mbox{Expected proportion}=$\\

      \newpage
\item Store the 100 sample medians in another column.  Compare the
      sampling distributions of the sample means and medians.  What do
      you conclude about properties of the two estimators?  Which
      estimator do you prefer?\vspace{5cm}
\item Carefully work through the demonstrations `Sampling Distribution
      Simulation' and `Confidence Intervals' in the `Rice Virtual Lab
      in Statistics'.
\end{enumerate}

\clearpage

\section*{Exercise 6.  Hypothesis testing}

\begin{enumerate}
\item The file \verb|cloud.txt| contains data collected from a U.S.\
      experiment in the early 1970s that dropped silver nitrate
      crystals from aircraft to `seed' clouds and make rain.  The data
      are the rainfall amounts (in acre-feet!) from a sample of 26
      unseeded clouds and a sample of 26 seeded clouds.  Explore the
      distributions of the two samples, noting any similarities and
      differences.
\item The experimenters want to know if seeding a cloud affects the
      amount of rainfall.  One way to do this is to assess whether or
      not the two samples come from populations with different means.
      Write down the null and alternative hypotheses.  Which
      statistical test can be used to test these hypotheses?  Select
      an appropriate level of significance for the test.
\item What assumptions does your chosen test make about the data?  Are
      these assumptions reasonable for the rainfall data?  If not,
      transform the data (by taking square roots for example) so that
      the test will be appropriate.
      \newpage
\item Compute the test statistic for your test by hand.  Write down
      the distribution of your test statistic and sketch its
      probability density.  Use your statistical tables to determine
      critical regions for your test and add them to your sketch.  Use
      the tables to obtain an approximate $p$-value for your test
      statistic.  Now perform
      the test using MINITAB (Stat \> Basic Statistics), note the
      $p$-value and compare it with
      your chosen level of significance.  Write down clearly what
      conclusion you draw from the test and what this tells the
      experimenters about cloud seeding.
      \newpage
\item Does the result change if you perform the test without
      transforming the data?
\item Shortly after the introduction of the euro coins in 2002, BBC
      on-line news published this article:

      {\it `Meanwhile, two Polish statisticians have discovered
      something about euro coins that should gladden the hearts of
      confidence tricksters.  The coin apparently favours heads.  When
      Tomas Gliszczynski and Waclaw Zawadowski of the Podlaska Academy
      spun one Belgian euro coin 250 times, it came up with
      King Albert's head 140 times.  ``The euro is struck
      asymmetrically,'' Mr Gliszczynski told Germany's Die Welt
      newspaper.  He said he hoped to experiment with German euro
      coins at a maths conference next month.  ``I know the phenomenon
      from other coins like the two zloty piece, which we have thrown
      more than 10,000 times,'' he said.'}\\

      Write a short note describing a statistical test for the
      hypothesis that the Belgian euro is biased given these results,
      and comment on Mr Gliszczynski's claim.
\end{enumerate}

\clearpage

\section*{Exercise 7.  Linear regression}

\begin{enumerate}
\item Read the data in the file \verb|xy.txt| into MINITAB.  Compute
      the sample correlation between $x_1$ and $y_1$ (Stats \> Basic
      Statistics \> Correlation) then repeat for the other three
      pairs.  Record the values in the table below.  Also write down
      what these values tell you about the association between the
      four pairs of $x$ and $y$ variables.  Plot $y_1$ against $x_1$
      (Graph \> Plot) then repeat for the other three pairs.  Do these
      plots change your ideas about the associations?  What
      implications does this have for the interpretation of
      correlations?\\
      \begin{center}\begin{tabular}{lp{2cm}p{2cm}p{2cm}p{2cm}}
      Pair        & 1 & 2 & 3 & 4 \\ \hline
      Correlation &   &   &   &   \\
      \end{tabular}\end{center}

      \newpage
\item Write down a mathematical representation for the
      simple linear regression of each $y$-variable on the
      corresponding $x$-variable.  Make sure that you know which is
      the response variable and which is the explanatory variable.
      Using a calculator instead of MINITAB, estimate the slope and
      intercept parameters in each of the four cases using the
      formulae in the lecture notes.

      \begin{center}\begin{tabular}{p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}}
      Dataset & $\hat{\beta}_0$ & $\hat{\beta}_1$ & $R^2$ & $p$ \\ \hline
            1 &                 &                 &       &     \\
            2 &                 &                 &       &     \\
            3 &                 &                 &       &     \\
            4 &                 &                 &       &     \\
      \end{tabular}\end{center}

      \newpage
\item Now perform the linear regressions with MINITAB (Stat \>
      Regression \> Regression) and check that the parameter estimates
      agree with your calculations.  What are the values of the
      coefficient of determination?  What does this tell you about
      the linear models?  What is the $p$-value for testing whether or
      not the slope is zero?  What do you conclude about the
      explanatory power of the $x$ variable in each case?
\item Compute the residuals from the fitted models and assess the model
      fits by making diagnostic plots.  Are any of the model
      assumptions inappropriate?  Do these plots change your
      conclusion about the explanatory power of the $x$ variable in
      each case?
\end{enumerate}

\clearpage

\section*{Exercise 8.  Multiple regression}

In this exercise we look at the Central England Temperature (CET)
dataset in the file \verb|atldjf.txt|.  The column `cet' contains the
mean winter central England temperature ($^\circ$C) from 1866 to 1997.
Columns C2--C5 contain mean sea-level pressure (SLP) measurements
(hPa) at four locations.  As you work through this exercise you should
compile a short report of your analysis, including the regression
equation for each model that you fit.

\begin{enumerate}
\item Plot CET against year and plot a histogram of the temperatures.
      What features do you notice in the series?  What does the
      distribution look like?
\item One way to assess evidence for a time trend in CET is to fit
      a linear regression of temperature on year.  Fit this model
      using MINITAB and interpret the results.  What do you conclude
      about the changes in CET through time?  Examine any diagnostic
      plots that you consider appropriate and comment on their
      consequences for your model.
\item Now regress CET on just the Iceland SLP and assess the model
      fit.  What does the estimate of the slope parameter say about
      the relationship between CET and Iceland SLP?  Can you explain
      this result scientifically?
\item The plot of residuals against observation order indicates a
      slight, increasing time trend.  Fit the multiple regression of
      CET on Iceland SLP and year.  Examine the significance of the
      two explanatory variables and assess the model fit.  What
      conclusions do you draw now about any time trend in CET?
\item If you have time, experiment by including and excluding
      different SLP series from the regression and compare the fitted
      models.  Also try adding a polynomial time trend by storing
      squared year in a new column.
\end{enumerate}

\clearpage

\section*{Exercise 9.  Time series analysis}

\begin{enumerate}
\item The Darwin SLP data discussed in the lectures is in
      \verb|darwin.txt|.  Plot the data against time.  What can you
      tell about any cycles or long-term time trends?
\item Apply moving average filters of different lengths to obtain a
      clearer view of the long-term trends (Stat \> Time Series \>
      Moving Average).
\item Compute the autocorrelation function up to lag 36 months (Stat
      \> Time Series \> Autocorrelation).  The cyclical behaviour
      indicates the seasonality of the data.  If $X_t$ is the SLP for
      month $t$, plot $X_t$ against $X_{t-12}$ to visualise this
      dependence.
\item Apply the backward difference filter with lag 12 to remove the
      seasonality, then plot the differenced series to obtain a
      clearer view of the inter-annual variations (Stat \> Time
      Series \> Differences).
\item (The final two questions are optional.)  In addition, apply the
      backward difference filter with lag 1 to remove the
      month-to-month dependence and plot the resulting series, which
      we shall call $Y_t$.  This looks like white noise.  If this were
      so, what would you expect the autocorrelation function to look
      like?  Compute the autocorrelation function up to lag 36 and
      interpret the result.
\item The autocorrelation function for $Y_t$ suggests that a
      particular seasonal ARIMA model, with moving average components
      at lags 1 and 12, will be a good description of the Darwin SLP
      series.  Fit this model (Stat \> Time Series \> ARIMA) to the
      Darwin SLP series by selecting a seasonal model with
      period 12, one nonseasonal and one seasonal difference, one
      nonseasonal and one seasonal moving average term, and no
      constant term.  Plot the autocorrelation function and histogram
      of the residuals.  Do the residuals look like white noise?
\end{enumerate}

\end{Large}
\end{document}
