de valpine nimble

21
NIMBLE (First release by summer) model language (BUGS) Algorithm language

Upload: david-lebauer

Post on 05-Jul-2015

2.996 views

Category:

Data & Analytics


2 download

TRANSCRIPT

Page 1: de Valpine NIMBLE

NIMBLE  

 (First  release  by  summer)  

model  language  (BUGS)  

Algorithm  language  

Page 2: de Valpine NIMBLE

Why  algorithm  programmability?  

•  Simple  advanced  MCMC:  block  updaters,  mulHple  updaters,  mulHple  scales,  modularity  

•  Advanced  advanced  MCMC:  bridge  sampling,  reversible  jump,  adapHve  MCMC,  tempering,  approximaHng  models  

•  ParHcle  filtering  •  Importance  sampling  •  Laplace  approximaHon,  adapHve  Gaussian  quadrature  •  Kalman  Filtering,  Unscented  KF,  extended  KF  •  Prior  sensiHvity  analysis  by  reweighHng  •  Monte  Carlo  ExpectaHon  MaximizaHon  (MCEM)  •  Data  cloning  •  Approximate  Bayesian  ComputaHon  •  Posterior  predicHve  checks  (without  re-­‐running  MCMC)  •  Normalizing  constants:  bridge  sampling;    see  above  •  CombinaHon  algorithms:  PF  +  MCMC,  MCMC  +  Laplace  

 Algorithm  developers  need  a  system  for  model-­‐flexibility  and  distribuHon.  

Page 3: de Valpine NIMBLE

What  we    do  with  BUGS  models  

model  {      mu  ~  dnorm(0,  10)      logit(p)  ~  dnorm(mu,  sigma)      y  ~  dbin(N,  p)  }  

Page 4: de Valpine NIMBLE

What  we    do  with  BUGS  models  

model  {      mu  ~  dnorm(0,  10)      logit(p)  ~  dnorm(mu,  sigma)      y  ~  dbin(N,  p)  }  

Extract  all  semanHc  relaHonships.  Build  a  graphical  model  object  R  (igraph).  Generate  C++  code  Compile,  load,  and  provide  interface  objects.  

Page 5: de Valpine NIMBLE

What  we    do  with  BUGS  models  

model  {      mu  ~  dnorm(0,  10)      logit(p)  ~  dnorm(mu,  sigma)      y  ~  dbin(N,  p)  }  

Extract  all  semanHc  relaHonships.  Build  a  graphical  model  object  R  (igraph).  Generate  C++  code  Compile,  load,  and  provide  interface  objects.  

mymodel$mu  <-­‐  5  toCalc  <-­‐  getDependencies(mymodel,  "mu")  calculate(mymodel,  toCalc)  

Page 6: de Valpine NIMBLE

What  we    do  with  BUGS  models  

Some  "automaHc"  extensions  of  BUGS  1.  Expressions  as  arguments  2.  MulHple  parameterizaHons  for  distribuHons  (e.g.  precision  or  std.  deviaHon)  3.  Compile-­‐Hme  if-­‐then-­‐else  4.  Single-­‐line  moHfs:    y[1:10]  ~  glmm(X  *  A  +  (1  |  Group),  family  =  "binomial")  

model  {      mu  ~  dnorm(0,  10)      logit(p)  ~  dnorm(mu,  sigma)      y  ~  dbin(N,  p)  }  

Extract  all  semanHc  relaHonships.  Build  a  graphical  model  object  R  (igraph).  Generate  C++  code  Compile,  load,  and  provide  interface  objects.  

mymodel$mu  <-­‐  5  toCalc  <-­‐  getDependencies(mymodel,  "mu")  calculate(mymodel,  toCalc)  

Page 7: de Valpine NIMBLE

How  we  write  algorithms  Random-­‐walk  MCMC  updater  

1.  setup  arguments:  model,  targetNode  

Page 8: de Valpine NIMBLE

How  we  write  algorithms  Random-­‐walk  MCMC  updater  

1.  setup  arguments:  model,  targetNode  

2.  setup  code:      use  model  structure  to  query  targetNode  dependencies  

Processed  ONCE,  in  R  

Page 9: de Valpine NIMBLE

How  we  write  algorithms  Random-­‐walk  MCMC  updater  

1.  setup  arguments:  model,  targetNode  

2.  setup  code:      use  model  structure  to  query  targetNode  dependencies  

Processed  ONCE,  in  R  

3.  run-­‐Hme  code:              (i)      put  a  proposal  value  in  the  targetNode              (ii)    calculate  needed  log  likelihoods              (iii)  accept  or  reject  

