Ch1 DATA315 2023W2
Ch1 DATA315 2023W2
1
Chapter 1: Introduction
Example 1
Electroless nickel concentrations in a chrome plating process* were
measured at the beginning of each eight hour work shift for a period of
25 days. A concentration of 4.5 ounces per gallon is considered optimal
in this application.
* The chrome plating process is a method of applying a thin layer of chromium onto a substrate
(metal or alloy) through an electroplating procedure.
https://www.sea.org.uk/blog/a-brief-guide-to-the-chrome-plating-process/?doingw pc ron =
1704997548.7409129142761230468750
2
Chapter 1: Introduction
Example 1
* https://rexplating.com/decorative-chrome-plating/
3
Chapter 1: Introduction
Example 1
Question: Interest here is in determining whether the distribution of
concentration measurements changes at any point in time.
4
Concentration (oz./gal.)
5
Chapter 1: Examples
10
Time (days)
15
20
25
5
ACF
0
1
2
3
Lag
Series nickel
4
5
6
## tau = 0.302, 2-sided pvalue =0.00029528
Concentration (oz./gal.)
5
Chapter 1: Examples
10
Time (days)
15
20
25
6
##
## Call:
## lm(formula = NKL ˜ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.45313 -0.10964 -0.01179 0.12733 0.48605
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.481333 0.044843 99.934 < 2e-16
## x 0.010872 0.003016 3.604 0.000569
##
## Residual standard error: 0.1884 on 73 degrees of freedom
## Multiple R-squared: 0.1511,Adjusted R-squared: 0.1394
## F-statistic: 12.99 on 1 and 73 DF, p-value: 0.000569
Chapter 1: Examples
ts.plot(y)
7
y
0
20
Time
40
60
summary(lm(y˜x))
##
## Call:
## lm(formula = y ˜ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.47760 -0.13391 -0.02575 0.12465 0.59900
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.468052 0.048689 91.766 <2e-16
## x -0.001106 0.003275 -0.338 0.737
##
## Residual standard error: 0.2045 on 73 degrees of freedom
## Multiple R-squared: 0.001559,Adjusted R-squared: -0.0121
## F-statistic: 0.114 on 1 and 73 DF, p-value: 0.7366
Chapter 1: Examples
Example 2
The time series of the number of lynx trapped in Hudson’s Bay Company
territory and later Canada in the years from 1821 through 1934.
8
Chapter 1: Examples
Example 2
7000
6000
5000
Number Trapped
4000
3000
2000
1000
0
Time
9
Chapter 1: Examples
Example 2
Notice the periodic behaviour of this time series
10
Chapter 1: Examples
Example 3
Global average temperatures are recorded in terms of number of Celsius
degrees above a baseline temperature. The baseline temperature is the
average temperature for the year 1990.
11
Chapter 1: Examples
Example 3
0.5
Change in Temperature
0.0
−0.5
Time
12
Chapter 1: Examples
Example 3
0.5
Change in Temperature
0.0
−0.5
Time
13
Chapter 1: Examples
Example 3
Question: The main interest in such a series is whether the apparently
increasing trend is simply due to random chance or whether there is a
true structural change in the data.*
Example 4
Plot the daily closing pricess for DAX (German) stock index.
15
Chapter 1: Examples
Example 4
0.05
6000
5000
0.00
closing price
log returns
4000
3000
−0.05
2000
−0.10
16
Chapter 1: Examples
Example 4
Question:
17
Chapter 1: Comparison with Trace Plots from 4 Examples
5.2
6000
Concentration (oz./gal.)
5.0
Number Trapped
4000
4.8
4.6
2000
4.4
4.2
0
5 10 15 20 25 1820 1860 1900
6000
0.5
Change in Temperature
closing price
0.0
4000
−0.5
2000
18
Chapter 1: Time series modelling
5.2
5.0
Concentration (oz./gal.)
4.8
4.6
4.4
4.2
5 10 15 20 25
Time (days)
19
Chapter 1: Time series modelling
When confronted with a new set of time series data, the data analyst typ-
ically proceeds through the following steps:
2. Model identification
3. Parameter estimation
4. Confirmatory analysis
5. Forecasting
20
Chapter 1: Necessary background probability and statistics concepts
21
Chapter 1: Basic features of a probability model
22
Chapter 1: Basic features of a probability model
f (x) = F ′(x).
23
Chapter 1: Probabilty Example
24
Chapter 1: Probabilty Example
• For a given value of α > −1, the function f (x) is nonnegative every-
where, and
Z 1
(α + 1)xαdx = 1
0
.
•
Z x
F (x) = (α + 1)y αdy = xα+1, for x ∈ [0, 1]
−∞
.
25
Chapter 1: Probability Example
26
Chapter 1: Expected value
27
Chapter 1: Expected Value Example
For the density function f (x) = (α + 1)xα, for x ∈ [0, 1], we have
Z 1
α+1
E[X] = x(α + 1)xαdx = . (1)
0 α+2
For the specific case where α = −0.5, this gives E[X] = 1/3. A com-
monly used alternate notation for the mean of a distribution is µ.
28
Chapter 1: Expected Value Example
29
Chapter 1: Expected Value
E[X + a] = E[X] + a.
When g(x) = x2, and the probability density function is as above, we
have
Z 1
α+1
E[X 2] = x2(α + 1)xαdx = .
0 α+3
30
Chapter 1: Example
31
Chapter 1: Variance
32
Chapter 1: Example
33
Chapter 1: Example
Var(X) = E[X 2] − µ2 = σ 2.
34
Chapter 1: Variance
Question:
35
Chapter 1: Variance
• A small value of Var(X) implies that there is more certainty about the
value of X; it will tend to take values close to µ when Var(X) is very
small.
• The distribution will be more spread out when Var(X) is large.
E[X] = E[Y ]
•
Var(X) ̸= Var(y)
36
Chapter 1: Variance
37
Chapter 1: standard deviation
q
• The standard deviation is Var(x).
q
• Both standard deviation and Var(x) quantities summarize the spread
or variability in a probability distribution.
38
Chapter 1: Sample
39
Chapter 1: Calculating the mean from a sample
40
Chapter 1: Calculating the variance from a sample
41
Chapter 1: Modelling more than one random variable
42
Chapter 1: Example
43
Chapter 1: Example
pdf
1
f (x1, x2) = q e−q/2
2πσ1σ2 1 − ρ2
where
1 2 − 2ρz z + z 2 )
q= (z 1 2
1 − ρ2 1 2
44
Chapter 1: Probability calculations
45
Chapter 1: Covariance
46
Chapter 1: Covariance
47
Chapter 1: Correlation
Cov(X1, X2)
ρ = Corr(X1, X2) = q .
Var(X1)Var(X2)
48
Chapter 1: Calculation of covariance and correlation for a sample
For a sample {(x11, x21), (x12, x22), . . . , (x1n, x2n)}, the sample covari-
ance is given by
n
1 X
c= (x1j − x̄1)(x2j − x̄2).
n − 1 j=1
The sample correlation is given by
c
r=
s1 s 2
where s1 and s2 are the sample standard deviations of the samples of
x1’s and x2’s respectively.
49
Chapter 1: Independence
50
Ch1: Expected values of products of independent random variables
E[X1X2] = E[X1]E[X2].
In fact, for any functions g1(x) and g2(x), we have the more general result
that
E[g1(X1)g2(X2)] = E[g1(X1)]E[g2(X2)]
when X1 and X2 are independent.
51
Chapter 1: Maximum likelihood Estimation (MLE)
52
Chapter 1: Example
• The goal is to find the value of θ which maximizes f (x1, x2) at the sam-
pled values of x1 and x2.
53
Chapter 1: Likelihood function
• Let X denote the vector of a random variables, that is X = (X1, X2, · · · , Xn)
• Let x denote the sample (x1, x2, · · · , xn)
• Suppose the density function of x is joint pdf or pmf of a sample,
f (x|θ) = f (x1, x2, · · · , xn|θ). Suppose we know the distribution of the
population, in the joint pdf or pmf function of x
– parameter θ is known
– the variables x is unknown
• Now, we observed the sample, but we don’t know the parameters, then
L(θ; x) = f (x1, x2, · · · , xn; θ) is called likelihood function. It is same
joint pdf or pmf, but unknown is parameter.
54
Chapter 1: Likelihood function in the discrete case
L(θ; x) = Pθ (X = x)
55
Chapter 1: Likelihood function in the discrete case
56
Chapter 1: Likelihood function in the continuous case
L(θ; x) = fθ (x)
57
Chapter 1: Example
58
f(θ; x1=0.2, x2=5)
0.18
0.17
0.16
f(θ)
0.15
0.14
θ
Chapter 1: Example
59
f(θ; x1=0.8, x2=1.5)
0.70
0.65
f(θ)
0.60
0.55
θ
Chapter 1: Example
60
f(θ; x1=0.8, x2=5)
0.58
0.57
0.56
f(θ)
0.55
0.54
θ
Chapter 1: Example
ℓ(θ) = log L(θ) = log(f (θ; x1, x2)) = log(2/3) + log(x1 + θe−θx2 ).
61
Chapter 1: MLE
62
Chapter 1: Large sample properties of maximum likelihood estimators
63