Lecture 13 Gaussian Process Models - Part 2 3/06/2018 1 EDA and - - PowerPoint PPT Presentation

โ–ถ
lecture 13
SMART_READER_LITE
LIVE PREVIEW

Lecture 13 Gaussian Process Models - Part 2 3/06/2018 1 EDA and - - PowerPoint PPT Presentation

Lecture 13 Gaussian Process Models - Part 2 3/06/2018 1 EDA and GPs 2 Variogram When fitting a Gaussian process model, it is often difficult to fit the covariance parameters (hard to identify). Today we will discuss some EDA approaches for


slide-1
SLIDE 1

Lecture 13

Gaussian Process Models - Part 2

3/06/2018

1

slide-2
SLIDE 2

EDA and GPs

2

slide-3
SLIDE 3

Variogram

When fitting a Gaussian process model, it is often difficult to fit the covariance parameters (hard to identify). Today we will discuss some EDA approaches for getting a sense of the values for the scale, range and nugget parameters. From the spatial modeling literature the typical approach is to examine an empirical variogram, first we will define the theoretical variogram and its connection to the covariance. Variogram:

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—) โˆ’ ๐‘ (๐‘ข๐‘˜))

where ๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) is known as the semivariogram.

3

slide-4
SLIDE 4

Variogram

When fitting a Gaussian process model, it is often difficult to fit the covariance parameters (hard to identify). Today we will discuss some EDA approaches for getting a sense of the values for the scale, range and nugget parameters. From the spatial modeling literature the typical approach is to examine an empirical variogram, first we will define the theoretical variogram and its connection to the covariance. Variogram:

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—) โˆ’ ๐‘ (๐‘ข๐‘˜))

where ๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) is known as the semivariogram.

3

slide-5
SLIDE 5

Variogram

When fitting a Gaussian process model, it is often difficult to fit the covariance parameters (hard to identify). Today we will discuss some EDA approaches for getting a sense of the values for the scale, range and nugget parameters. From the spatial modeling literature the typical approach is to examine an empirical variogram, first we will define the theoretical variogram and its connection to the covariance. Variogram:

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—) โˆ’ ๐‘ (๐‘ข๐‘˜))

where ๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) is known as the semivariogram.

3

slide-6
SLIDE 6

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-7
SLIDE 7

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-8
SLIDE 8

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-9
SLIDE 9

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-10
SLIDE 10

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-11
SLIDE 11

Some Properties of the theoretical Variogram / Semivariogram

  • are non-negative

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) โ‰ฅ 0

  • are equal to 0 at distance 0

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘—) = 0

  • are symmetric

๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐›ฟ(๐‘ข๐‘˜, ๐‘ข๐‘—)

  • if there is no dependence then

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜))

for all ๐‘— โ‰  ๐‘˜

  • if the process is not stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) + ๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘˜)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

  • if the process is stationary

2๐›ฟ(๐‘ข๐‘—, ๐‘ข๐‘˜) = 2๐‘Š ๐‘๐‘ (๐‘ (๐‘ข๐‘—)) โˆ’ 2 ๐ท๐‘๐‘ค(๐‘ (๐‘ข๐‘—), ๐‘ (๐‘ข๐‘˜))

4

slide-12
SLIDE 12

Empirical Semivariogram

We will assume that our process of interest is stationary, in which case we will parameterize the semivariagram in terms of โ„Ž = |๐‘ข๐‘— โˆ’ ๐‘ข๐‘˜|. Empirical Semivariogram:

ฬ‚ ๐›ฟ(โ„Ž) = 1 2 ๐‘‚(โ„Ž) โˆ‘

|๐‘ข๐‘—โˆ’๐‘ข๐‘˜|โˆˆ(โ„Žโˆ’๐œ—,โ„Ž+๐œ—)

(๐‘ (๐‘ข๐‘—) โˆ’ ๐‘ (๐‘ข๐‘˜))2

Practically, for any data set with ๐‘œ observations there are (๐‘œ

2) + ๐‘œ possible

