Skip to content

Distinguish power-law and geometric (discrete exponential) distributions using RStan with bridge sampling

Notifications You must be signed in to change notification settings

yfiua/rstan-powerlaw-geometric

Repository files navigation

rstan-powerlaw-geometric

Distinguish power-law and geometric (discrete exponential) distributions using RStan with bridge sampling.

Synthetic data

  • sim-pl.R: generate synthetic data that exhibits power-law with exponent $\alpha = 2$
  • sim-exp.R: generate synthetic data that exhibits geometric distribution with $p=.2$

Generated data can be found in the data/ directory. Example data and their distributions can be found in the data-example/ directory.

Model fitting and comparison

Results can be found in the results/ directory.

Results

Rstan should give the posterior distributions for the power-law exponent $\alpha$ and the success probability $p$ for the geometric distribution.

When using model-comparison-pl.R with the power-law data, it should estimate the Bayes factor of the two models as Inf, meaning it strongly favors the power-law distribution.

When using model-comparison-exp.R with the geometric data, it should estimate the Bayes factor of the two models as 0.00000, meaning it strongly favors the geometric distribution.

Example results are in the results-example/ directory.

Reproducibility

Environment

To reproduce the results, set up the environment in renv.lock with:

renv::restore()

Reproduce results

Then use stu to build all results:

stu

Clean up the results with:

stu @clean

Alternatively, run the script run.sh to build the results:

./run.sh

References

About

Distinguish power-law and geometric (discrete exponential) distributions using RStan with bridge sampling

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published