Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical...

46
Beyond the black box: Flexible programming of hierarchical modeling algorithms for BUGS compa=ble models using NIMBLE Colorado State Sta=s=cs seminar February 2016 Christopher Paciorek UC Berkeley Sta=s=cs Joint work with: Perry de Valpine (PI) UC Berkeley Environmental Science, Policy and Managem’t Daniel Turek UC Berkeley Sta=s=cs and ESPM Cliff AndersonBergman Lawrence Livermore Lab (alumnus) Duncan Temple Lang UC Davis Sta=s=cs Funded by NSF DBI1147230 hYp://r nimble.org

Transcript of Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical...

Page 1: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Beyond  the  black  box:      Flexible  programming  of  hierarchical  

modeling  algorithms  for  BUGS-­‐compa=ble  models  using  NIMBLE  

Colorado  State  Sta=s=cs  seminar  February  2016  

Christopher  Paciorek          UC  Berkeley  Sta=s=cs    

Joint  work  with:  Perry  de  Valpine  (PI)              UC  Berkeley  Environmental  Science,  Policy  and  Managem’t  Daniel  Turek                                          UC  Berkeley  Sta=s=cs  and  ESPM  Cliff  Anderson-­‐Bergman  Lawrence  Livermore  Lab  (alumnus)  Duncan  Temple  Lang            UC  Davis  Sta=s=cs  

Funded  by  NSF  DBI-­‐1147230  

hYp://r-­‐nimble.org  

Page 2: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

What  do  we  want  to  do  with  hierarchical  models?  1.  Core  algorithms  •  MCMC  •  Sequen=al  Monte  Carlo  •  Laplace  approxima=on  •  Importance  sampling  

2  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 3: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

What  do  we  want  to  do  with  hierarchical  models?  

2.  Different  flavors  of  algorithms  •  Many  flavors  of  MCMC  •  Gaussian  quadrature  •  Monte  Carlo  expecta=on  maximiza=on  (MCEM)  •  Kalman  Filter  •  Auxiliary  par=cle  filter  •  Posterior  predic=ve  simula=on  •  Posterior  re-­‐weigh=ng  •  Data  cloning  •  Bridge  sampling  (normalizing  constants)  •  YOUR  FAVORITE  HERE  •  YOUR  NEW  IDEA  HERE  

1.  Core  algorithms  •  MCMC  •  Sequen=al  Monte  Carlo  •  Laplace  approxima=on  •  Importance  sampling  

3  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 4: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

What  do  we  want  to  do  with  hierarchical  models?  3.  Idea  combina=ons  •  Par=cle  MCMC  •  Par=cle  Filter  with  replenishment  •  MCMC/Laplace  approxima=on  •  Dozens  of  ideas  in  recent  JRSSB/JCGS  issues  

2.  Different  flavors  of  algorithms  •  Many  flavors  of  MCMC  •  Gaussian  quadrature  •  Monte  Carlo  expecta=on  maximiza=on  (MCEM)  •  Kalman  Filter  •  Auxiliary  par=cle  filter  •  Posterior  predic=ve  simula=on  •  Posterior  re-­‐weigh=ng  •  Data  cloning  •  Bridge  sampling  (normalizing  constants)  •  YOUR  FAVORITE  HERE  •  YOUR  NEW  IDEA  HERE  

1.  Core  algorithms  •  MCMC  •  Sequen=al  Monte  Carlo  •  Laplace  approxima=on  •  Importance  sampling  

4  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 5: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

What  can  a  prac==oner  do  with  hierarchical  models?  Two  basic  so_ware  designs:    1. Typical  R  package  =  Model  family  +  1  or  more  algorithms  •  GLMMs:  lme4,  MCMCglmm  •  GAMMs:  mgcv  •  spa=al  models:  spBayes,  INLA  

2. Flexible  model  +  black  box  algorithm  •  BUGS:  WinBUGS,  OpenBUGS,  JAGS  •  PyMC  •  INLA  •  Stan  

 5  NIMBLE:  extensible  so_ware  for  

hierarchical  models  (r-­‐nimble.org)  

Page 6: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Exis=ng  so_ware  

X(1)   X(2)   X(3)  

