Skip to content

al-jshen/gmestan-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gmestan

This repository provides examples for using Stan to create a hierarchical Bayesian model to estimate the mass of the Milky Way using kinematic data from tracers. See the associated paper describing the model and code here: Shen et al. 2022

GME model

This repository contains a Stan port of GME. There are two models, models/gc.stan and models/dg.stan, which can be used to reproduce the results of Eadie and Jurić 2019 and Slizewski et. al (submitted to ApJ) respectively. These models assume independence between the two proper motions (RA and DEC), do not incorporate covariances between phase-space parameters, and the results are produced with complete data only.

Example files for how to use the models are in examples/gme_py.ipynb for Python and examples/gme.r for R.

Two accompanying datasets are provided:

Extended model

The extended model used for analysis of H3 halo stars is provided in models/h3p.stan. The model can deal with missing positions and/or velocities, and incorporates within-source covariances. Also provided is a version of the model where RA and Dec. are fixed. This model can be found in models/h3p-fixed.stan, and is the recommended one to use when uncertainties in position are small (e.g., from Gaia).

There are again two examples of how to run the models: examples/h3.ipynb and examples/h3.r. Bring your own data!

Python

To install CmdStanPy (a lightweight Python interface to Stan), see the instructions here.

The Python examples are Jupyter notebooks. Apart from Pystan and Jupyter, the necessary dependencies to run all the code in the notebook can be installed through pip with the following line:

pip3 install numpy pandas matplotlib arviz seaborn

R

To install CmdStanR (the R interface to CmdStan), see the instructions here.

I recommend opening the provided R files in RStudio. Apart from CmdStanR, the necessary depenencies to run all the code can be installed with the following line:

install.packages(c("tidyverse", "latex2exp", "bayesplot", "shinystan", "ggridges", "reshape2", "posterior"), dependencies=TRUE)

Citation

If you make use of the code in this repository and find it useful, please consider citing Shen et al. 2022. The BibTeX entry for this paper is:

@article{Shen_2022,
   title={The Mass of the Milky Way from the H3 Survey},
   volume={925},
   ISSN={1538-4357},
   url={http://dx.doi.org/10.3847/1538-4357/ac3a7a},
   DOI={10.3847/1538-4357/ac3a7a},
   number={1},
   journal={The Astrophysical Journal},
   publisher={American Astronomical Society},
   author={Shen, Jeff and Eadie, Gwendolyn M. and Murray, Norman and Zaritsky, Dennis and Speagle, Joshua S. and Ting, Yuan-Sen and Conroy, Charlie and Cargile, Phillip A. and Johnson, Benjamin D. and Naidu, Rohan P. and Han, Jiwon Jesse},
   year={2022},
   month={jan},
   pages={1}
}

Useful Resources

About

Galactic mass estimation with Stan.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages