methods and an r package for bayesian inference with log … · 2020. 3. 6. · b. taylor...

24
Motivation Methods An R Package Examples Conculsions/Future Methods and an R package for Bayesian inference with log-Gaussian Cox processes http://cran.r-project.org/web/packages/lgcp Benjamin M. Taylor http://www.lancaster.ac.uk/staff/taylorb1 (Joint work with Tilman Davies, Barry Rowlingson and Peter Diggle) B. Taylor Log-Gaussian Cox Processes

Upload: others

Post on 23-Jan-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Methods and an R package for Bayesianinference with log-Gaussian Cox processeshttp://cran.r-project.org/web/packages/lgcp

Benjamin M. Taylorhttp://www.lancaster.ac.uk/staff/taylorb1

(Joint work with Tilman Davies, Barry Rowlingson and Peter Diggle)

B. Taylor Log-Gaussian Cox Processes

Page 2: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

1 Motivation

2 Methods

3 An R Package

4 Examples

5 Conculsions/Future

B. Taylor Log-Gaussian Cox Processes

Page 3: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Primary Biliary Cirrhosis in Newcastle-Upon-TynePrimary Biliary Cirrhosis in Newcastle-Upon-Tyne (Aggregated)Gastrointestinal Disease SurveillanceBovine Tuberculosis in Cornwall

Spatial Point Process Data

• Primary biliarycirrhosis inNewcastle-Upon-Tyne

• 415geo-referencedcases ofdefinite orprobableprimary biliarycirrhosis (PBC)alive between1987 and 1994.

B. Taylor Log-Gaussian Cox Processes

Page 4: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Primary Biliary Cirrhosis in Newcastle-Upon-TynePrimary Biliary Cirrhosis in Newcastle-Upon-Tyne (Aggregated)Gastrointestinal Disease SurveillanceBovine Tuberculosis in Cornwall

Aggregated Spatial Point Process Data

• Again, Primarybiliary cirrhosisin Newcastle-Upon-Tyne

• This timesuppose weonly observecase numbersaggregated toregions

B. Taylor Log-Gaussian Cox Processes

Page 5: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Primary Biliary Cirrhosis in Newcastle-Upon-TynePrimary Biliary Cirrhosis in Newcastle-Upon-Tyne (Aggregated)Gastrointestinal Disease SurveillanceBovine Tuberculosis in Cornwall

Spatiotemporal Point Process Data

• AscertainmentandEnhancementofGastroentericInfectionSurveillanceStatistics

• Calls to NHSdirect

B. Taylor Log-Gaussian Cox Processes

Page 6: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Primary Biliary Cirrhosis in Newcastle-Upon-TynePrimary Biliary Cirrhosis in Newcastle-Upon-Tyne (Aggregated)Gastrointestinal Disease SurveillanceBovine Tuberculosis in Cornwall

Multivariate Spatial Point Process Data

• 873 genotypedcases of bovinetuberclosisbreakdowns inCornwall herds(1989–2002)

• Is there spatialsegregation?(related topotentialtransmissionmechanisms)

B. Taylor Log-Gaussian Cox Processes

Page 7: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

The log-Gaussian Cox ProcessSpatial Point ProcessBayesian InferenceMCMC

The log-Gaussian Cox Process

Gaussian process: A stochastic process Y (s) where s ∈ Rd is aGaussian process if any finite collection[Y (s1), . . . ,Y (sn)] has a multivariate Gaussiandistribution.

(Spatial/ spatiotemporal) Poisson process: A stochastic processthat counts the number of events in a givenspatial/spatiotemporal region.

Intensity process: a non-negative valued stochastic processΛ : S 7→ [0,∞) where S ⊂ Rd ; typically d = 2 .

Cox process: An inhomogenegous Poisson process with stochasticintensity Λ.

log-Gaussian Cox process: a Cox process where log Λ is aGaussian process

B. Taylor Log-Gaussian Cox Processes

Page 8: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

The log-Gaussian Cox ProcessSpatial Point ProcessBayesian InferenceMCMC

The log-Gaussian Cox Process

If X is a Cox process, then conditional on Λ, we have for any finiteobservation window W ⊆ S

number of X in W ∼ Poisson

(∫W

Λ(s)ds

)

• We think of X as being continuous in space

• In practice, for computational reasons, we treat X aspiecewise constant on a fine grid.

B. Taylor Log-Gaussian Cox Processes

Page 9: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

The log-Gaussian Cox ProcessSpatial Point ProcessBayesian InferenceMCMC

Example: Spatial Point Process

Let X (s) denote the number of events in a grid cell containing s.

X (s) ∼ Poisson[Λ(s)]

Λ(s) = CAλ(s) exp{Z (s)β + Y (s)}

• CA is the area of the grid cell containing s (regular grid).

• Z (s) is a vector of covariates particular to the grid cellcontaining s