data pairs to examine. Each individually is not very informative, so we aggregate into bins and calculate the empirical semivariogram for each bin.

5

slide-13
SLIDE 13

Empirical Semivariogram

We will assume that our process of interest is stationary, in which case we will parameterize the semivariagram in terms of โ„Ž = |๐‘ข๐‘— โˆ’ ๐‘ข๐‘˜|. Empirical Semivariogram:

ฬ‚ ๐›ฟ(โ„Ž) = 1 2 ๐‘‚(โ„Ž) โˆ‘

|๐‘ข๐‘—โˆ’๐‘ข๐‘˜|โˆˆ(โ„Žโˆ’๐œ—,โ„Ž+๐œ—)

(๐‘ (๐‘ข๐‘—) โˆ’ ๐‘ (๐‘ข๐‘˜))2

Practically, for any data set with ๐‘œ observations there are (๐‘œ

2) + ๐‘œ possible

data pairs to examine. Each individually is not very informative, so we aggregate into bins and calculate the empirical semivariogram for each bin.

5

slide-14
SLIDE 14

Connection to Covariance

6

slide-15
SLIDE 15

Covariance vs Semivariogram - Exponential

exp cov exp semivar 0.0 0.5 1.0 1.5 2.0 0.0 0.5 1.0 1.5 2.0 0.00 0.25 0.50 0.75 1.00

d y l

1 1.7 2.3 3 3.7 4.3 5 5.7 6.3 7

7

slide-16
SLIDE 16

Covariance vs Semivariogram - Square Exponential

sq exp cov sq exp semivar 0.0 0.5 1.0 1.5 2.0 0.0 0.5 1.0 1.5 2.0 0.00 0.25 0.50 0.75 1.00

d y l

1 1.7 2.3 3 3.7 4.3 5 5.7 6.3 7

8

slide-17
SLIDE 17

From last time

โˆ’2 โˆ’1 1 0.00 0.25 0.50 0.75 1.00

t y 9

slide-18
SLIDE 18

Empirical semivariogram - no bins / cloud

2 4 0.00 0.25 0.50 0.75 1.00

h gamma 10

slide-19
SLIDE 19

Empirical semivariogram (binned)

binwidth=0.1 binwidth=0.15 binwidth=0.05 binwidth=0.075 0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00 1 2 3 1 2 3

h gamma 11

slide-20
SLIDE 20

Empirical semivariogram (binned + n)

binwidth=0.1 binwidth=0.15 binwidth=0.05 binwidth=0.075 0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00 1 2 3 1 2 3

h gamma n

10 20 30 40

12

slide-21
SLIDE 21

Theoretical vs empirical semivariogram

After fitting the model last time we came up with a posterior median of

๐œ2 = 1.89 and ๐‘š = 5.86 for a square exponential covariance.

๐ท๐‘๐‘ค(โ„Ž) = ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) ๐›ฟ(โ„Ž) = ๐œ2 โˆ’ ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) = 1.89 โˆ’ 1.89 exp ( โˆ’ (5.86 โ„Ž)2)

13

slide-22
SLIDE 22

Theoretical vs empirical semivariogram

After fitting the model last time we came up with a posterior median of

๐œ2 = 1.89 and ๐‘š = 5.86 for a square exponential covariance.

๐ท๐‘๐‘ค(โ„Ž) = ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) ๐›ฟ(โ„Ž) = ๐œ2 โˆ’ ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) = 1.89 โˆ’ 1.89 exp ( โˆ’ (5.86 โ„Ž)2)

13

slide-23
SLIDE 23

Theoretical vs empirical semivariogram

After fitting the model last time we came up with a posterior median of

๐œ2 = 1.89 and ๐‘š = 5.86 for a square exponential covariance.

๐ท๐‘๐‘ค(โ„Ž) = ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) ๐›ฟ(โ„Ž) = ๐œ2 โˆ’ ๐œ2 exp ( โˆ’ (โ„Ž ๐‘š)2) = 1.89 โˆ’ 1.89 exp ( โˆ’ (5.86 โ„Ž)2)