Y(1)   Y(2)   Y(3)  

Model   Algorithm  

e.g.,  BUGS  (WinBUGS,  OpenBUGS,  JAGS),  INLA,  Stan,            various  R  packages  

6  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 7: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  The  Goal  

X(1)   X(2)   X(3)  

Y(1)   Y(2)   Y(3)  

Model   Algorithm  language  

7  

+  

=  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 8: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

X(1)   X(2)   X(3)  

Y(1)   Y(2)   Y(3)  

MCMC  Flavor  1  

MCMC  Flavor  2  

Par=cle  Filter  

Importance  Sampler  

Maximum  likelihood  

Quadrature  

MCEM  

Data  cloning  

Your  new  method  

8  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Divorcing  Model  Specifica=on    from  Algorithm  

Page 9: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Background  and  Goals  •  So_ware  for  finng  hierarchical  models  has  opened  their  use  to  a  wide  variety  of  communi=es  

•  Most  so_ware  for  finng  such  models  is  either  model-­‐specific  or  algorithm-­‐specific  

•  So_ware  is  o_en  a  black  box  and  hard  to  extend  •  Our  goal  is  to  divorce  model  specifica=on  from  algorithm,  while  –  Retaining  BUGS  compa=bility  –  Providing  a  variety  of  standard  algorithms  –  Allowing  developers  to  add  new  algorithms  (including  modular  combina8on  of  algorithms)  

–  Allowing  users  to  operate  within  R  –  Providing  speed  via  compila=on  to  C++,  with  R  wrappers  

9  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 10: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

sta=s=cal  model  (BUGS  code)                      +  algorithm  (nimbleFunc=on)  

R  objects  +  R  under  the  hood  

R  objects  +  C++  under  the  hood    ² We  generate  C++  code,  ² compile  and  load  it,  ² provide  interface  object.  

NIMBLE  System  Summary  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   10  

Page 11: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE  

1.  Model  specifica=on    

BUGS  language  è  R/C++  model  object  

2.  Algorithm  specifica=on    NIMBLE  programming  language  within  R  è  R/C++  algorithm  object  

3.  Algorithm  library  

MCMC,  Par=cle  Filter/Sequen=al  MC,  etc.  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   11  

Page 12: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

12  

Page 13: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

1  

>  liYersModel  <-­‐  nimbleModel(liYersCode,  constants  =  list(N  =  16,  G  =  2),  data  =  list(r  =  input$r))  >  liYersModel_cpp  <-­‐  compileNimble(liYersModel)  

