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:
- rhotensor_like of
float
Tensor of autoregressive coefficients. The n-th entry in the last dimension is the coefficient for the n-th lag.
- sigmatensor_like of
float
, default 1 Standard deviation of innovation (sigma > 0). Only required if tau is not specified.
- tautensor_like of
float
, optional Precision of innovation (tau > 0).
- constantbool, default
False
Whether the first element of rho should be used as a constant term in the AR process.
- init_distunnamed_distribution, optional
Scalar or vector distribution for initial values. Distributions should have shape (*shape[:-1], ar_order). If not, it will be automatically resized. Defaults to pm.Normal.dist(0, 100, shape=…).
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.
- rhotensor_like of
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.dist
(rho[, sigma, tau, init_dist, steps, ...])Creates a tensor variable corresponding to the cls distribution.