You are on page 1of 48

Variance and covariance

Week Number of
patients (X)
1 1
2 2
3 3
4 1
5 4
6 4
7 1
Week Number of
patients (X)
1 1
2 2
3 3
4 1
5 4
6 4
7 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
Week Number of
patients (X)
1 1
2 2
3 3
4 1
5 4
6 4
7 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
=
𝑛
Week Number of Deviation from mean
patients (X) 𝑿−𝑿 ഥ
1 1 1− 2.2857
2 2 2− 2.2857
3 3 3− 2.2857
4 1 1− 2.2857
5 4 4− 2.2857
6 4 4− 2.2857
7 1 1− 2.2857

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
=
𝑛
Week Number of Deviation from mean ഥ
𝑿−𝑿 𝟐
patients (X) 𝑿−𝑿 ഥ
1 1 1− 2.2857 1.653
2 2 2− 2.2857 0.081
3 3 3− 2.2857 0.510
4 1 1− 2.2857 1.653
5 4 4− 2.2857 2.938
6 4 4− 2.2857 2.938
7 1 1− 2.2857 1.653

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
=
𝑛
Week Number of Deviation from mean ഥ
𝑿−𝑿 𝟐
patients (X) 𝑿−𝑿 ഥ
1 1 1− 2.2857 1.653
2 2 2− 2.2857 0.081
3 3 3− 2.2857 0.510
4 1 1− 2.2857 1.653
5 4 4− 2.2857 2.938
6 4 4− 2.2857 2.938
7 1 1− 2.2857 1.653

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
=
𝑛
11.426
= = 1.632
7
Week Number of
patients (X)
1 1
2 2
3 3
4 1
5 4
6 4
7 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
= 𝐸 𝑋2 − 𝐸 𝑋 2
Week Number of
patients (X)
1 1
2 2
3 3
4 1
5 4
6 4
7 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
= 𝐸 𝑋2 − 𝐸 𝑋 2
𝑛
෌𝑖=1 𝑋𝑖 2
= − 𝑋ത 2
𝑛
Week Number of 𝑿𝟐
patients (X)
1 1 1
2 2 4
3 3 9
4 1 1
5 4 16
6 4 16
7 1 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
= 𝐸 𝑋2 − 𝐸 𝑋 2
𝑛
෌𝑖=1 𝑋𝑖 2
= − 𝑋ത 2
𝑛
Week Number of 𝑿𝟐
patients (X)
1 1 1
2 2 4
3 3 9
4 1 1
5 4 16
6 4 16
7 1 1

2
𝑣𝑎𝑟 𝑋 = 𝐸 𝑋 − 𝐸 𝑋
= 𝐸 𝑋2 − 𝐸 𝑋 2
𝑛
෌𝑖=1 𝑋𝑖 2
= − 𝑋ത 2 = 1.632
𝑛
Population
Population Sample
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
𝑣𝑎𝑟 𝑋 =
𝑛
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
𝑣𝑎𝑟 𝑋 =
𝑛
𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
=
𝑛−1
Week Number of Deviation from mean ഥ
𝑿−𝑿 𝟐
patients (X) 𝑿−𝑿 ഥ
1 1 1− 2.2857 1.653
2 2 2− 2.2857 0.081
3 3 3− 2.2857 0.510
4 1 1− 2.2857 1.653
5 4 4− 2.2857 2.938
6 4 4− 2.2857 2.938
7 1 1− 2.2857 1.653

𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
𝑠2 =
𝑛−1
Week Number of Deviation from mean ഥ
𝑿−𝑿 𝟐
patients (X) 𝑿−𝑿 ഥ
1 1 1− 2.2857 1.653
2 2 2− 2.2857 0.081
3 3 3− 2.2857 0.510
4 1 1− 2.2857 1.653
5 4 4− 2.2857 2.938
6 4 4− 2.2857 2.938
7 1 1− 2.2857 1.653

𝑛
෌𝑖=1 𝑋𝑖 − 𝑋ത 2
𝑠2 =
𝑛−1
11.426
= = 1.904
7−1
Sample size = n
𝑥1 , 𝑥2 , ⋯ , 𝑥𝑖 , ⋯ , 𝑥𝑛