• Y (s) is the value of the Gaussian process Y in the grid cellcontaining s

B. Taylor Log-Gaussian Cox Processes

Page 10: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

The log-Gaussian Cox ProcessSpatial Point ProcessBayesian InferenceMCMC

Bayesian Inference

Given some observed data X , we use the posterior density:

π(β,Y , η|X ) ∝ π(X |β,Y , η)π(β,Y , η)

for Bayesian inference.

• η = {σ, φ} are parameters that control the properties of Y(respectively variance and spatial dependence)

• We assume π(X |β,Y , η) = π(X |β,Y )

B. Taylor Log-Gaussian Cox Processes

Page 11: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

The log-Gaussian Cox ProcessSpatial Point ProcessBayesian InferenceMCMC

Markov Chain Monte Carlo

Independent block proposal scheme. A mix of:

• Langevin kernels for Y and β

• A random walk kernel for η

Algorithm tuning:

• Design the proposal covariance using a quadraticapproximation to the posterior.

• Adaptively tune the chain to maintain acceptance rate of0.574 to suit Langevin kernels

B. Taylor Log-Gaussian Cox Processes

Page 12: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Aggregated Spatial Point Process DataSpatiotemporal DataMultivariate Point Process Data

lgcp Log-Gaussian Cox Processes in R

B. Taylor Log-Gaussian Cox Processes

Page 13: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Aggregated Spatial Point Process DataSpatiotemporal DataMultivariate Point Process Data

Aggregated Spatial Point Process Data

• Observe number of events Ti in eachregion Ai

• Augment the list of parameters,{β, η,Y }, with an additional variable N,the unobserved cell count (akin to X )

• Seek to sample from:

π(β, η,Y ,N|T1, . . . ,Tm).

• Use a Gibbs scheme, alternately samplingfrom π(β, η,Y |N,T1:m) andπ(N|β, η,Y ,T1:m)

B. Taylor Log-Gaussian Cox Processes

Page 14: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Aggregated Spatial Point Process DataSpatiotemporal DataMultivariate Point Process Data

Spatiotemporal Point Process DataModel:

X (s, t) = Poisson[R(s, t)]

R(s, t) = CAλ(s, t) exp{Z (s, t)β + Y (s, t)}

• Similar in notation to spatial case: (s, t)instead of (s)

• Assume a separable spatiotemporalcovariance function for Y :

cov[Y (s1, t1),Y (s2, t2)] = σ2 exp{−||s2−s1||/φ−|t2−t1|/θ}.

• θ determines the temporal correlation inthe process Y .

B. Taylor Log-Gaussian Cox Processes

Page 15: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Aggregated Spatial Point Process DataSpatiotemporal DataMultivariate Point Process Data

Multivariate Spatial Point Process Data

Model for multitype process with K types, for k ∈ 1, . . . ,K ,

Xk(s) = Poisson[Rk(s)]

Rk(s) = CAλk(s) exp{Z (s)kβk + Yk(s) + YK+1(s)}

• Xk(s) is the number of events of type kin the computational grid cell containingthe point s

• YK+1 captures areas of high or lowintensity that are common to all types

B. Taylor Log-Gaussian Cox Processes

Page 16: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Convergence/Mixing Diagnostics

R> traceplots(lg)

0 200 400 600 800

0.5

0.6

0.7

0.8

0.9

1.0

Sample No.

σ

0 200 400 600 800

500

1000

1500

Sample No.

φ

0 200 400 600 800

−20

−18

−16

−14

−12

−10

−8

Sample No.

β (In

terc

ept)

0 200 400 600 800

0.8

0.9

1.0

1.1

1.2

1.3

1.4

1.5

Sample No.

β pop

0 200 400 600 800

−25

−20

−15

−10

−5

0

Sample No.

β pro

pmal

e

0 200 400 600 800

−6

−4

−2

02

4

Sample No.

β Inc

ome

R> plot(ltar(lg),lty="s")

0 200 400 600 800 1000

−20

000

−15

000

−10

000

Iteration/900

log

targ

et

B. Taylor Log-Gaussian Cox Processes

Page 17: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Convergence/Mixing DiagnosticsR> parautocorr(lg)

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

log(

σ)

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

log(

φ)

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

β (In

terc

ept)

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

β pop

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

β pro

pmal

e

0 5 10 15 20 25 30

0.0

0.2

0.4

0.6

0.8

1.0

Lag

β Inc

ome

R> lagch <- c(1, 5, 15)

R> Sacf <- autocorr(lg, lagch,

+ inWindow = NULL)

Lag: 1

−1.0

−0.5

0.0

0.5

1.0

5 km

B. Taylor Log-Gaussian Cox Processes

Page 18: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Plots of Prior and Posterior

R> priorpost(lg)

σ

Den

sity

0.2 0.6 1.0 1.4

01

23

45

φ

Den

sity

−500 500 1500 25000.

0000

