Worksheet 2 - Basic statistics

Basic statistics references

  • Fowler et al. (1998) -Chpts 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, & 16 (16.1, 16.2, 16.3, 16.9,16.11-16.14)
  • Holmes et al. (2006) - Chpt 4 & Sections 7.1-7.3 & 8.1-8.3
  • Quinn & Keough (2002) - Chpt 1, 2, 3 & 4

Question 1 - Population parameters

The little spotted kiwi (Apteryx owenii) is a very rare flightless bird that is extinct on mainland New Zealand and survives as 1000 individuals on Kapiti Island. In order to monitor the population, researches in the recovery team systematically captured all of the individuals in the population over a two week period. Each individual was weighed, banded, assessed and released. The file *.csv lists the weights of each individual male little spotted kiwi in the population.

Format of kiwi.csv data files
BandWeight
649551.749
653182.551
646121.768
643932.327
640922.127
......

BandUnique bird identification band number
WeightWeight (grams) of the individual male birds
Spotted Kiwi

Open the kiwi data file.

Generate a frequency histogram of male kiwi weights. This distribution represents the population (all possible observations) of male kiwi weights.  Note that this is the statistical population and not a biological population - obviously a biological population entirely lacking in females would not last long!

Q1-1.Describe the shape of the distribution?

Since we have the weights of all male kiwi in the population, is possible to calculate population parameters (such as population mean and standard deviation) directly!

Q1-2. What is the mean (a location measure) and standard deviation (a measure of spread) of the population?
  1. Mean
  2. SD

Assuming, the population is normally distributed, it is possible to calculate the probability that a randomly recaptured male kiwi will weigh greater than a particular value, less than a particular value, or weigh between a range of weights. This probability is just the area under a particular region of a normal distribution and can be calculated using the normal probabilities.

Q1-3. Assuming that the population is normally distributed, what is the probability of recapturing a male little spotted kiwi that weighs greater than 2.9 kg?

For data sets with large numbers of observations, the distribution of observations can be examined via a histogram - as demonstrated above. However, histograms are only meaningful for summarizing large data sets. For smaller data sets other exploratory tools (such as boxplots) are necessary. To appreciate the relationship between boxplots and the underlying distribution of data, construct a boxplot of male kiwi weights.

Question 2 - Samples as estimates of populations

Here is a modified example from Quinn and Keough (2002). Lovett et al. (2000) studied the chemistry of forested watersheds in the Catskill Mountains in New York State. They had 38 sites and recorded the concentrations of ten chemical variables, averaged over three years. We will look at two of these variables, dissolved organic carbon (DOC) and hydrogen ions (H).

Format of lovett.csv data files
STREAMDOCH
Hunter180.40.48
West Kill108.80.24
Mill104.70.47
Kelly Hollow84.50.23
Pigeon82.40.37

STREAMName of the site (stream) from which observations were collected
DOCDissolved oxygen concentration (mmol.L-1)
HHydrogen concentration (mmol.L-1)
A river in the Catskill Mountains

Open the lovett data file.

Q2-1. What is the purpose of sampling?

Before continuing, make sure you are clear on what the observations, variables and populations are.

Construct a boxplot of dissolved organic carbon (DOC) from the sample observations.

Q2-2. How would you describe the boxplot?

Q2-3. Are there any outliers? (Y or N)

Provided the data were collected without bias (ideally random) and with adequate replication, the sample should reflect the entire population. Therefore sample statistics should be good estimates of the population parameters.

Q2-4. Calculate the sample mean

The mean of a sample is considered to be a location characteristic of the sample. Along with the mean, it is often desirable to characterize the spread of data in a sample - that is to determine how variable the sample is.

Q2-5. Calculate the sample standard deviation

For most purposes, the sample itself is of little interest - it is purely used to estimate the population. Therefore it is necessary to be able to estimate how well the sample mean estimates the true population mean. The Standard error (SE) of the mean is a measure of the precision of the mean.

Q2-6. Calculate the standard error of the mean

Following on from the idea of precision of the mean, is the concept of confidence intervals, by which an interval is calculated that we are 95% confident will contain the true population mean.

Q2-7. Calculate the 95% confidence interval of the mean +/-

Construct a boxplot of hydrogen concentration (H) from the sample observations

Q2-8. How would you describe the boxplot?

Many statistical analyses assume that the population from which the sample was collected is normally distributed. However, biological data is not always normally distributed. To normalize the data, try transforming to logs.

Q2-9. Does the transformation successfully normalize these data? (Y or N)

Earlier we identified the presence of an outlier in the DOC variable. To investigate the impact of this outlier on a range of summary statistics, calculate the following measures of location (mean and median) and spread (standard deviation and interquartile range) for DOC, with and without the outlying observation and complete the table below.