𝑛
1
Variance: 𝑠2 = ෍ 𝑥𝑖 − 𝑥ҧ 2
(𝑛 − 1)
𝑖=1

𝑛
1 2
Std. dev: 𝑠= ෍ 𝑥𝑖 − 𝑥ҧ
𝑛−1
𝑖=1
Covariance
Random Variable: X, Y
Measure of joint variability of X and Y
Random Variable: X, Y
Measure of joint variability of X and Y

X
Random Variable: X, Y
Measure of joint variability of X and Y

cov 𝑋, 𝑌 = 𝐸 𝑋 − 𝐸 𝑋 𝑌−𝐸 𝑌
Random Variable: X, Y
Measure of joint variability of X and Y

cov 𝑋, 𝑌 = 𝐸 𝑋 − 𝐸 𝑋 𝑌−𝐸 𝑌

= 𝐸 𝑋𝑌 − 𝐸 𝑋 𝐸(𝑌)
X Y
x1 y1
x2 y2
.. ..
.. ..
xi yi
.. ..
.. ..
xn yn
X Y
x1 y1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
x2 y2
.. ..
.. ..
xi yi
.. ..
.. ..
xn yn
X Y
x1 y1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
x2 y2
.. .. 𝑛
.. .. ෍ 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
xi yi 𝑖=1
.. ..
.. ..
xn yn
X Y
x1 y1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
x2 y2
.. .. 𝑛
.. .. ෍ 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
xi yi 𝑖=1
.. ..
.. ..
xn yn

σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
cov 𝑋, 𝑌 =
𝑛−1
Covariance
• Measure of joint variability of two random
variables.
• Measures the trend of association between
two variables.
Y

X
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − + −
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − + −
𝑋𝑖 > 𝑋ത + − −
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − + −
𝑋𝑖 > 𝑋ത + − −

cov 𝑋, 𝑌 < 0
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − − +
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − − +
𝑋𝑖 > 𝑋ത + + +
Y

𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത 𝑋𝑖 − 𝑋ത 𝑌𝑖 − 𝑌ത
𝑋𝑖 < 𝑋ത − − +
𝑋𝑖 > 𝑋ത + + +

cov 𝑋, 𝑌 > 0
Y cov 𝑋, 𝑌 < 0

Y
cov 𝑋, 𝑌 > 0

X
X and Y are independent

cov 𝑋, 𝑌 = 𝐸 𝑋𝑌 − 𝐸 𝑋 𝐸 𝑌
X and Y are independent

cov 𝑋, 𝑌 = 𝐸 𝑋𝑌 − 𝐸 𝑋 𝐸 𝑌

=𝐸 𝑋 𝐸 𝑌 −𝐸 𝑋 𝐸 𝑌

=0
X and Y are independent: cov 𝑋, 𝑌 = 0
X and Y are independent: cov 𝑋, 𝑌 = 0

cov(X,Y ) = 0 does NOT assure that X and Y


are independent
X and Y are independent: cov 𝑋, 𝑌 = 0

cov(X,Y ) = 0 does NOT assure that X and Y


are independent

𝑋 = 𝑈 −1,1

𝑌 = 𝑋2

cov 𝑋, 𝑌 = 0
Key Points

Calculating variance from sample data


𝑛
1
𝑠2 = ෍ 𝑥𝑖 − 𝑥ҧ 2
(𝑛 − 1)
𝑖=1
Key Points

Covariance measure of joint variability of two


random variables

cov 𝑋, 𝑌 = 𝐸 𝑋 − 𝐸 𝑋 𝑌−𝐸 𝑌

σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
cov 𝑋, 𝑌 =
𝑛−1
Key Points
Covariance is an indicator of association between
two variables.

cov 𝑋, 𝑌 > 0 cov 𝑋, 𝑌 < 0


Key Points

X and Y are independent: cov 𝑋, 𝑌 = 0

cov(X,Y ) = 0 does NOT assure that X and Y


are independent
Guess the value of cov(X,Y) for this data

You might also like