StateSpaceTimeSeries#
- class causalpy.pymc_models.StateSpaceTimeSeries[source]#
State-space time series model using pymc_extras.statespace.structural.
- Parameters:
level_order (int, optional) – Order of the local level/trend component. Defaults to 2.
seasonal_length (int, optional) – Seasonal period (e.g., 12 for monthly data with annual seasonality). Defaults to 12.
trend_component (optional) – Custom state-space trend component.
seasonality_component (optional) – Custom state-space seasonal component.
sample_kwargs (dict, optional) – Kwargs passed to pm.sample.
mode (str, optional) – Mode passed to build_statespace_graph (e.g., “JAX”).
Methods
StateSpaceTimeSeries.__init__
([level_order, ...])StateSpaceTimeSeries.add_coord
(name[, ...])Register a dimension coordinate with the model.
StateSpaceTimeSeries.add_coords
(coords, *[, ...])Vectorized version of
Model.add_coord
.Add a random graph variable to the named variables of the model.
StateSpaceTimeSeries.build_model
(X, y, coords)Build the PyMC state-space model. coords must include:
StateSpaceTimeSeries.check_start_vals
(start, ...)Check that the logp is defined and finite at the starting point.
StateSpaceTimeSeries.compile_d2logp
([vars, ...])Compiled log probability density hessian function.
StateSpaceTimeSeries.compile_dlogp
([vars, ...])Compiled log probability density gradient function.
StateSpaceTimeSeries.compile_fn
(outs, *[, ...])Compiles a PyTensor function.
StateSpaceTimeSeries.compile_logp
([vars, ...])Compiled log probability density function.
Clone the model.
StateSpaceTimeSeries.create_value_var
(...[, ...])Create a
TensorVariable
that will be used as the random variable's "value" in log-likelihood graphs.StateSpaceTimeSeries.d2logp
([vars, ...])Hessian of the models log-probability w.r.t.
StateSpaceTimeSeries.debug
([point, fn, verbose])Debug model function at point.
StateSpaceTimeSeries.dlogp
([vars, jacobian])Gradient of the models log-probability w.r.t.
Evaluate shapes of untransformed AND transformed free variables.
StateSpaceTimeSeries.fit
(X, y, coords)Fit the model, drawing posterior samples.
StateSpaceTimeSeries.initial_point
([random_seed])Compute the initial point of the model.
StateSpaceTimeSeries.logp
([vars, jacobian, sum])Elemwise log-probability of the model.
Compile a PyTensor function that computes logp and gradient.
StateSpaceTimeSeries.make_obs_var
(rv_var, ...)Create a TensorVariable for an observed random variable.
Check if name has prefix and adds if needed.
Check if name has prefix and deletes if needed.
StateSpaceTimeSeries.point_logps
([point, ...])Compute the log probability of point for all random variables in the model.
StateSpaceTimeSeries.predict
(X, coords[, ...])Wrapper around forecast: expects coords with 'datetime_index' of future points.
StateSpaceTimeSeries.profile
(outs, *[, n, ...])Compile and profile a PyTensor function which returns
outs
and takes values of model vars as a dict as an argument.Register a data variable with the model.
StateSpaceTimeSeries.register_rv
(rv_var, name, *)Register an (un)observed random variable with the model.
Clone and replace random variables in graphs with their value variables.
StateSpaceTimeSeries.score
(X, y, coords)Compute R^2 between observed and mean forecast.
StateSpaceTimeSeries.set_data
(name, values)Change the values of a data variable in the model.
StateSpaceTimeSeries.set_dim
(name, new_length)Update a mutable dimension.
StateSpaceTimeSeries.set_initval
(rv_var, initval)Set an initial value (strategy) for a random variable.
StateSpaceTimeSeries.to_graphviz
(*[, ...])Produce a graphviz Digraph from a PyMC model.
Attributes
basic_RVs
List of random variables the model is defined in terms of.
continuous_value_vars
All the continuous value variables in the model.
coords
Coordinate values for model dimensions.
datalogp
PyTensor scalar of log-probability of the observed variables and potential terms.
dim_lengths
The symbolic lengths of dimensions in the model.
discrete_value_vars
All the discrete value variables in the model.
isroot
observedlogp
PyTensor scalar of log-probability of the observed variables.
parent
potentiallogp
PyTensor scalar of log-probability of the Potential terms.
prefix
root
unobserved_RVs
List of all random variables, including deterministic ones.
unobserved_value_vars
List of all random variables (including untransformed projections), as well as deterministics used as inputs and outputs of the model's log-likelihood graph.
value_vars
List of unobserved random variables used as inputs to the model's log-likelihood (which excludes deterministics).
varlogp
PyTensor scalar of log-probability of the unobserved random variables (excluding deterministic).
varlogp_nojac
PyTensor scalar of log-probability of the unobserved random variables (excluding deterministic) without jacobian term.
- __init__(level_order=2, seasonal_length=12, trend_component=None, seasonality_component=None, sample_kwargs=None, mode='JAX')[source]#
- classmethod __new__(*args, **kwargs)#