## models.BayesGlm


A Bayesian GLM sampled with NUTS (nuts-rs, the Rust core of nutpie).


Usage


``` python
models.BayesGlm()
```


Normal priors with mean 0 on the coefficients: standard deviation `intercept_sd` for an all-ones column, `prior_sd` for the others (on the link scale; standardize covariates). For the Gaussian, gamma and inverse Gaussian the dispersion is sampled too, with a half-normal prior of scale `dispersion_scale`, unless [dispersion](models.GlmFit.md#prospicio.models.GlmFit.dispersion) fixes it. Chains run in parallel, start near the maximum-likelihood fit, and replay exactly from [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed).


## Parameters


`family: str`  

`link: str`  

`prior_sd: float = ``2.5`  

`intercept_sd: float = ``10.0`  

`dispersion: float`  
A fixed dispersion; 1 by default for the Poisson, binomial and negative binomial. A Tweedie needs one.

`dispersion_scale: float = ``10.0`  

`chains: int = 4, 1000, 1000`  

`tune: int = 4, 1000, 1000`  

`draws: int = 4, 1000, 1000`  

`seed: int = ``0`  

`target_accept: float = ``0.8`  

`max_depth: int = ``10`  

`theta: float`  

`power: float`  

`link_power: float`  


## Examples

``` python
>>> from prospicio.models import BayesGlm, Design
>>> x = [(i % 4) - 1.5 for i in range(40)]
>>> y = [[1.0, 2.0, 3.0, 5.0][i % 4] for i in range(40)]
>>> d = Design([[1.0] * 40, x], ["(Intercept)", "x"])
>>> fit = BayesGlm("poisson", chains=2, tune=300, draws=300).fit(d, y)
>>> all(s["rhat"] < 1.05 for s in fit.summary())
```

True


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | Samples the posterior. |

------------------------------------------------------------------------


#### fit()


Samples the posterior.


Usage


``` python
fit(design, y)
```


##### Parameters


`design: Design`  

`y: list of float`  


##### Returns


`BayesGlmFit`
