Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Introduction to Biostatistical Analysis
Statistics course for PhD students in Veterinary Sciences
Session 1:
Lecture: Basic concepts
Session 2:
Lecture: Introduction to statistical hypothesis testing
Session 3:
Lecture: Analysis of Variance
Session 4:
Lecture: Regression
Session 5:
Lecture: Synthesis and applications
Lecturer: Lorenzo Marini, PhD
Department of Environmental Agronomy and Crop Production,
University of Padova, Viale dell’Università 16, 35020 Legnaro, Padova.
E-mail: [email protected], Tel.: +39 0498272807, Skype: lorenzo.marini
http://www.biodiversity-lorenzomarini.eu/
1
Introduction to Biostatistical Analysis
Statistics course for first-year PhD students in Agricultural and Forest
Sciences
5 Sessions:
Lecture: theory + Practical: use of R
+
Assessment (at least three sessions attended)
Analysis of an assigned data set and writing a report
Your report should consist of the following 2 items:
1. A 1 page R script fully documenting your analysis.
2. A word document presenting the aims, method of analysis, the results,
and an interpretation.
2
Statistics: Definition
STATISTICS
-Statistical methods can be used to summarize or describe a
collection of data; this is called descriptive statistics.
-In addition, patterns in the data may be modeled from samples,
and then used to draw inferences about the process or population
being studied; this is called inferential statistics.
Statistics = Techniques of
•
Collecting
•
Analysing
•
Drawing conclusions from
DATA
“A mode of thought”
will change the way you do science
3
Statistics: Population and samples
Population: is a set of entities of interest (e.g. PhD students, farms,
bees, fishes, dogs…)
Samples: is a subset of entities randomly drawn from the population
Population 1
Spatial
extent
Samples
Population 2
Statistics answers RESEARCH
questions using samples
4
Inferential statistics: logics
Statistical testing in five steps:
1. Construct a null hypothesis (RESEARCH QUESTION)
E.g. Hypothesis: Does Y hormone concentration depend on age?
2. Choose a statistical analysis
E.g. Regression between [hormone] and age
3. Collect the data (sampling)
E.g. Sampling dogs at different ages
4. Calculate P-value and test statistic
Test of our regression model
5. Reject/accept (Hypothesis) if p is small/large
(ANSWER THE QUESTION)
Common error
Sampling before (1)
constructing the hyp.
and (2) choosing the
statistical analysis
5
Strong vs. weak inference
Weak inference
(Observational)
1. Many hypotheses
2. Correlational
Strong inference
(Experimental)
1. A clear hypothesis
2. A specified test
3. Causal
SEVERAL alternative
hypotheses for
explaining the process
ONE clear testable
hypothesis
What is a hypothesis?
• a statement that is testable
• Testable: can be falsified (K. Popper)
6
KEEP IN MIND!
1. Clearer is the question, easier is the sampling,
simpler is the statistics to be applied
2. If you have blurry and foggy questions and bad design,
you will have to apply complex analyses
Where are you?
Without statistics you cannot write scientific papers
(almost)
7
1. Construct hypotheses: types of variables
Which is/are your response variable/s?
Object of your research (e.g. animal fitness, surgical operation
success, healing time, cow milk production…)
Which is/are your explanatory variable/s?
Variables for explaining your response variable (e.g. age, risk
factors, temperature, hormones, drugs, diet...)
Which are your research questions (hypotheses)?
HYPOTHESIS: a statement that can be falsified
8
1. Construct hypotheses
Univariate analysis
Y
Variables
- One Response variable (Y):
(e.g. Y= Hormone concentration)
- One or more explanatory variables (Xi) (e.g. age, size, breed…)
Multivariate analysis
Variables
Y1 Y2 Y3 Y4 Y5
- More than 1 response variable (Yi)
(e.g. Yi= parameters of horse exercise fitness)
- One or more explanatory variables (xi) (e.g. age, training,
breed, sex, )
9
1. Construct hypotheses
Response Variable
Continuous
Weight, height, length,
temperature, concentration
Count
(Whole
numbers,
integers)
Proportion
Number of individuals,
days, cells (zero is a
common value)
Percentage mortality,
infection rate, proportion
responding to a treatment.
Continuous explanatory Variable
Weight, height, length,
temperature
Scatter plot
10
1. Construct hypotheses
Response Variable
Continuous
Weight, height, length,
temperature, concentration
Count
Number of individuals,
days, cells; zero is a
common value
Proportion
Percentage mortality,
infection rate, proportion
responding to a treatment;
percent leaf area eaten.
Categorical explanatory Variable
Species, Clone,
Genotype, Treatment, Diet,
Growth Chamber, breed
Box-plot
11
2. Choose a statistic analysis
- Univariate analysis: one response variable
Response Variable:
Continuous (normal)
Count (normal or Poisson)
Proportion (normal or binomial)
Distributions
Explanatory Variables:
Continuous:
Regression
Statistical
analyses
Categorical:
Anova
Categorical + continuous:
Ancova, GLMs
- Multivariate analysis: > than one response variable 12
2. Choose a statistic analysis
Parametric statistics
The population is assumed to fit any parameterized distributions.
A probability distribution describes the values and probabilities
that a random event can take place
-Normal
-Poisson
-Gamma
-Binomial…
General Linear Models
(ANOVA, regression, ANCOVA)
Generalized Linear Models GLMs
NB The distribution depends on the
nature of your response variable
Non-parametric statistics
Nonparametric methods are often referred to as ‘distribution free’
methods as they do not rely on assumptions that the data are
13
drawn from a given probability distributions.
2. Choose a statistic analysis
Statistical analysis
Assumptions
Each analysis (even nonparametric) requires to make
some background assumptions
Sampling design
Each analysis requires an
appropriate sampling design
If both these conditions are met
5. We can accept/refuse our hypotheses
14
3. Collect the data (sampling):
Population
Samples
SAMPLING
Key step in any
research
Sampling is that part of statistical practice concerned with the selection
of individual observations intended to yield some knowledge about a
population of concern
Key concepts:
-Randomization
-Replication (no pseudo-replication!!!)
-Independence
15
3. Collect the data: randomization
Population (N)
Sample (n<N)
1
2
3
…
n
Without replacement
A simple random sample is selected so that every
possible sample has an equal chance of being drawn
from the population
Copy and paste in R
###Draw randomly one student among you
students<-seq(1,30) ## assign to each student an ID
students ##show the ID numbers
sample(students,1) ## select randomly one among the 16
hist(replicate(1000,sample(students,1)), breaks=8)
16
3. Collect the data: randomization
Simple randomization is selected so that every possible sample
has an equal chance of being drawn from the population
E.g. arthritis vs. age
Stratified randomization is selected so that every possible sample
has an equal chance of being drawn from each stratum of the
population
E.g. I can stratify per size. Then for each size I
draw randomly dogs of different age
17
3. Collect the data: replication
True replication vs. pseudoreplication
Replication is the repetition of the creation of a
phenomenon so that the variability associated with the
phenomenon can be estimated
n replicates
Degree of freedom
Replicates MUST NOT:
- Come from a time series
- Be grouped in space
- Be repeated measures on the same individuals
- Dependent (but it depends: wait for mixed models!!!)
P
18
3. Collect the data: independence
Population
4 replicates
Random sampling
4 replicates
Independence
Intuitively means that the occurrence of one event makes it
neither more nor less probable that the other occurs. No
meaningful relation between the sampling units
3 MAIN PROBLEMS IN BIOSTATISTICAL ANALYSES
1. Spatial dependence (e.g. spatial autocorrelation)
2. Temporal dependence (e.g. repeated measures)
3. Biological dependence (e.g. siblings)
19
3. Collect the data: spatial dependence
Effect of breed on
milk production
Farm
Cow
SH Hurlbert 1984, Ecological Monographs 54, 187-211
20
3. Collect the data: spatial dependence
Which is your replicate and which is the right scale?
♂
♀
10 birds per sex
15 feathers per bird
18 rats
18 livers
3 samples per liver
2 analyses per tissue sample
21
3. Collect the data: spatial dependence
Which is your replicate and which is the right scale?
♀
Response variable
Feather length
♂
Explanatory variable
Sex (♀ and ♂)
15 measures per bird
22
3. Collect the data: spatial dependence
Which is your replicate and which is the right scale?
E.g. ANOVA
> Bird_level<-aov(feather ~ sex)
df SS
MS
F value
P
sex
1
3.4279
3.42
5.887
0.025 *
Residuals 18 10.4813
0.58
--------------------------------------------------> Feather_level<-aov(feather ~ sex)
sex
Residuals
df
1
298
SS
51.41
242.48
MS
51.41
0.81
F value
63.19
P
3.9e-14 ***
Pseudo-replication!!! Do you have a solution?
23
3. Collect the data: temporal dependence
Temporal dependence: time series & repeated measures
(not covered)
When we measure experimental units repeatedly over time,
we are collecting longitudinal data, also called repeated
measures data.
Time 1
measure 1
Time 2
Time 3
Time 4
measure 2
measure 3
measure 4
24
3. Collect the data: biological dependence
Biological dependence
Unknown genetic relations between sampled units
Individuals belonging to same litter or brood
Litter A
Litter B
Litter C
Drug A
Drug B
Biased sampling (factor + noise)
Proper sampling (2 litter + diet)
25
3. Collect the data (sampling)
If temporal or spatial dependence exists
BEST SOLUTION
To have an appropriate number of replicates at the proper scale
[P.A. Murtaugh 2007. Simplicity and complexity in ecological data analysis. Ecology,
88, 56–62]
ALTERNATIVE SOLUTION
USE OF MIXED MODELS
(they can deal with non-independent data)
Experimental research: easy to control possible confounding
factors
Ecological research: more difficult to apply traditional models.
Modern mixed models with REML estimation (extremely
dangerous analyses!!!)
26
3. Collect the data (sampling)
‘Bad’ design
no replication (you cannot use statistics)
clumped segregation (totally uninformative)
isolative segregation (growth chambers etc.)
systematic (problem: periodic variations)
‘Good’ Designs
randomized block (paired or block design)
completely randomized (if enough time,
space, money)
27
3. Collect the data (sampling)
‘Good’ design (multifactorial ANOVA)
A
C
D
B
D
A
B
C
B
D
C
A
C
B
A
D
Latin square
(Experiments: treatment with few animals
E.g. 4 cows, 4 doses, 4 withdraw times)
Split-plot (very common!)
E.g. Petri dishes
Nested
(especially in medicine)
E.g. liver samples from individual rat
All are ‘good’ designs but all present spatial dependence
We can deal with it using MIXED models
28
3. Collect the data (sampling)
Before sampling you MUST know which is your
REPLICATE and the right SCALE of your study!!!
Sampling with appropriate replication!!!
29
3. Collect the data (sampling)
Manipulative
experiments
Natural
experiments
Observational studies
If we know exactly the
analysis the choice of the
sampling is straightforward
Spatial patterns in the samples
If you don’t work with experiments you
should always consider the spatial patterns
30
in your sampling design
Basic concepts: mean and variance
Body size
MEAN AND VARIANCE
Whereas the mean is a way to describe the location of a
distribution, the variance is a way to capture its scale or
degree of being spread out.
mean
y