0.00

100.

0020

β(Intercept)

Den

sity

−25 −15 −5

0.00

0.05

0.10

0.15

0.20

βpop

Den

sity

0.6 1.0 1.4 1.8

01

23

4

βpropmale

Den

sity

−40 −20 0 10

0.00

0.02

0.04

0.06

0.08

0.10

βIncome

Den

sity

−10 −5 0 5 10

0.00

0.05

0.10

0.15

0.20

B. Taylor Log-Gaussian Cox Processes

Page 19: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Tabulate Results

R> parsum <- parsummary(lg, LaTeX = TRUE)

R> require("miscFuncs")

R> latextable(parsum, rownames = rownames(parsum),

+ colnames = c("Parameter", colnames(parsum)), digits = 4)

Parameter median lower 95% CRI upper 95% CRIσ 0.7999 0.6033 0.9695φ 637.1 389.3 1098

exp(β(Intercept)) 4.111×10−7 8.735×10−9 3.019×10−5

exp(βpop) 3.162 2.633 3.84

exp(βpropmale ) 1.328×10−5 3.937×10−9 4.62×10−2

exp(βIncome ) 0.5449 1.425×10−2 23.05exp(βEmployment ) 52.73 0.2343 9981exp(βEducation) 0.9961 0.9797 1.012exp(βBarriers ) 0.982 0.9594 1.007exp(βCrime ) 0.9034 0.6956 1.223

exp(βEnvironment ) 1.015 0.9967 1.035

R> textsummary(lg)

A summary of the parametersof the latent field is as fol-lows. The parameter σ had

median 8×10−1 (95% CRI0.603 to 0.97) and the pa-rameter φ had median 637(95% CRI 389 to 1098).

The following effects werefound to be significant: eachunit increase in propmale ledto a reduction in relativerisk with median 1.33×10−5

(95% CRI 3.94×10−9 to

4.62×10−2); each unit in-crease in pop led to a increasein relative risk with median3.16 (95% CRI 2.63 to 3.84).

The remainder of the . . .

B. Taylor Log-Gaussian Cox Processes

Page 20: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Posterior Correlation Function

R> postcov(lg)

0 5000 10000 15000 20000

0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

Range

Cov

aria

nce

0.5 quantile0.025−0.975 CRI

0 2 4 6 8 10 12 14

0.0

0.2

0.4

0.6

0.8

1.0

Time

Cor

rela

tion

0.5 quantile0.025−0.975 CRI

B. Taylor Log-Gaussian Cox Processes

Page 21: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Exceedance Probabilities

R> ep <- exceedProbs(c(1.5, 2, 5, 10))

R> ex <- lgcp:::expectation.lgcpPredict(lg, ep)

R> plotExceed(ex[[1]], "ep", lg,

+ zlim = c(0,1), asp = 1,

+ axes = FALSE, xlab = "",

+ ylab = "", sub = "")

R> scalebar(5000, label = "5 km")

0.0

0.2

0.4

0.6

0.8

1.0

5 km

P{Relative Risk > 2}

R> sp <- exceedProbs(c(2/3, 1/2, 1/5, 1/10),

+ direction = "lower")

R> su <- lgcp:::expectation.lgcpPredict(lg, sp)

R> plotExceed(su[[1]], "sp", lg,

+ zlim = c(0, 1), asp = 1,

+ axes = FALSE, xlab = "",

+ ylab = "", sub = "")

R> scalebar(5000, label = "5 km")

0.0

0.2

0.4

0.6

0.8

1.0

5 km

P{

Relative Risk <1

2

}

B. Taylor Log-Gaussian Cox Processes

Page 22: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Conditional Probabilities, Segregation Probabilities

Conditional Probabilities:

pk = P{a case at location s is of type k |there is a case at s}

Segmentation Probabilities:

• Let Ak(c , q) denote the set of locations x for whichP{pk(x) > c |X} > q.

• c is the ”dominance probability”

• c , q → 1⇒ Ak(c , p)→ ∅• happens more slowly in a highly segregated pattern compared

with a weakly segregated one

• Compute P{pk(x) > c |X}

B. Taylor Log-Gaussian Cox Processes

Page 23: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Conditional Probabilities, Segregation Probabilities

R> condProbs(lg) R> segProbs(lg,domprob=0.8)

Genotype 9Genotype 12Genotype 15Genotype 20

B. Taylor Log-Gaussian Cox Processes

Page 24: Methods and an R package for Bayesian inference with log … · 2020. 3. 6. · B. Taylor Log-Gaussian Cox Processes. Motivation Methods An R Package Examples Conculsions/Future 1

MotivationMethods

An R PackageExamples

Conculsions/Future

Conclusions

• Four classes of log-Gaussian Cox processes

• A software package, lgcp, for MCMC-based inference forthese models

• . . . more functionality . . .

B. Taylor Log-Gaussian Cox Processes