binwidth=0.05 binwidth=0.1 0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00 1 2 3

h gamma 13

slide-24
SLIDE 24

Variogram features

14

slide-25
SLIDE 25

PM2.5 Example

15

slide-26
SLIDE 26

FRN Data

Measured PM2.5 data from an EPA monitoring station in Columbia, NJ.

5 10 15 20 Jan 2007 Apr 2007 Jul 2007 Oct 2007 Jan 2008

date pm25 16

slide-27
SLIDE 27

FRN Data

site latitude longitude pm25 date day 230031011 46.682

  • 68.016

8.9 2007-01-03 3 230031011 46.682

  • 68.016

10.4 2007-01-06 6 230031011 46.682

  • 68.016

9.7 2007-01-15 15 230031011 46.682

  • 68.016

7.5 2007-01-18 18 230031011 46.682

  • 68.016

4.6 2007-01-21 21 230031011 46.682

  • 68.016

9.5 2007-01-24 24 230031011 46.682

  • 68.016

9.0 2007-01-27 27 230031011 46.682

  • 68.016

16.2 2007-01-30 30 230031011 46.682

  • 68.016

9.1 2007-02-05 36 230031011 46.682

  • 68.016

19.9 2007-02-11 42 230031011 46.682

  • 68.016

11.5 2007-02-14 45 230031011 46.682

  • 68.016

6.5 2007-02-17 48 230031011 46.682

  • 68.016

14.7 2007-02-23 54 230031011 46.682

  • 68.016

14.1 2007-02-26 57 230031011 46.682

  • 68.016

13.3 2007-03-01 60 230031011 46.682

  • 68.016

8.6 2007-03-04 63 230031011 46.682

  • 68.016

9.0 2007-03-07 66 230031011 46.682

  • 68.016

14.0 2007-03-10 69 230031011 46.682

  • 68.016

8.6 2007-03-13 72 230031011 46.682

  • 68.016

10.3 2007-03-16 75

17

slide-28
SLIDE 28

Mean Model

5 10 15 20 100 200 300

day pm25

## ## Call: ## lm(formula = pm25 ~ day + I(day^2), data = pm25) ## ## Coefficients: ## (Intercept) day I(day^2) ## 12.9644351

  • 0.0724639

0.0001751 ## ## Call: ## lm(formula = pm25 ~ day + I(day^2), data = pm25) ## ## Coefficients: ## (Intercept) day I(day^2) ## 12.9644351

  • 0.0724639

0.0001751

18

slide-29
SLIDE 29

Detrended Residuals

โˆ’5 5 10 100 200 300

day resid

Residuals

19

slide-30
SLIDE 30

Empirical Variogram

binwidth=3 binwidth=6 100 200 300 100 200 300 10 20 30 40

h gamma n

50 100 150 200

20

slide-31
SLIDE 31

Empirical Variogram

binwidth=6 binwidth=9 50 100 150 50 100 150 5 10 15

h gamma n

100 150 200

21

slide-32
SLIDE 32

Model

What does the model we are trying to fit actually look like?

๐‘ง(๐‘ข) = ๐œˆ(๐‘ข) + ๐‘ฅ(๐‘ข) + ๐œ—(๐‘ข)

where

๐‚(๐ฎ) = ๐›พ0 + ๐›พ1 ๐ฎ + ๐›พ2 ๐ฎ2 ๐ฑ(๐ฎ) โˆผ ๐’ฃ๐’ฌ(0, ๐šป) ๐œ—(๐‘ข) โˆผ ๐’ช(0, ๐œ2

๐‘ฅ)

22

slide-33
SLIDE 33

Model

What does the model we are trying to fit actually look like?

๐‘ง(๐‘ข) = ๐œˆ(๐‘ข) + ๐‘ฅ(๐‘ข) + ๐œ—(๐‘ข)

where

