Timeseries¶

Autoregressive process with 1 lag. 

Autoregressive process with p lags. 

Random Walk with Normal innovations 

GARCH(1,1) with Normal innovations. 

Stochastic differential equation discretized with the EulerMaruyama method. 

Multivariate Random Walk with Normal innovations 

Multivariate Random Walk with StudentT innovations 
 class pymc3.distributions.timeseries.AR(name, *args, **kwargs)¶
Autoregressive process with p lags.
\[x_t = \rho_0 + \rho_1 x_{t1} + \ldots + \rho_p x_{tp} + \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
Tensor of autoregressive coefficients. The first dimension is the p lag.
 sigma: float
Standard deviation of innovation (sigma > 0). (only required if tau is not specified)
 tau: float
Precision of innovation (tau > 0). (only required if sigma is not specified)
 constant: bool (optional, default = False)
Whether to include a constant.
 init: distribution
distribution for initial values (Defaults to Flat())
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(value)¶
Calculate logprobability of AR distribution at specified value.
 Parameters
 value: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 class pymc3.distributions.timeseries.AR1(name, *args, **kwargs)¶
Autoregressive process with 1 lag.
 Parameters
 k: tensor
effect of lagged value on current value
 tau_e: tensor
precision for innovations
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(x)¶
Calculate logprobability of AR1 distribution at specified value.
 Parameters
 x: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 class pymc3.distributions.timeseries.EulerMaruyama(name, *args, **kwargs)¶
Stochastic differential equation discretized with the EulerMaruyama method.
 Parameters
 dt: float
time step of discretization
 sde_fn: callable
function returning the drift and diffusion coefficients of SDE
 sde_pars: tuple
parameters of the SDE, passed as
*args
tosde_fn
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(x)¶
Calculate logprobability of EulerMaruyama distribution at specified value.
 Parameters
 x: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 class pymc3.distributions.timeseries.GARCH11(name, *args, **kwargs)¶
GARCH(1,1) with Normal innovations. The model is specified by
\[y_t = \sigma_t * z_t\]\[\sigma_t^2 = \omega + \alpha_1 * y_{t1}^2 + \beta_1 * \sigma_{t1}^2\]with z_t iid and Normal with mean zero and unit standard deviation.
 Parameters
 omega: tensor
omega > 0, mean variance
 alpha_1: tensor
alpha_1 >= 0, autoregressive term coefficient
 beta_1: tensor
beta_1 >= 0, alpha_1 + beta_1 < 1, moving average term coefficient
 initial_vol: tensor
initial_vol >= 0, initial volatility, sigma_0
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(x)¶
Calculate logprobability of GARCH(1, 1) distribution at specified value.
 Parameters
 x: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 class pymc3.distributions.timeseries.GaussianRandomWalk(name, *args, **kwargs)¶
Random Walk with Normal innovations
Note that this is mainly a userfriendly wrapper to enable an easier specification of GRW. You are not restricted to use only Normal innovations but can use any distribution: just use theano.tensor.cumsum() to create the random walk behavior.
 Parameters
 mu: tensor
innovation drift, defaults to 0.0 For vector valued mu, first dimension must match shape of the random walk, and the first element will be discarded (since there is no innovation in the first timestep)
 sigma: tensor
sigma > 0, innovation standard deviation (only required if tau is not specified) For vector valued sigma, first dimension must match shape of the random walk, and the first element will be discarded (since there is no innovation in the first timestep)
 tau: tensor
tau > 0, innovation precision (only required if sigma is not specified) For vector valued tau, first dimension must match shape of the random walk, and the first element will be discarded (since there is no innovation in the first timestep)
 init: distribution
distribution for initial value (Defaults to Flat())
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(x)¶
Calculate logprobability of Gaussian Random Walk distribution at specified value.
 Parameters
 x: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 random(point=None, size=None)¶
Draw random values from GaussianRandomWalk.
 Parameters
 point: dict, optional
Dict of variable values on which random values are to be conditioned (uses default point if not specified).
 size: int, optional
Desired size of random sample (returns one sample if not specified).
 Returns
 array
 class pymc3.distributions.timeseries.MvGaussianRandomWalk(name, *args, **kwargs)¶
Multivariate Random Walk with Normal innovations
 Parameters
 mu: tensor
innovation drift, defaults to 0.0
 cov: tensor
pos def matrix, innovation covariance matrix
 tau: tensor
pos def matrix, inverse covariance matrix
 chol: tensor
Cholesky decomposition of covariance matrix
 init: distribution
distribution for initial value (Defaults to Flat())
Notes
Only one of cov, tau or chol is required.
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5
 logp(x)¶
Calculate logprobability of Multivariate Gaussian Random Walk distribution at specified value.
 Parameters
 x: numeric
Value for which logprobability is calculated.
 Returns
 TensorVariable
 random(point=None, size=None)¶
Draw random values from MvGaussianRandomWalk.
 Parameters
 point: dict, optional
Dict of variable values on which random values are to be conditioned (uses default point if not specified).
 size: int or tuple of ints, optional
Desired size of random sample (returns one sample if not specified).
 Returns
 array
Examples
with pm.Model(): mu = np.array([1.0, 0.0]) cov = np.array([[1.0, 0.0], [0.0, 2.0]]) # draw one sample from a 2dimensional Gaussian random walk with 10 timesteps sample = MvGaussianRandomWalk(mu, cov, shape=(10, 2)).random() # draw three samples from a 2dimensional Gaussian random walk with 10 timesteps sample = MvGaussianRandomWalk(mu, cov, shape=(10, 2)).random(size=3) # draw four samples from a 2dimensional Gaussian random walk with 10 timesteps, # indexed with a (2, 2) array sample = MvGaussianRandomWalk(mu, cov, shape=(10, 2)).random(size=(2, 2))
 class pymc3.distributions.timeseries.MvStudentTRandomWalk(name, *args, **kwargs)¶
Multivariate Random Walk with StudentT innovations
 Parameters
 nu: degrees of freedom
 mu: tensor
innovation drift, defaults to 0.0
 cov: tensor
pos def matrix, innovation covariance matrix
 tau: tensor
pos def matrix, inverse covariance matrix
 chol: tensor
Cholesky decomposition of covariance matrix
 init: distribution
distribution for initial value (Defaults to Flat())
Creates a PyMC distribution object.
 Parameters
 shapetuple
Output shape of the RV. Forwarded to the Theano TensorType of this RV.
 dtype
Forwarded to the Theano TensorType of this RV.
 initvalnp.ndarray
Initial value for this RV. In PyMC 4.0.0 this will no longer assign test values to the tensors.
 defaultstuple
 transformpm.Transform
 broadcastabletuple
Forwarded to the Theano TensorType of this RV.
 dimstuple
Ignored.
 testvalnp.ndarray
The old way of specifying initial values assigning testvalues.
Deprecated
Parameter testval deprecated since 3.11.5