Unverified Commit 727b88ad authored by Jonathan Sedar's avatar Jonathan Sedar Committed by GitHub

Update robust glm notebook (#3908)

* updated the Hogg notebook

* attempted to clarify the kwargs in sample() docstring describing how to pass kwargs to the steppers

I believe this fixes https://github.com/pymc-devs/pymc3/issues/3197

I also noted this need for more clarity in my updated notebook in this PR

`pymc3/docs/source/notebooks/GLM-robust-with-outlier-detection.ipynb`

* Remove deprecated stuff (#3906)

* remove file which is not used

* remove deprecated code

* repair tests and notebooks that used deprecated API

* mention #3906
Co-authored-by: default avatarMichael Osthege <zufallsprinzip@hotmail.de>

* add deprecation warnings for old backends (#3902)

* add deprecation warnings for old backends

* mention backend deprecation #3902

* fix typo
Co-authored-by: default avatarColin <ColCarroll@users.noreply.github.com>
Co-authored-by: default avatarMichael Osthege <zufallsprinzip@hotmail.de>
Co-authored-by: default avatarColin <ColCarroll@users.noreply.github.com>

* minor formatting to notebook and rework of docstring for sample function

notebook: dropped all headings one level lower to comply with TOC logic, and very minor language edits

sampling.py: clarifired language around single vs compoundstep

* updated the Hogg notebook

* attempted to clarify the kwargs in sample() docstring describing how to pass kwargs to the steppers

I believe this fixes https://github.com/pymc-devs/pymc3/issues/3197

I also noted this need for more clarity in my updated notebook in this PR

`pymc3/docs/source/notebooks/GLM-robust-with-outlier-detection.ipynb`

* minor formatting to notebook and rework of docstring for sample function

notebook: dropped all headings one level lower to comply with TOC logic, and very minor language edits

sampling.py: clarifired language around single vs compoundstep

* updates folowing AlexAndorra review:

upgrade to arviz=0.7
set prior params to slightly simpler (more justifiable) values, and testvals to simplier defaults
explanatory clarifications
formatting, typos,

* removed the note re step_kwargs, since this PR updates the appropriate docstring

* a cell had become markdown, silly. reset it to code and rerun

* minor code reformatting via black_nbconvert, final check and re-run

* rerun notebook purely as a lazy but safe way to trigger new CI
parent 2d68025e
......@@ -334,16 +334,42 @@ def sample(
Notes
-----
Optional keyword arguments can be passed to ``sample`` to be delivered to the
``step_method``s used during sampling. In particular, the NUTS step method accepts
a number of arguments. Common options are:
``step_method``s used during sampling.
* target_accept: float in [0, 1]. The step size is tuned such that we approximate this
acceptance rate. Higher values like 0.9 or 0.95 often work better for problematic
posteriors.
* max_treedepth: The maximum depth of the trajectory tree.
If your model uses only one step method, you can address step method kwargs
directly. In particular, the NUTS step method has several options including:
* target_accept: float in [0, 1]. The step size is tuned such that we
approximate this acceptance rate. Higher values like 0.9 or 0.95 often
work better for problematic posteriors
* max_treedepth: The maximum depth of the trajectory tree
* step_scale: float, default 0.25
The initial guess for the step size scaled down by :math:`1/n**(1/4)`
If your model uses multiple step methods, aka a Compound Step, then you have
two ways to address arguments to each step method:
A: If you let ``sample()`` automatically assign the ``step_method``s,
and you can correctly anticipate what they will be, then you can wrap
step method kwargs in a dict and pass that to sample() with a kwarg set
to the name of the step method.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send:
1. ``target_accept`` to NUTS: nuts={'target_accept':0.9}
2. ``transit_p`` to BinaryGibbsMetropolis: binary_gibbs_metropolis={'transit_p':.7}
Note that available names are:
``nuts``, ``hmc``, ``metropolis``, ``binary_metropolis``,
``binary_gibbs_metropolis``, ``categorical_gibbs_metropolis``,
``DEMetropolis``, ``DEMetropolisZ``, ``slice``
B: If you manually declare the ``step_method``s, within the ``step``
kwarg, then you can address the ``step_method`` kwargs directly.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send:
step=[pm.NUTS([freeRV1, freeRV2], target_accept=0.9),
pm.BinaryGibbsMetropolis([freeRV3], transit_p=.7)]
You can find a full list of arguments in the docstring of the step methods.
Examples
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment