The default functions work with the latent_factor
class, and are called automatically by analysis
, dglm.update
, dglm.forecast_marginal
, and dglm.forecast_path
when there are latent factors in the model.
To use simulated latent factor values, set the argument analytic=False
in the dglm
methods, and pass in the set of simulated values as phi_samps
. It is not currently supported to use the simulated latent factor values within analysis
.
These functions are called automatically in PyBATS when working with a DGLM that has a latent factor component. The new arguments are:
phi_mu
: Mean vector of the latent factor. Forforecast_path_lf_copula
, it should be a list ofk
mean vectors.phi_sigma
: Variance matrix of the latent factor. Forforecast_path_lf_copula
, it should be a list ofk
variance matrices.
The following extra arguments are only applicable to path forecasting with forecast_path_lf_copula
:
phi_psi
: This is a list ofk-1
covariance matrices $cov(\phi_{t+k}, \phi_{t+j})$. Each element is a numpy array.t_dist
: Boolean. By default, a Gaussian copula is used. If True, then a t-copula is used instead.y
: Future path of observations y. If provided, output will be the forecast density of y.nu
: Degrees of freedom for t-copula.
These functions can be called through dglm.update
, dglm.forecast_marginal
, and dglm.forecast_path
by setting the argument analytic=False
. They represent an alternative method of analysis by working with simulated values of the latent factor. The simulated values are passed into the function as an array phi_samps
, where each row contains a simulated value of the latent factor.
This is a more accurate analysis method because it does not reduce the distribution of the latent factor down to its mean and variance. However, it is also more computationally demanding to work with the simulated values, so there is a trade-off between speed and accuracy.
forecast_joint_marginal_lf_copula
is used to recouple a set of DGLMs which share the same latent factor. In other words, if the same latent factor is used in multiple models, then their forecasts will be correlated. This function allows for joint forecasting across these separated DGLMs.
A classic example comes from retail sales. The latent factor may represent an effect at the total store level - say, customer traffic based on the day-of-week. A separate DGLM models the sales of each individual item. To jointly forecast the sales of many items, the models can all be passed into forecast_joint_marginal_lf_copula
, along with the latent factor mean and variance, to draw joint samples from the forecast distribution.
forecast_joint_marginal_lf_copula_dcmm
behaves similarly to forecast_joint_marginal_lf_copula
, but for a set of related DCMMs instead of related DGLMs.
These functions are for marginal and path forecasting with a latent factor DCMM. They may be accessed as methods from dcmm
.