liYersCode  <-­‐  nimbleCode({      for(j  in  1:G)  {          for(I  in  1:N)  {  

 r[i,  j]  ~  dbin(p[i,  j],  n[i,  j]);    p[i,  j]  ~  dbeta(a[j],  b[j]);  

         }            mu[j]  <-­‐  a[j]/(a[j]  +  b[j]);            theta[j]  <-­‐  1.0/(a[j]  +  b[j]);            a[j]  ~  dgamma(1,  0.001);            b[j]  ~  dgamma(1,  0.001);    })  

mu

muBlock[1]

muBlock[2]

muBlock[3]

y[1]

y[2]

y[3]

y[4]

y[5]

y[6]

y[7]

y[8]

y[9]

Parse  and  process  BUGS  code.  Collect  informa=on  in    model  object.    

Use  igraph  plot  method  (we  also  use  this  to  determine  dependencies).    

Provides  variables  and  func=ons  (calculate,  simulate)  for  algorithms  to  use.  

13  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

User  Experience:  Crea=ng  a  Model  from  BUGS  

Page 14: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

The  Success  of  R  

14  

Page 15: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

You  give  NIMBLE:  

liYersCode  <-­‐  nimbleCode(  {  for(j  in  1:G)  {          for(I  in  1:N)  {  

 r[i,  j]  ~  dbin(p[i,  j],  n[i,  j]);    p[i,  j]  ~  dbeta(a[j],  b[j]);  

         }            mu[j]  <-­‐  a[j]/(a[j]  +  b[j]);            theta[j]  <-­‐  1.0/(a[j]  +  b[j]);            a[j]  ~  dgamma(1,  0.001);            b[j]  ~  dgamma(1,  0.001);      }  )  

You  get  this:  

>  liYersModel$a[1]  <-­‐  5  >  simulate(liYersModel,  ‘p')  >  p_deps  <-­‐  liYersModel$getDependencies(‘p’)  >  calculate(liYersModel,  p_deps)  >  getLogProb(pumpModel,  ‘r')  

Programming  with  Models  

NIMBLE  also  extends  BUGS:  mul=ple  parameteriza=ons,  named  parameters,  and  user-­‐defined  distribu=ons  and  func=ons.  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   15  

Page 16: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

>  liYersMCMCspec  <-­‐  configureMCMC(liYersModel)  >  liYersMCMCspec$getSamplers()  […snip…]  [3]  RW  sampler;      targetNode:  b[1],    adap=ve:  TRUE,    adaptInterval:  200,    scale:  1  [4]  RW  sampler;      targetNode:  b[2],    adap=ve:  TRUE,    adaptInterval:  200,    scale:  1  [5]  conjugate_beta  sampler;      targetNode:  p[1,  1],    dependents_dbin:  r[1,  1]  [6]  conjugate_beta  sampler;      targetNode:  p[1,  2],    dependents_dbin:  r[1,  2]    [...snip...]    >  liYersMCMCspec$addSampler(‘a[1]’,  ‘slice’,  list(adaptInterval  =  100))  >  liYersMCMCspec$addSampler(‘a[2]’,  ‘slice’,  list(adaptInterval  =  100))  >  liYersMCMCspec$addMonitors(‘theta’)  >  liYersMCMC  <-­‐  buildMCMC(liYersMCMCspec)  >  liYersMCMC_Cpp  <-­‐  compileNimble(liYersMCMC,  project  =  liYersModel)  >  liYersMCMC_Cpp$run(20000)  

16  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

User  Experience:  Specializing  an  Algorithm  to  a  Model  liYersModelCode  <-­‐  modelCode({      for(j  in  1:G)  {          for(I  in  1:N)  {  

 r[i,  j]  ~  dbin(p[i,  j],  n[i,  j]);    p[i,  j]  ~  dbeta(a[j],  b[j]);  

         }            mu[j]  <-­‐  a[j]/(a[j]  +  b[j]);            theta[j]  <-­‐  1.0/(a[j]  +  b[j]);            a[j]  ~  dgamma(1,  0.001);            b[j]  ~  dgamma(1,  0.001);    })  

sampler_slice  <-­‐  nimbleFunc=on(        setup  =  func=on((model,  mvSaved,  control)  {                calcNodes  <-­‐  model$getDependencies(control$targetNode)                discrete  <-­‐  model$getNodeInfo()[[control$targetNode]]$isDiscrete()  […snip…]      run  =  func=on()  {              u  <-­‐  getLogProb(model,  calcNodes)  -­‐  rexp(1,  1)              x0  <-­‐  model[[targetNode]]              L  <-­‐  x0  -­‐  runif(1,  0,  1)  *  width    […snip….]  …  

Page 17: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

>  liYersMCEM  <-­‐  buildMCEM(liYersModel,  latentNodes  =  ‘p’,  mcmcControl  =  list(adaptInterval  =  50),  boxConstraints  =  list(  list(‘a’,  ‘b’),  limits  =  c(0,  Inf))),  buffer  =  1e-­‐6)  >  set.seed(0)  >  liYersMCEM(maxit  =  50,  m1  =  500,  m2  =  5000)  

17  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

User  Experience:  Specializing  an  Algorithm  to  a  Model  (2)  liYersModelCode  <-­‐  quote({      for(j  in  1:G)  {          for(I  in  1:N)  {  

 r[i,  j]  ~  dbin(p[i,  j],  n[i,  j]);    p[i,  j]  ~  dbeta(a[j],  b[j]);  

         }            mu[j]  <-­‐  a[j]/(a[j]  +  b[j]);            theta[j]  <-­‐  1.0/(a[j]  +  b[j]);            a[j]  ~  dgamma(1,  0.001);            b[j]  ~  dgamma(1,  0.001);    })  

buildMCEM  <-­‐  nimbleFunc=on(      while(run=me(converged  ==  0))  {      ….              calculate(model,  paramDepDetermNodes)              mcmcFun(mcmc.its,  ini=alize  =  FALSE)              currentParamVals[1:nParamNodes]  <-­‐  getValues(model,paramNodes)                          op  <-­‐  op=m(currentParamVals,  objFun,  maximum  =  TRUE)              newParamVals  <-­‐  op$maximum    …..  

One  can  plug  any  MCMC  sampler  into  the  MCEM,  with  user  control  of  the  sampling  strategy,  in  place  of  the  default  MCMC.  

Modularity:  

Page 18: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE  

1.  Model  specifica=on    

BUGS  language  è  R/C++  model  object  

2.  Algorithm  specifica=on    NIMBLE  programming  language  within  R  è  R/C++  algorithm  object  

3.  Algorithm  library  

MCMC,  Par=cle  Filter/Sequen=al  MC,  etc.  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   18  

Page 19: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  Programming  With  Models  

We  want:    • High-­‐level  processing  (model  structure)  in  R  

•  Low-­‐level  processing  in  C++  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   19  

Page 20: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  Programming  With  Models  objec=veFunc=on  <-­‐  nimbleFunc=on  (        setup  =  func=on(model,  nodes)  {          calcNodes  <-­‐  model$getDependencies(nodes)      },          run  =  func=on(vals  =  double(1))  {          values(model,  nodes)  <<-­‐  vals          sumLogProb  <-­‐  calculate(model,  calcNodes)                  return(sumLogProb)          returnType(double())      })  

2  kinds  of  func=ons  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   20  

Page 21: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  Programming  With  Models  objec=veFunc=on  <-­‐  nimbleFunc=on  (        setup  =  func=on(model,  nodes)  {          calcNodes  <-­‐  model$getDependencies(nodes)      },          run  =  func=on(vals  =  double(1))  {          values(model,  nodes)  <<-­‐  vals          sumLogProb  <-­‐  calculate(model,  calcNodes)                  return(sumLogProb)          returnType(double())      })  

query  model    structure  ONCE.  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   21  

Page 22: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  Programming  With  Models  objec=veFunc=on  <-­‐  nimbleFunc=on  (        setup  =  func=on(model,  nodes)  {          calcNodes  <-­‐  model$getDependencies(nodes)      },          run  =  func=on(vals  =  double(1))  {          values(model,  nodes)  <<-­‐  vals          sumLogProb  <-­‐  calculate(model,  calcNodes)                  return(sumLogProb)          returnType(double())      })  

the  actual  algorithm  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   22  

Page 23: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

The  NIMBLE  compiler  Feature  summary:  •  R-­‐like  matrix  algebra  (using  Eigen  library)  •  R-­‐like  indexing  (e.g.  X[1:5,])  •  Use  of  model  variables  and  nodes  •  Model  calculate  (logProb)  and  simulate  func=ons  •  Sequen=al  integer  itera=on  •  if-­‐then-­‐else,  do-­‐while  •  Declare  input  &  output  types  only  •  Access  to  much  of  Rmath.h  (e.g.  distribu=ons)  •  Automa=c  R  interface  /  wrapper  •  Many  improvements  /  extensions  planned  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   23  

Page 24: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

How  an  Algorithm  is  Processed  in  NIMBLE  

DSL  code  within  nimbleFunc=on()  

Parse  tree  of  code  

Abstract  syntax  tree  

.Cpp  and  .h  files  in  R  TMPDIR  

DLL  in  R  TMPDIR  

Access  via  wrappers  from  R  

Parse  in  R  

Process  to  a  Reference  Class    in  R  

Wri=

ng  to

 files  from  R  

g++/llvm/etc.  

Genera=on  of  R  wrapper  func=ons  that  use  .Call  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   24  

Page 25: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Programmer  experience:  Random  walk  updater  sampler_myRW  <-­‐  nimbleFunc=on(contains  =  sampler_BASE,                      setup  =  func=on(model,  mvSaved,  targetNode,  scale)  {          calcNodes  <-­‐  model$getDependencies(targetNode)  },            run  =  func=on()  {                      model_lp_ini=al  <-­‐  getLogProb(model,  calcNodes)          proposal  <-­‐  rnorm(1,  model[[targetNode]],  scale)          model[[targetNode]]  <<-­‐  proposal          model_lp_proposed  <-­‐  calculate(model,  calcNodes)          log_MH_ra=o  <-­‐  model_lp_proposed  -­‐  model_lp_ini=al                              if(decide(log_MH_ra=o))  jump  <-­‐  TRUE                  else                                    jump  <-­‐  FALSE                              if(jump)  {  

 copy(from  =  model,  to  =  mvSaved,  row  =  1,    nodes  =  calcNodes,  logProb  =  TRUE)                }  else    copy(from  =  mvSaved,  to  =  model,  row  =  1,  nodes  =  calcNodes,  logProb  =  TRUE)          })  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   25  

Page 26: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE  

1.  Model  specifica=on    

BUGS  language  è  R/C++  model  object  

2.  Algorithm  specifica=on    NIMBLE  programming  language  within  R  è  R/C++  algorithm  object  

3.  Algorithm  library  

MCMC,  Par=cle  Filter/Sequen=al  MC,  MCEM,  etc.  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   26  

Page 27: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Grou  

liYersModelCode  <-­‐  nimbleCode({      for(j  in  1:2)  {          for(I  in  1:16)  {  

 r[i,  j]  ~  dbin(p[i,  j],  n[i,  j]);    p[i,  j]  ~  dbeta(a[j],  b[j]);  

         }            mu[j]  <-­‐  a[j]/(a[j]  +  b[j]);            theta[j]  <-­‐  1.0/(a[j]  +  b[j]);            a[j]  ~  dgamma(1,  0.001);            b[j]  ~  dgamma(1,  0.001);    })  

27  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

NIMBLE  in  Ac=on:  the  LiYers  Example  

ri,j  

aj     pi,j  

Group  j  

•  BUGS  manual:  “The  es=mates,  par=cularly  a1,  a2  suffer  from  extremely  poor  convergence,  limited  agreement  with  m.l.e.’s  and  considerable  prior  sensi=vity.  This  appears  to  be  due  primarily  to  the  parameterisa=on  in  terms  of  the  highly  related  aj  and  bj,  whereas  direct  sampling  of  muj  and  thetaj  would  be  strongly  preferable.”  

•  But  that’s  not  all  that’s  going  on.  Consider  the  dependence  between  the  p’s  and  their  aj,  bj  hyperparameters.  

•  And  perhaps  we  want  to  do  something  other  than  MCMC.      

Challenges  of  the  toy  example:  

LiYer  i  

bj    

Beta-­‐binomial  GLMM  for  clustered  binary  response  data      Survival  in  two  sets  of  16  liYers  of  pigs  

ni,j  

Page 28: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Default  MCMC:  Gibbs  +  Metropolis  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   28  

>  liYersMCMCspec  <-­‐  configureMCMC(liYersModel,  list(adaptInterval  =  100))  >  liYersMCMC  <-­‐  buildMCMC(liYersMCMCspec)  >  liYersMCMC_cpp  <-­‐  compileNIMBLE(liYersModel,  project  =  liYersModel)  >  liYersMCMC_cpp$run(10000)  

Page 29: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   29  

Red  line  is  MLE  

0 500 1500 2500

020

0040

0060

00un

ivar.

adap

tive

a1

0 500 1500 2500

020

060

0

b1

0 500 1500 2500

05

1015

20

a2

0 500 1500 2500

01

23

45

6

b2

Page 30: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Blocked  MCMC:  Gibbs  +  Blocked  Metropolis  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   30  

>  liYersMCMCspec2  <-­‐  configureMCMC(liYersModel,  list(adaptInterval  =  100))  >  liYersMCMCspec2$addSampler(c(‘a[1]’,  ‘b[1]’),  ‘RW_block’,  list(adaptInterval  =  100)  >  liYersMCMCspec2$addSampler(c(‘a[2]’,  ‘b[2]’),  ‘RW_block’,  list(adaptInterval  =  100)  >  liYersMCMC2  <-­‐  buildMCMC(liYersMCMCspec2)  >  liYersMCMC2_cpp  <-­‐  compileNIMBLE(liYersMCMC2,  project  =  liYersModel)  >  liYersMCMC2_cpp$run(10000)  

Page 31: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   31  

0 500 1500 2500

020

0040

0060

00un

ivar.

adap

tive

a1

0 500 1500 2500

020

060

0

b1

0 500 1500 2500

05

1015

20

a2

0 500 1500 2500

01

23

45

6

b2

0 500 1500 2500

020

0040

0060

00bl

ocke

d

0 500 1500 2500

020

060

0

0 500 1500 2500

05

1015

20

0 500 1500 2500

01

23

45

6

Page 32: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Blocked  MCMC:  Gibbs  +  Cross-­‐level  Updaters  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   32  

>  liYersMCMCspec3  <-­‐  configureMCMC(liYersModel,  adaptInterval  =  100)  >  topNodes1  <-­‐  c('a[1]',  'b[1]')    >  liYersMCMCspec3$addSampler(topNodes1,  ‘crossLevel’,  list(adaptInterval  =  100)  >  topNodes2  <-­‐  c('a[2]',  'b[2]')    >  liYersMCMCspec3$addSampler(topNodes2,  ‘crossLevel’,  list(adaptInterval  =  100)  >  liYersMCMC3  <-­‐  buildMCMC(liYersMCMCspec3)  >  liYersMCMC3_cpp  <-­‐  compileNIMBLE(liYersMCMC3,  project  =  liYersModel)  >  liYersMCMC3_cpp$run(10000)  

•  Cross-­‐level  dependence  is  a  key  barrier  in  this  and  many  other  models.  •  We  wrote  a  new  “cross-­‐level”  updater  func=on  using  the  NIMBLE  DSL.  

•  Blocked  Metropolis  random  walk  on  a  set  of  hyperparameters  with  condi=onal  Gibbs  updates  on  dependent  nodes  (provided  they  are  in  a  conjugate  rela=onship).  

•  Equivalent  to  (analy=cally)  integra=ng  the  dependent  (latent)  nodes  out  of  the  model.  

Page 33: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   33  

0 500 1500 2500

020

0040

0060

00un

ivar.

adap

tive

a1

0 500 1500 2500

020

060

0

b1

0 500 1500 2500

05

1015

20

a2

0 500 1500 2500

01

23

45

6

b2

0 500 1500 2500

020

0040

0060

00bl

ocke

d

0 500 1500 2500

020

060

0

0 500 1500 2500

05

1015

20

0 500 1500 2500

01

23

45

6

0 500 1500 2500

020

0040

0060

00cr

oss−

leve

l

0 500 1500 2500

020

060

0

0 500 1500 2500

05

1015

20

0 500 1500 2500

01

23

45

6

Page 34: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

LiYers  MCMC:  BUGS  and  JAGS  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   34  

•  Customized  sampling  possible  in  NIMBLE  greatly  improves  performance.  

•  BUGS    gives  similar  performance  to  the  default  NIMBLE  MCMC  •  Be  careful  –  values  of  $sim.list  and  $sims.matrix  in  R2WinBUGS  

output  are  randomly  permuted  •  Mixing  for  a2  and  b2  modestly  beYer  than  default  NIMBLE  

MCMC  •  JAGS  slice  sampler  gives  similar  performance  as  BUGS,  but  fails  for  some  star=ng  values  with  this  (troublesome)  parameteriza=on  

•  NIMBLE  provides  user  control  and  transparency.    •  NIMBLE  is  faster  than  JAGS  on  this  example  (if  one  ignores  the  compila=on  =me),  though  not  always.  

•  Note:  we’re  not  out  to  build  the  best  MCMC  but  rather  a  flexible  framework  for  algorithms  –  we’d  love  to  have  someone  else  build  a  beYer  default  MCMC  and  distribute  for  use  in  our  system.  

Page 35: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Stepping  outside  the  MCMC  box:    maximum  likelihood/empirical  Bayes  via  MCEM  

NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)   35  

>  liYersMCEM        <-­‐  buildMCEM(liYersModel,  latentNodes  =  'p')  >  liYersMCEM(maxit  =  500,  m1  =  500,  m2  =  5000)    

•  Gives  es=mates  consistent  with  direct  ML  es=ma=on  (possible  in  this  simple  model  with  conjugacy  for  ‘p’)  to  2-­‐3  digits  

•  VERY  slow  to  converge,  analogous  to  MCMC  mixing  issues  •  Current  implementa=on  is  basic;  more  sophis=cated  

treatments  should  help  

Many  algorithms  are  of  a  modular  nature/combine  other  algorithms,  e.g.  •  par=cle  MCMC    •  normalizing  constant  algorithms  •  many,  many  others  in  the  literature  in  the  last  15  years  

Page 36: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Status  of  NIMBLE  and  Next  Steps  •  First  release  was  June  2014  with  regular  releases  since.      

Lots  to  do:  –  Sequen=al  MC  methods  in  next  release  (par=cle  filter,  ensemble  Kalman  filter,  par=cle  MCMC)  

–  Improve  the  user  interface  and  speed  up  compila=on  –  Allow  indices  of  vectors  to  be  random  (e.g.,  mixture  models)  –  Refinement/extension  of  the  DSL  for  algorithms  –  Addi=onal  algorithms  wriYen  in  NIMBLE  DSL  (e.g.,  normalizing  constant  calcula=on,  Laplace  approxima=ons)  

–  Advanced  features  (e.g.,  auto.  differen=a=on,  paralleliz’n)  •  Interested?    

–  Announcements:  nimble-­‐announce  Google  site  –  User  support/discussion:  nimble-­‐users  Google  site  –  Write  an  algorithm  using  NIMBLE!    –  Help  with  development  of  NIMBLE:  email  [email protected]  or  see  github.com/nimble-­‐dev  

36  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 37: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

PalEON  Project  www3.nd.edu/~paleolab/paleonproject  

37  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Goal:  Improve  the  predic=ve  capacity  of  terrestrial  ecosystem  models  Friedlingstein  et  al.  2006  J.  Climate  

“This  large  varia-on  among  carbon-­‐cycle  models  …  has  been  called  ‘uncertainty’.                      I  prefer  to  call  it  ‘ignorance’.”                -­‐  Pren-ce  (2013)  Grantham  Ins-tute  

Cri=cal  issue:    model  parameteriza=on  and  representa=on  of  decadal-­‐  to  centennial-­‐scale  processes  are  poorly  constrained  by    data  Approach:  use  historical  and  fossil  data  to  es=mate  past  vegeta=on  and  climate  and  use  this  informa=on  for  model  ini=aliza=on,  assessment,  and  improvement    

Page 38: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

PalEON  Sta=s=cal  Applica=ons  •  Es=mate  spa=ally-­‐varying  composi=on  and  biomass  of  tree  species  from  count  and  zero-­‐inflated  size  data  in  year  1850  

•  Es=mate  temporal  varia=ons  in  temperature  and  precipita=on  over  2000  years  from  tree  rings  and  lake/bog  records  

•  Es=mate  tree  composi=on  spa=ally  over  2000  years  from  fossil  pollen  in  lake  sediment  cores  

•  Es=mate  biomass  over  =me  at  a  site  from  fossil  pollen  in  lake  sediment  cores  

38  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 39: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

39  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Fossil  Pollen  Data  

2000

1900

1800

1700

1600

1500

1300

1200

1100

1000

1400

Year A

D

Pine

20

Hemloc

k

20 40

Birch

20

Oak Hickory

20 40

Beech

Chestn

ut

20

Grass &

wee

ds

1500

Charco

al:Poll

en

60

% orga

nic m

atterBerry Pond WestBerry Pond, W Massachusetts

Onset of Little Ice Age

European settlement

Page 40: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Inferring  Biomass  from  Pollen  •  Calibra=on  with  mul=ple  spa=al  loca=ons:  –  “Regress”  mul=nomial  counts  on  biomass  –  For  each  taxon,  have  propor=on  of  the  taxon  be  a  smooth  func=on  of  biomass  using  splines  and  Dirichlet  parameters:  •  αk  =  exp(  Z(b)βk)  

–  Es=mate  spline  coefficients  for  each  taxon  •  Predict  biomass  over  =me  at  one  loca=on:  –  State  space  model  for  biomass  over  =me  –  Fixed  spline  coefficients  from  calibra=on  –  Inverse  problem  (just  Bayesian  inference)  

•  αk  =  exp(  Z(bt)βk)  

40  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 41: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Rela=ng  biomass  to  composi=on  

 

41  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

•  Using  mul=ple  sites  (i  =  1,…,n)  with  measured  pollen  composi=on  (yi)  for  k=1,…,K  taxa  and  known  local  biomass  (bi),  we  regress  the  counts  on  biomass:  

•  This  uses  b-­‐splines  to  relate  propor=onal  abundance  of  a  taxon  to  biomass.  

•  Es=mate  the  βk  parameters  (basis  coefficients)  for  each  taxon,  k=1,…,K.  

↵i,k = exp(Z(bi)>�k)

pi ⇠ Dirich(↵i,·)

yi ⇠ Multinom(pi)

Page 42: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Predic=on  Model  

42  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

=me  t  

taxon  k  

βk  

αtk  

ptk  

Ytk  

bt  

Z(bt)  

σ  

Page 43: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Predic=on  Model  for(t  in  1:nTimes)    

 Y[t,  1:nTaxa]  ~  ddirchmul=(alpha[t,  1:nTaxa],  n[t])    for  (k  in  1:nTaxa)            for(t  in  1:nTimes)  

 alpha[t,  k]  <-­‐  exp(Zb[t,  1:nKnots]  %*%  beta[1:nKnots,  k])    for(  t  in  1:nTimes)    

 Zb[t,  1:nKnots]  <-­‐  bspline(b[t],  knots[1:w])    for(t  in  2:nTimes)  

 b[t]  ~  dlnorm(log(b[t-­‐1]),  sdlog  =  sigma)    sigma  ~  dunif(0,  10)  #  Gelman  (2006)          b[1]  ~  dunif(0,  400)  

43  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

pollen  likelihood    

latent    predictor    

hyperpriors  

biomass  evolu=on  

Page 44: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

Results  at  one  site  

44  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●

●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●

●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●

●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●

●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●

●●

●●

●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●

●●

●●

●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●

●●

●●●●●●●●●●●●●●●●●●●●●●●●●

●●

●●

●●●

●●

●●●●●● ●●●●

●●●

●●●●●

●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

−95 −90 −85

4244

4648

50

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

Calibra=on  sites  and  predic=on  site  (red)  

−8000 −6000 −4000 −2000 0 2000

020

4060

80100

year

biom

ass

Biomass  over  =me  

Page 45: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

How  Can  NIMBLE  Help?  •  More  flexible  model  specifica=on    – Dirichlet-­‐mul=nomial  – b-­‐spline  construc=on  

•  User  control  over  MCMC  specifica=on  •  Alterna=ve  algorithms,  such  as  par=cle  filter,  par=cle  MCMC  

•  Provide  algorithms  for  model  comparison  and  model  cri=cism  

•  Transparency  when  an  algorithm  fails  

45  NIMBLE:  extensible  so_ware  for  hierarchical  models  (r-­‐nimble.org)  

Page 46: Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical ...paciorek/presentations/...Beyond’the’black’box:’’’ Flexible’programming’of’hierarchical’

PalEON  Acknowledgements  •  Pollen-­‐biomass  Collaborators:  Ann  Raiho,  Jason  McLachlan  (Notre  Dame  Biology)  

•  PalEON  inves=gators:  Jason  McLachlan  (Notre  Dame,  PI),  Mike  Dietze  (BU),  Andrew  Finley  (Michigan  State),  Amy  Hessl  (West  Virginia),  Phil  Higuera  (Idaho),  Mevin  Hooten  (USGS/Colorado  State),  Steve  Jackson  (USGS/Arizona),  Dave  Moore  (Arizona),  Neil  Pederson  (Harvard  Forest),  Jack  Williams  (Wisconsin),  Jun  Zhu  (Wisconsin)  

•  NSF  Macrosystems  Program  46  NIMBLE:  extensible  so_ware  for  

hierarchical  models  (r-­‐nimble.org)