mean 
deviance  SS   ( yi  mean)
i
n
var 
 ( yi  mean)
(n  1)
2
sd 
(y
i
 mean)
(n  1)
2
2
31
Basic concepts: Residuals
RESIDUALS
residual
mean
A residual is an observable
estimate of the unobservable
statistical error.
The simplest case involves a
random sample of n men
whose heights are measured.
The difference between the height of each man in the sample
and the observable sample average is a residual.
Residuals represent what we cannot explain
32
Basic concepts: Uncertainty
Population
We normally compute means
using samples. It is not feasible
to measure all the individuals in
a population.
Distribution of single cow milk production)
WHOLE POPULATION
Mean=40
15000
Mean=42
5000
How can we reduce the degree
of uncertainty?
0
Frequency
Mean=39.5
As we work with samples, there
is a degree of UNCERTAINTY
in the estimation.
20
30
40
50
60
33
Milk production
Basic concepts: Law of the Large Numbers
3
As the sample size (n) grows, the sample mean
approaches to the population mean
x
1
2
When is a sample large enough?
Population with mean = 0
SD = 1
-2
-1
0
Run the simulation to answer
0
20
40
60
n = 100
80
100
library(animation)
ani.options(ani.height = 480, ani.width = 600, outdir = getwd(), nmax =100,
interval = 0.1, title = "Demonstration of the Law of Large Numbers",
description = "The sample mean approaches to the population mean as
the sample size n grows.")
ani.start()
par(mar = c(3, 3, 1, 0.5), mgp = c(1.5, 0.5, 0))
lln.ani(FUN = rnorm, mu = 0, np = 50, pch = 20, col.poly = "grey")
ani.stop()
34
Basic concepts: Uncertainty
Standard error (SE)
SD
SE 
n
SE is simply the SD of the probability
distribution of a specific statistic.
E.g. SE of the mean
Confidence intervals (CI)
CI is an interval estimate of a population
parameter. How likely the interval is to
contain the parameter is determined by
the confidence level (95%)
t distribution (n<30)
CI 0.975  mean  t0.975,df  SE
CI 0.025  mean  t0.025,df  SE
Normal distribution (n>30)
CI 0.975  mean  z0.975  SE
CI 0.025  mean  z0.025  SE
35
Basic concepts
DEGREE OF FREEDOM
The number of INDEPENDENT measurements minus
the number of parameters estimated from the data
Df does not correspond to the sum of the single
measures but must be computed on our replicates
The number of the df define the scale of our analyses!!!
Look at the error df to spot pseudo-replication
36
Basic concepts: Distributions
A probability distribution describes the values and probabilities
that a random event can take place
-Probability Density Function (PDF) describes the probability at each
point in the sample space
-Cumulative Distribution Function (CDF) completely describes the
probability distribution of a real-valued random variable X
(PDF)
(CDF)
37
Basic concepts: Why distributions?
We can use distribution in statistics mainly in 2 ways:
1. To model our response variables we need to know its distribution
(assumptions)
2. Once we know the distribution we can run a statistical test
(There are loads of tests to do (F test, t test etc.)
No matter what test we do, the principal is always the same:
-> Calculate a test statistic (e.g. z, t, F) which follows a DEFINED
DISTRIBUTION
-> Look up the critical value related to our level of significance
-> Compare the calculated value with the critical value
->We can then associate a PROBABILITY to our decision
38
Basic concepts: Normal distribution
The normal distribution is ubiquitous in nature and statistics
due to the central limit theorem: every variable that can be
modelled as a sum of many small independent variables is
approximately normal.
39
Basic concepts: Normal distribution
Normal standardized (mean=0, sd=1)
y  y mean
z
sd
f ( z) 
1  z2 / 2
e
2
E.g. Suppose we have measured the heights of 100 people.
The mean height was 170 cm and the sd was 8 cm
• shorter than a particular height?
• taller than a particular height?
• between one specified height and
another?
40
Basic concepts: Poisson distribution
The Poisson distribution, which describes a very large number of
individually unlikely events that happen (count data)
Non-negative values
Variance=mean
Right skewed
1 Parameter: λ (mean=variance)
Use: count data
Sample from a Poisson distribution
(n=1000, mean=variance=0.2)
var = mean
41
Basic concepts: Binomial distribution
The binomial distribution describes the number of
successes in a finite series of independent Yes/No
experiments.
2 Parameters: sample size, probability
Use: proportion data and power analysis
42
What’s R?
R is a system for statistical computation and graphics. It consists
of a language plus a run-time environment with graphics, a
debugger, access to certain system functions, and the ability to
run programs stored in script files.
R has a home page at http://www.R-project.org/.
It is a free software distributed under a GNU-style copyleft, and
an official part of the GNU project (“GNU S”).
43
Why R?
The benefits of R are:
+ R is free. R is open-source and runs on UNIX, Windows and Macintosh
+ R has an excellent built-in help system
+ R has excellent graphing capabilities
+ Students can easily migrate to the commercially supported S-Plus
program if commercial software is desired
+ R's language has a powerful, easy to learn syntax with many built-in
statistical functions
+ The language is easy to extend with user-written functions
+ R is a computer programming
What is R lacking compared to other software solutions?
- It has a limited graphical interface (S-Plus has a good one). This means,
it can be harder to learn at the outset.
- There is no commercial support. (Although one can argue the
international mailing list is even better)
- The command language is a programming language so students must 44
learn to appreciate syntax issues etc.
Appendix 1
Box-plot explanation
45