Becomes  C++  code,  compiled  &  interfaced  

Page 10: de Valpine NIMBLE

How  we  write  algorithms  Random-­‐walk  MCMC  updater  

1.  setup  arguments:  model,  targetNode  

2.  setup  code:      use  model  structure  to  query  targetNode  dependencies  

Processed  ONCE,  in  R  

3.  run-­‐Hme  code:              (i)      put  a  proposal  value  in  the  targetNode              (ii)    calculate  needed  log  likelihoods              (iii)  accept  or  reject  

Becomes  C++  code,  compiled  &  interfaced  

Building  a  program  with  many  funcHons:  •  model  structure  (setup  arguments)  processed  in  R  •  algorithm  executed  in  C++  

Page 11: de Valpine NIMBLE

How  we  write  algorithms  Random-­‐walk  MCMC  updater  

1.  setup  arguments:  model,  targetNode  

2.  setup  code:      use  model  structure  to  query  targetNode  dependencies  

Processed  ONCE,  in  R  

3.  run-­‐Hme  code:              (i)      put  a  proposal  value  in  the  targetNode              (ii)    calculate  needed  log  likelihoods              (iii)  accept  or  reject  

Becomes  C++  code,  compiled  &  interfaced  

Building  a  program  with  many  funcHons:  •  model  structure  (setup  arguments)  processed  in  R  •  algorithm  executed  in  C++  

We  provide  data  structures  for  sets  of  model  values  (e.g.  MCMC  output)  

Page 12: de Valpine NIMBLE

ConnecHons  to  other  engines  

When  another  system  has  a  great  algorithm,  we  want  to  wrap  access  to  it.  

Page 13: de Valpine NIMBLE

ConnecHons  to  other  engines  

When  another  system  has  a  great  algorithm,  we  want  to  wrap  access  to  it.  

Example:    Monte  Carlo  ExpectaHon  MaximizaHon  (MCEM)  •  Uses  MCMC  repeatedly  on  latent  states  •  Parameters  updated  between  MCMCs  •  We  don't  have  to  use  our  own  MCMC  if  someone  else  has  a  great  one  

   

Page 14: de Valpine NIMBLE

ConnecHons  to  other  engines  

When  another  system  has  a  great  algorithm,  we  want  to  wrap  access  to  it.  

Example:    Monte  Carlo  ExpectaHon  MaximizaHon  (MCEM)  •  Uses  MCMC  repeatedly  on  latent  states  •  Parameters  updated  between  MCMCs  •  We  don't  have  to  use  our  own  MCMC  if  someone  else  has  a  great  one  

   

How?      We  have  high-­‐level  representaHon  of  model  structure.  Can  generate  specificaHons  needed  for  other  packages.    

Page 15: de Valpine NIMBLE

Who  we  think  will  use  NIMBLE  

1.  Algorithm  developers  

2.  Data  analysts  

3.  Workflow  pipelines  

Page 16: de Valpine NIMBLE

Numerical!Integration of!Mixture Models for!Bayesian and !Likelihood!Estimation!

Team:!Perry de Valpine!Chris Paciorek!Daniel Turek!Cliff Anderson-Bergmann!Ras Bodik!Duncan Temple Lang!

Funding:!NSF Advances in !Biological Informatics!

Page 17: de Valpine NIMBLE
Page 18: de Valpine NIMBLE

Common  situaHon  

model  language  

(Black  box  algorithm)  

Page 19: de Valpine NIMBLE

How  we  build  an  MCMC  

1.  R  funcHons  use  model/graph  objects  in  R  to  inspect  a  parHcular  model:    -­‐    Build  list  of  updaters  

                 -­‐    Can  be  inspected,  modified                    -­‐    You  can  write  your  own  

Page 20: de Valpine NIMBLE

How  we  build  an  MCMC  

1.  R  funcHons  use  model/graph  objects  in  R  to  inspect  a  parHcular  model:    -­‐    Build  list  of  updaters  

                 -­‐    Can  be  inspected,  modified                    -­‐    You  can  write  your  own  

2.  Generate  C++  code  for  all  updaters.  

Page 21: de Valpine NIMBLE

How  we  build  an  MCMC  

1.  R  funcHons  use  model/graph  objects  in  R  to  inspect  a  parHcular  model:    -­‐    Build  list  of  updaters  

                 -­‐    Can  be  inspected,  modified                    -­‐    You  can  write  your  own  

2.  Generate  C++  code  for  all  updaters.  

3.  Compile,  load,  build  and  interface  to  objects.