You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: knitr/planetary_motion/planetary_motion.rmd
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The specific concepts we encounter in this article include why our inference fai
23
23
24
24
Given the recorded position of a planet over time, we want to estimate the physical properties of a star-planet system.
25
25
This includes position, momentum, and gravitational interaction.
26
-
We fit the model with Stan [@Carpenter:2017], using Hamiltonian Monte Carlo (HMC), a gradient-based Markov chain Monte Carlo (MCMC) algorithm;
26
+
We fit the model with Stan [@Carpenter:2017], using a Hamiltonian Monte Carlo (HMC) sampler, a gradient-based Markov chain Monte Carlo (MCMC) algorithm;
27
27
for a thorough introduction to HMC, we recommend the article by @Betancourt:2018.
28
28
Initially, we meant the planetary motion problem to be a simple textbook example for ODE-based models; but it turns out many interesting challenges arise when we do a Bayesian analysis on this model.
29
29
We discuss how to diagnose and fix these issues.
@@ -44,21 +44,23 @@ In our presentation, we try to distinguish generalizable methods, problem-specif
As commented before, we would've been wise not to run the algorithm for so many iterations... Stan returns several warning messages, including divergent transitions (for 343 out of 8,000 samples) and exceeded maximum treedepths (for 28 samples).
576
579
We can check the warning message report using `fit$cmdstan_diagnose()`.
577
580
As before, let's examine a few diagnostics:
578
-
```{r, message=FALSE}
581
+
```{r, message=FALSE, fig.height=3}
579
582
pars <- c("lp__", "k", "q0", "p0", "star")
580
583
r_fit2$summary(pars)[, c(1, 2, 4, 8, 9)]
581
584
582
585
pars <- c("lp__", "k", "q0[1]", "q0[2]", "p0[1]", "p0[2]",
583
586
"star[1]", "star[2]")
584
-
bayesplot::mcmc_trace(r_fit2$draws(), pars = pars)
587
+
bayesplot::mcmc_trace(r_fit2$draws(inc_warmup = TRUE), pars = pars,
588
+
n_warmup = 500)
585
589
```
586
590
587
591
We have five well-behaved chains, which return consistent estimates, and three other chains which have with great effort ventured into other regions of the parameter space.
@@ -611,7 +615,7 @@ Our proposition is to look at _conditional likelihoods_, that is fix some of the
611
615
This, from a certain point of view, very much amounts to studying a simplification of our model.
612
616
To begin, we fix all parameters (based on the correct values or equivalently estimates from the well-behaving Markov chains), except for $q_*^x$.
613
617
614
-
```{r, fig.height=5}
618
+
```{r, fig.height=4}
615
619
star_x <- seq(from = -0.5, to = 0.8, by = 0.01)
616
620
star_s <- array(NA, dim = c(length(star_x), 2))
617
621
star_s[, 1] <- star_x
@@ -753,14 +757,14 @@ The possibility of such ill-fitting modes implies we should always run multiple
753
757
This case study also raises the question of what role starting points may play.
754
758
Ideally a Markov chain forgets its initial value but in a non-asymptotic regime this may not be the case.
755
759
Just as there is no universal default prior, there is no universal default initial point.
756
-
Modelers often need to depart from defaults to insure a numerically stable evaluation of the joint density and improve MCMC computation.
760
+
Modelers often need to depart from defaults to ensure a numerically stable evaluation of the joint density and improve MCMC computation.
757
761
At the same time we want dispersed initial points in order to have reliable convergence diagnostics and to potentially explore all the relevant modes.
758
-
Like for other tuning parameters of an inference algorithm, picking starting points can be an iterative process, with adjustments made after a first attempt at fitting the model.
762
+
As with other tuning parameters of an inference algorithm, picking starting points can be an iterative process, with adjustments made after a first attempt at fitting the model.
759
763
760
764
We do not advocate mindlessly discarding misbehaving chains. It is important to analyze where this poor behavior comes from, and whether it hints at serious flaws in our model and in our inference. Our choice to adjust the initial estimates is based on: (a) the realization that the defaults are widely inconsistent with our expertise and (b) the understanding that the local modes do not describe a latent phenomenon of interest, as shown by our detailed analysis of how cyclical data interacts with a normal likelihood.
761
765
762
766
# Acknowledgement {-#Acknowledgement}
763
767
764
-
We thank Ben Bales, Matthew West, and Martin Modrák for helpful discussion.
768
+
We thank Ben Bales, Matthew West, Martin Modrák, and Jonah Gabry for helpful discussion.
0 commit comments