Summary StatisticDOCModified DOC
Mean
Median
Variance
Standard deviation
Inter-quartile range

Q2-10. Which measures of location and spread are most robust to inclusion and exclusion of a single unusual observation?

Question 3 - Exploratory data analysis

Sánchez-Piñero & Polis (2000) studied the effects of seabirds on tenebrionid beetles on islands in the Gulf of California. These beetles are the dominant consumers on these islands and it was envisaged that seabirds leaving guano and carrion would increase beetle productivity. They had a sample of 25 islands and recorded the beetle density, the type of bird colony (roosting, breeding, no birds), % cover of guano and % plant cover of annuals and perennials.

Format of sanchez.csv data files
COLTYPEBEETLE96GUANOPLANT96
........
........
........

COLTYPEType of bird colony (N = no birds, R = roosting, B = breeding
BEETLE96Abundance of beetles (number per carrion trap) in 1996
GUANO% cover of guano on island in 1995 and 1996
PLANT96% cover of total plants (annual and perennial) on island in 1996
Tenebrionid beetle

Open the sanchez data file.

Q3-1.For percentage plant cover, Calculate the following summary statistics separately for each colony type and complete the table below.

Summary StatisticNo coloniesRoosting colonyBreeding colony
Mean
Variance
Standard deviation
Coefficient of variation

  1. Which colony type has the greatest variance? (N, R or B)
  2. Which is the most variable when corrected for the mean? (N, R or B)

Normality

Before proceeding, make sure you are familiar with the significance of normally distributed sample data and thus why it is necessary to examine the distribution of sample data as part of routine exploratory data analysis (EDA) prior to any formal data analysis.

Q3-2. Construct a boxplot for total 1996 beetle abundance for each colony type separately.
  1. Are there any outliers identified? (Y or N)
  2. Describe the shape of each distribution.
  3. Now transform the response variable to logs and redraw the boxplots, does this change (improve?) the shape of the distributions? (Y or N)

Linearity

Often it is necessary to examine the nature of the relationship or association between variables as part of routine exploratory data analysis (EDA) prior to any formal data analysis. The nature of relationships/associations between continuous data is explored using scatterplots.

Q3-3. Construct a scatterplot for beetle abundance against total 1996 plant cover.
  1. Is there any evidence of non-linearity? (Y or N)
  2. Note, that the boxplots also enable us to explore the normality of both variables (populations). Is there any evidence of non-normality? (Y or N)

Sánchez-Piñero & Polis (2000) measured a number of continuous variables (% cover of guano, % cover or plants and abundance of beetles. Therefore, they might be interested in exploring the relationships between each of these variables. That is, the relationship between guano and plants, guano and beetles, and beetles and plants. While it is possible to create separate scatterplots for each pair (in this case three separate scatterplots), a scatterplot matrix is usually more informative and efficient.

Q3-4. Construct a scatterplot matrix or SPLOM for % of guano, % of plant cover and beetle abundance. Are there any obvious relationships?

Homogeneity of variance

Many statistical hypothesis tests assume that populations are equally varied. For hypothesis tests that compare populations (such as t-tests - see Question 4), it is important that one of the populations is not substantially more or less variable than the other population(s). Thus, such tests assume homogeneity of variance.

Q3-5. Construct an examine boxplots of beetle abundance for each of the three colony types.
  1. Firstly, is there any evidence of non-normality? (Y or N)
  2. Try square-root transforming (preferred over log transformation when applying to count data, since log(0) is not legal) the beetle variable (function is sqrt) and using this transformed variable to reconstruct the boxplots. Note that it may be necessary to perform a forth-root transformation (which performing the square-root transformation twice) in order to normalize this highly skewed data. This can be done using the expression to compute as sqrt(sqrt(BEETLE96)). If this successfully normalizes the data, focus on whether there is any evidence that the populations are equally varied. Is there any evidence that the assumption of homogeneity of variance is violated? (Y or N)
  3. Try calculating the variance or standard deviation of beetle abundance for each colony type separately (remember to use the transformed data, as the raw data was obviously non-normal and non-normality often results in unequal variances). Do these values provide any evidence for unequally varied populations? (Y or N)
  4. The primary concern of the equal variance assumption is that there should not be a relationship between population mean and variance. Use the sample statistics to plot mean against variance for the transformed beetle abundance data. Any evidence of a relationship between mean and variance? (Y or N)

Question 4 - Hypothesis testing

Furness & Bryant (1996) studied the energy budgets of breeding northern fulmars (Fulmarus glacialis) in Shetland. As part of their study, they recorded the body mass and metabolic rate of eight male and six female fulmars.

Format of furness.csv data files
SEXMETRATEBODYMASS
MALE2950875
FEMALE1956765
MALE2308780
MALE2135790
MALE1945788

SEXSex of breeding northern fulmars (Fulmarus glacialis)
METRATEMetabolic rate (hJ/day)
BODYMASSBody mass (g)
Northern fulmars

Open the furness data file.

Q4-1. The researchers were interested in testing whether there is a difference in the metabolic rate of male and female breeding northern fulmars. In light of this, list the following:
  1. The biological hypotheses of interest
  2. The biological null hypotheses
  3. The statistical null hypotheses (H0)

The appropriate statistical test for testing the null hypothesis that the means of two independent populations are equal is a t-test

Before proceeding, make sure you understand what is meant by normality and equal variance as well as the principles of hypothesis testing using a t-test.

Q4-2. For the null hypothesis test of interest (that the mean population metabolic rate of males and females were the same), calculate the Degrees of freedom

Q4-3. Calculate the critical t-values for the following null hypotheses (&alpha = 0.05)
  1. The metabolic rate of males is higher than that females (one-tailed test)
  2. The metabolic rate of males is the same as that of females (two-tailed test)

Since most hypothesis tests follow the same basic procedure, confirm that you understand the basic steps of hypothesis tests.

Q4-4.In the table below, list the assumptions of a t-test along with how violations of each assumption are diagnosed and/or the risks of violations are minimized.

AssumptionDiagnostic/Risk Minimization
I.
II.
III.

So, we wish to investigate whether or not male and female fulmars have the same metabolic rates, and that we intend to use a t-test to test the null hypothesis that the population mean metabolic rate of males is equal to the population mean metabolic rate of females. Having identified the important assumptions of a t-test, use the samples to evaluate whether the assumptions are likely to be violated and thus whether a t-test is likely to be reliability.

Q4.5 Is there any evidence that;
  1. The assumption of normality has been violated?
  2. The assumption of homogeneity of variance has been violated?

Q4-6. Perform a t-test to examine the effect of sex on the mass of fulmars using either (which ever is most appropriate) a pooled variance t-test (for when population variances are very similar) or separate variance t-test (for when the variance of one population is likely to be up to 2.5 times greater or less than the other population). Ensure that you are familiar with the output of a t-test.
  1. What is the t-value? (Excluding the sign. The sign will depend on whether you compared males to females or females to males, and thus only indicates which group had the higher mean).
  2. What is the df (degrees of freedom).
  3. What is the p value.

Q4-7. Write the results out as though you were writing a research paper/thesis. For example (select the phrase that applies and fill in gaps with your results): 
The mean metabolic rate of male fulmars was (choose correct option)
(t = , df = , P = )
the mean metabolic rate of female fulmars.

Q4-8.Construct a bar graph showing the mean metabolic rate of male and female fulmars and an indication of the precision of the means with error bars.

Question 5 - Paired data

Here is a modified example from Quinn and Keough (2002). Elgar et al. (1996) studied the effect of lighting on the web structure or an orb-spinning spider. They set up wooden frames with two different light regimes (controlled by black or white mosquito netting), light and dim. A total of 17 orb spiders were allowed to spin their webs in both a light frame and a dim frame, with six days `rest' between trials for each spider, and the vertical and horizontal diameter of each web was measured. Whether each spider was allocated to a light or dim frame first was randomized. The H0's were that each of the two variables (vertical diameter and horizontal diameter of the orb web) were the same in dim and light conditions. Elgar et al. (1996) correctly treated these as paired comparisons because the same spider spun her web in a light frame and a dark frame.

Format of elgar.csv data files
PAIRVERTDIMHORIZDIMVERTLIGHHORIZLIGH
..........
..........
..........

PAIRName given to each pair of webs spun by a particular spider
VERTDIMThe vertical dimension or height (mm) of webs spun in dim conditions
HORIZDIMThe horizontal dimension or width (mm) of webs spun in dim conditions
VERTLIGHThe vertical dimension or height (mm) of webs spun in light conditions
HORIZLIGHThe horizontal dimension or width (mm) of webs spun in light conditions
Coastal orb-weaving spider
Note:for paired t-tests, categories appear as column labels rather than entries in a categorical variable. Compare the structure of the elgar data (paired t-test) set with that of the furness (standard t-test) data set.

Open the elgar data file.

Q5-1. What is an appropriate statistical test for testing an hypothesis about the difference in dimensions of webs spun in light versus dark conditions? Explain why?

Q5-2. The actual H0 is that the mean of the differences between the pairs (light and dim for each spider) equals zero. Use a paired t-test to test the H0 that the mean of the differences in vertical diameter and separately, in horizontal diameter of the web between the pairs (light and dim for each spider) equal zero.

Q5-3. Write the results out as though you were writing a research paper/thesis. For example (select the phrase that applies and fill in gaps with your results): 
The mean vertical diameter of spider webs in dim conditions was (choose correct option)
(t = , df = , P = )
the vertical dimensions in light conditions.
The mean horizontal diameter of spider webs in dim conditions was (choose correct option)
(t = , df = , P = )
the horizontal dimensions in light conditions.

Question 6 - Non-parametric tests

We will now revisit the data set of Furness & Bryant (1996) that was used in Question 4 to investigate the effects of gender on the metabolic rates of breeding northern fulmars (Fulmarus glacialis). Furness & Bryant (1996) also recorded the body mass of the eight male and six female fulmars they captured.

Since the males and female fulmars were all independent of one another, a t-test would be appropriate to test the null hypothesis of no difference in mean body weight of male and female fulmars.

Q6-1. Are the assumptions underlying this test met? (Y or N) Hint: check the relative sizes of the two sample variances and the distribution of body weight for each sex.

When the distributional assumptions are violated, parametric tests are unreliable. Under these circumstances, non-parametric tests can be very useful.

Q6-2. The Wilcoxon-Mann-Whitney test is described as a non-parametric test for comparing two groups.
  1. What null hypothesis does this test actually evaluate?
  2. What are the underlying assumptions of a Wilcoxon-Mann-Whitney test?

Q6-3. If the assumptions are met, test the null hypothesis of no difference in body weight between male and female fulmars using a Wilcoxon test. Based on this outcome, what are your conclusions?
  1. Statistical:
  2. Biological (include trend):

Q6-4.Construct a bar graph showing the mean mass of male and female fulmars and an indication of the precision of the means with error bars.

Question 7 - Hypothesis testing

The tuatara (Sphenodon punctatum) is the sole surviving member of a group of ancient reptiles that otherwise disappeared 100 million years ago and occurs only in New Zealand. Evolutionary biologist interested in studying rates of evolution in this ancient reptilian lineage, measured the masses of 13 adult males from each of two isolated islets in the Cook Strait. The masses are in the file called tuatara.csv

Format of tuatara.csv data files
ISLETMASS
A467
A971
A783
B448
B395
....

ISLETIslet from which adult male tuataras (Sphenodon punctatum) were captured
MASSBody mass of adult males (g)
Northern fulmars

Open the tuatara data file.

Q7-1. The researchers were interested in testing whether there is a difference in the mass of adult male tuataras from the two Islet populations. In light of this, list the following:
  1. The biological hypotheses of interest
  2. The biological null hypotheses
  3. The statistical null hypotheses (H0)

The appropriate statistical test for testing the null hypothesis that the means of two independent populations are equal is a t-test

Before proceeding, make sure you understand what is meant by normality and equal variance as well as the principles of hypothesis testing using a t-test.

Q7-2. For the null hypothesis test of interest (that the mean population mass of adult male tuataras from Islet A and B were the same), calculate the Degrees of freedom

Q4-3. For the null hypothesis that the population masses are equal, determine the following:
  1. The t-distribution representing all possible t-values
  2. The critical t-value (two-tailed test)

Since most hypothesis tests follow the same basic procedure, confirm that you understand the basic steps of hypothesis tests.

Q7-4.In the table below, list the assumptions of a t-test along with how violations of each assumption are diagnosed and/or the risks of violations are minimized.

AssumptionDiagnostic/Risk Minimization
I.
II.
III.

So, we wish to investigate whether the population mean mass of adult male tuataras from Islet A is equal to that of Islet B, and that we intend to use a t-test to test this null hypothesis. Having identified the important assumptions of a t-test, use the samples to evaluate whether the assumptions are likely to be violated and thus whether a t-test is likely to be reliability.

Q7.5 Is there any evidence that;
  1. The assumption of normality has been violated?
  2. The assumption of homogeneity of variance has been violated?

Q7-6. Perform a t-test to examine the effect of Islet location on the mass of adult male tuataras using either (which ever is most appropriate) a pooled variance t-test (for when population variances are very similar) or separate variance t-test (for when the variance of one population is likely to be up to 2.5 times greater or less than the other population). Ensure that you are familiar with the output of a t-test.
  1. What is the t-value? (Excluding the sign. The sign will depend on whether you compared males to females or females to males, and thus only indicates which group had the higher mean).
  2. What is the df (degrees of freedom).
  3. What is the p value.

Q7-7. Write the results out as though you were writing a research paper/thesis. For example (select the phrase that applies and fill in gaps with your results): 
The mean mass of male tuataras from Islet A was (choose correct option)
(t = , df = , P = )
that of Islet B.

Q7-8.Construct a bar graph showing the mean mass of adult male tuataras from Islet A and B and an indication of the precision of the means with error bars.

Welcome to the end of Worksheet 2