pymc.AR#
- class pymc.AR(name, rho, *args, steps=None, constant=False, ar_order=None, **kwargs)[source]#
Autoregressive process with p lags.
\[x_t = \rho_0 + \rho_1 x_{t-1} + \ldots + \rho_p x_{t-p} + \epsilon_t, \epsilon_t \sim N(0,\sigma^2)\]The innovation can be parameterized either in terms of precision or standard deviation. The link between the two parametrizations is given by
\[\tau = \dfrac{1}{\sigma^2}\]- Parameters
- rho: tensor_like of float
Tensor of autoregressive coefficients. The n-th entry in the last dimension is the coefficient for the n-th lag.
- sigma: tensor_like of float, optional
Standard deviation of innovation (sigma > 0). Defaults to 1. Only required if tau is not specified.
- tau: tensor_like of float
Precision of innovation (tau > 0).
- constant: bool, optional
Whether the first element of rho should be used as a constant term in the AR process. Defaults to False
- init_dist: unnamed distribution
Scalar or vector distribution for initial values. Distribution should be created via the .dist() API, and have shape (*shape[:-1], ar_order). If not, it will be automatically resized.
Warning
init_dist will be cloned, rendering it independent of the one passed as input.
- ar_order: int, optional
Order of the AR process. Inferred from length of the last dimension of rho, if possible. ar_order = rho.shape[-1] if constant else rho.shape[-1] - 1
- steps
int
, optional Number of steps in AR process (steps > 0). Only needed if shape is not provided.
Notes
The init distribution will be cloned, rendering it distinct from the one passed as input.
Examples
# Create an AR of order 3, with a constant term with pm.Model() as AR3: # The first coefficient will be the constant term coefs = pm.Normal("coefs", 0, size=4) # We need one init variable for each lag, hence size=3 init = pm.Normal.dist(5, size=3) ar3 = pm.AR("ar3", coefs, sigma=1.0, init_dist=init, constant=True, steps=500)
Methods
AR.__init__
(*args, **kwargs)AR.change_size
(rv, new_size[, expand])AR.dist
(rho[, sigma, tau, init_dist, steps, ...])Creates a TensorVariable corresponding to the cls symbolic distribution.
AR.ndim_supp
(*args)AR.rv_op
(rhos, sigma, init_dist, steps, ...)