๐‚(๐ฎ) = ๐›พ0 + ๐›พ1 ๐ฎ + ๐›พ2 ๐ฎ2 ๐ฑ(๐ฎ) โˆผ ๐’ฃ๐’ฌ(0, ๐šป) ๐œ—(๐‘ข) โˆผ ๐’ช(0, ๐œ2

๐‘ฅ)

22

slide-34
SLIDE 34

JAGS Model

gp_exp_model = โ€model{ y ~ dmnorm(mu, inverse(Sigma)) for (i in 1:N) { mu[i] <- beta[1]+ beta[2] * x[i] + beta[3] * x[i]^2 } for (i in 1:(N-1)) { for (j in (i+1):N) { Sigma[i,j] <- sigma2 * exp(- pow(l*d[i,j],2)) Sigma[j,i] <- Sigma[i,j] } } for (k in 1:N) { Sigma[k,k] <- sigma2 + sigma2_w } for (i in 1:3) { beta[i] ~ dt(0, 2.5, 1) } sigma2_w ~ dnorm(10, 1/25) T(0,) sigma2 ~ dnorm(10, 1/25) T(0,) l ~ dt(0, 2.5, 1) T(0,) }โ€ 23

slide-35
SLIDE 35

Posterior - Betas

beta[1] beta[2] beta[3] 250 500 750 1000 5 10 15 โˆ’0.10 โˆ’0.05 0.00 0.05 0.10 0.15 โˆ’4eโˆ’04 โˆ’2eโˆ’04 0e+00 2eโˆ’04

.iteration estimate term

beta[1] beta[2] beta[3]

24

slide-36
SLIDE 36

Posterior - Covariance Parameters

l sigma2 sigma2_w 250 500 750 1000 3 6 9 12 5 10 15 20 25 5 10 15

.iteration estimate term

l sigma2 sigma2_w

25

slide-37
SLIDE 37

Posterior - Covariance Parameters

l sigma2 sigma2_w 3 6 9 12 5 10 15 20 25 5 10 15 0.00 0.05 0.10 0.15 0.00 0.02 0.04 0.06 2 4 6

estimate density term

l sigma2 sigma2_w

26

slide-38
SLIDE 38

Posterior

term post_mean post_med post_lower post_upper beta[1] 6.922 7.624

  • 0.720

14.369 beta[2]

  • 0.015
  • 0.018
  • 0.091

0.092 beta[3] 0.000 0.000 0.000 0.000 l 0.462 0.021 0.007 5.303 sigma2 9.862 9.284 1.610 20.555 sigma2_w 10.748 11.239 3.832 14.693

27

slide-39
SLIDE 39

Empirical + Fitted Variogram

binwidth=3 binwidth=6 50 100 150 50 100 150 5 10 15 20

h gamma 28

slide-40
SLIDE 40

Fitted Model + Predictions

5 10 15 20 100 200 300

day pm25 29

slide-41
SLIDE 41

Empirical Variogram Model

binwidth=3 binwidth=6 50 100 150 50 100 150 5 10 15

h gamma 30

slide-42
SLIDE 42

Fit

binwidth=3 binwidth=6 50 100 150 50 100 150 5 10 15

h gamma 31

slide-43
SLIDE 43

Predictions

5 10 15 20 100 200 300

day pm25 32

slide-44
SLIDE 44

Full Posterior Predictive Distribution

33

slide-45
SLIDE 45

Plug in Prediction

l = filter(post, term == 'l') %>% pull(post_med) sigma2 = filter(post, term == 'sigma2') %>% pull(post_med) sigma2_w = filter(post, term == 'sigma2_w') %>% pull(post_med) beta0 = filter(post, term == 'beta[1]') %>% pull(post_med) beta1 = filter(post, term == 'beta[2]') %>% pull(post_med) beta2 = filter(post, term == 'beta[3]') %>% pull(post_med) reps=1000 x = pm25$day y = pm25$pm25 x_pred = 1:365 + rnorm(365, 0.01) mu = beta0 + beta1*x + beta2*x^2 mu_pred = beta0 + beta1*x_pred + beta2*x_pred^2 dist_o = fields::rdist(x) dist_p = fields::rdist(x_pred) dist_op = fields::rdist(x, x_pred) dist_po = t(dist_op) cov_o = sq_exp_cov(dist_o, sigma2 = sigma2, l = l) + nugget_cov(dist_o, sigma2 = sigma2_w) cov_p = sq_exp_cov(dist_p, sigma2 = sigma2, l = l) + nugget_cov(dist_p, sigma2 = sigma2_w) cov_op = sq_exp_cov(dist_op, sigma2 = sigma2, l = l) + nugget_cov(dist_op, sigma2 = sigma2_w) cov_po = sq_exp_cov(dist_po, sigma2 = sigma2, l = l) + nugget_cov(dist_po, sigma2 = sigma2_w) inv = solve(cov_o, cov_op) cond_cov = cov_p - cov_po %*% inv cond_mu = mu_pred + t(inv) %*% (y - mu) pred = cond_mu %*% matrix(1, ncol=reps) + t(chol(cond_cov)) %*% matrix(rnorm(length(x_pred)*reps), ncol=reps) 34

slide-46
SLIDE 46

Full Posterior Predictive Distribution

Our posterior consists of samples from

๐‘š, ๐œ2, ๐œ2

๐‘ฅ, ๐›พ0, ๐›พ1, ๐›พ2 | ๐ณ

and for the purposes of generating the posterior predictions we sampled

๐ณ๐‘ž๐‘ ๐‘“๐‘’ | ๐‘š(๐‘›), ๐œ2(๐‘›), ๐œ2

๐‘ฅ (๐‘›), ๐›พ0 (๐‘›), ๐›พ1 (๐‘›), ๐›พ2 (๐‘›), ๐ณ

where ๐‘š(๐‘›), โ€ฆ , ๐›พ2

(๐‘›), etc. are the posterior median of that parameter.

In practice we should instead be sampling

๐ณ(๐‘—)

๐‘ž๐‘ ๐‘“๐‘’ | ๐‘š(๐‘—), ๐œ2(๐‘—), ๐œ2 ๐‘ฅ (๐‘—), ๐›พ0 (๐‘—), ๐›พ1 (๐‘—), ๐›พ2 (๐‘—), ๐ณ

since this takes into account the additional uncertainty in the model parameters.

35

slide-47
SLIDE 47

Full Posterior Predictive Distribution

Our posterior consists of samples from

๐‘š, ๐œ2, ๐œ2

๐‘ฅ, ๐›พ0, ๐›พ1, ๐›พ2 | ๐ณ

and for the purposes of generating the posterior predictions we sampled

๐ณ๐‘ž๐‘ ๐‘“๐‘’ | ๐‘š(๐‘›), ๐œ2(๐‘›), ๐œ2

๐‘ฅ (๐‘›), ๐›พ0 (๐‘›), ๐›พ1 (๐‘›), ๐›พ2 (๐‘›), ๐ณ

where ๐‘š(๐‘›), โ€ฆ , ๐›พ2

(๐‘›), etc. are the posterior median of that parameter.

In practice we should instead be sampling

๐ณ(๐‘—)

๐‘ž๐‘ ๐‘“๐‘’ | ๐‘š(๐‘—), ๐œ2(๐‘—), ๐œ2 ๐‘ฅ (๐‘—), ๐›พ0 (๐‘—), ๐›พ1 (๐‘—), ๐›พ2 (๐‘—), ๐ณ

since this takes into account the additional uncertainty in the model parameters.

35

slide-48
SLIDE 48

Full Posterior Predictive Distribution - Plots

Iter.4 Iter.5 Iter.6 Iter.1 Iter.2 Iter.3 100 200 300 100 200 300 100 200 300 10 20 10 20

day pm25 iter

Iter.1 Iter.2 Iter.3 Iter.4 Iter.5 Iter.6

36

slide-49
SLIDE 49

Full Posterior Predictive Distribution - Median + CI

5 10 15 20 100 200 300

day pm25 37