DynamicLinearModels.DLMPlot
— TypeDLMPlot
Indicator type for plotting recipe.
DynamicLinearModels.check_dimensions
— Methodcheck_dimensions(F, G[; V, W, Y])
Utility function that checks for dimension mistmatches in the given arguments and returns the dimensions for the observations and for the state-space.
DynamicLinearModels.compute_prior
— Methodcompute_prior(Y, F, m₀, C₀)
Utility function for computing a smart prior that's not informative and at the same does not lead to numerical or visualization issues. Only takes effect if one of m₀
is C₀
is nothing
, otherwise it just returns m₀
and C₀
.
DynamicLinearModels.estimate
— Methodestimate(Y, F, G, η, δ[, m₀, C₀; maxit, ϵ])
Obtains maximum a posteriori estimates for the states and observational covariance matrix for a Dynamic Linear Model (F
, G
), considering a discount factor δ
for the evolutional covariance matrices, and weighted replicates. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior. Parameters maxit
and ϵ
control the maximum number of iterations and the numerical precision for early convergence for the Coordinate Descent algorithm, respectively.
Returns point estimates for the states θ
and point estimate for the covariance matrix V
. Also returns the number of iterations until convergence. If negative, it means the algorithm stopped from reaching the maximum number of iterations.
DynamicLinearModels.estimate
— Methodestimate(Y, F, G, η, δ[, m₀, C₀; maxit, ϵ])
Obtains maximum a posteriori estimates for the states and observational covariance matrix for a Dynamic Linear Model (F
, G
), considering a discount factor δ
for the evolutional covariance matrices, and dynamically weighted replicates. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior. Parameters maxit
and ϵ
control the maximum number of iterations and the numerical precision for early convergence for the Coordinate Descent algorithm, respectively.
Returns point estimates for the states θ
and point estimate for the covariance matrix V
. Also returns the number of iterations until convergence. If negative, it means the algorithm stopped from reaching the maximum number of iterations.
DynamicLinearModels.estimate
— Methodestimate(Y, F, G, δ[, m₀, C₀; maxit, ϵ])
Obtains maximum a posteriori estimates for the states and observational covariance matrix for a Dynamic Linear Model (F
, G
), considering a discount factor δ
for the evolutional covariance matrices. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior. Parameters maxit
and ϵ
control the maximum number of iterations and the numerical precision for early convergence for the Coordinate Descent algorithm, respectively.
Returns point estimates for the states θ
and point estimate for the covariance matrix V
. Also returns the number of iterations until convergence. If negative, it means the algorithm stopped from reaching the maximum number of iterations.
DynamicLinearModels.evolutional_covariances
— Methodevolutional_covariances(Y, F, G, V, η, δ[, m₀, C₀])
Compute the implied values of the evolutional covariances W[1], ..., W[T] when considering a discount factor approach, and weighted replicates.
DynamicLinearModels.evolutional_covariances
— Methodevolutional_covariances(Y, F, G, V, δ[, m₀, C₀])
Compute the implied values of the evolutional covariances W[1], ..., W[T] when considering a discount factor approach, and dynamically weighted replicates.
DynamicLinearModels.evolutional_covariances
— Methodevolutional_covariances(Y, F, G, V, δ[, m₀, C₀])
Compute the implied values of the evolutional covariances W[1], ..., W[T] when considering a discount factor approach.
DynamicLinearModels.extract
— Methodextract(x, index)
Utility function that facilitates fetching the time series as a vector for one the objects used in the package.
If x
is a Vector{Vector{RT}}
it returns [x[t][index] for t = 1:T]
; If x
is a Vector{CovMat{RT}}
it returns [x[t][index,index] for t = 1:T]
.
DynamicLinearModels.fitted
— Methodfitted(F, V, m, C)
Computes the fitted values for the data, for a model with observational matrix F
, evolutional covariance matrix V
, and state means m
and C
. Note that this can be done with the one-step ahead priors, online parameters or, more appropriately, smoother results.
Returns observational means and covariances f
and Q
.
DynamicLinearModels.forecast
— Methodforecast(F, G, V, W, μ, Σ, h)
Filtering routine for the Dynamic Linear Model (F
, G
) where the observational and evolutional covariance matrices V
and W
are known and constant. μ
and Σ
are the mean and covariance matrix for the last state given the most recent information, and h
is the forecasting window.
Returns observational means and covariances f
and Q
.
DynamicLinearModels.forecast
— Methodforecast(F, G, V, δ, μ, Σ, h)
Filtering routine for the Dynamic Linear Model (F
, G
) where the observational covariance matrix V
is known and constants, and evolutional covariance matrices W[1], ..., W[T] are indirectly modeled through a discount factor δ
. μ
and Σ
are the mean and covariance matrix for the last state given the most recent information, and h
is the forecasting window.
Returns observational means and covariances f
and Q
.
DynamicLinearModels.from_matrix
— Methodfrom_matrix(x)
Converts a matrix to a vector of vector.
DynamicLinearModels.kfilter
— Methodkfilter(Y, F, G, V, δ[, m₀, C₀])
Filtering routine for a discount factor Dynamic Linear Model (F
, G
) where the observational covariance matrices V[1], …, V[T]
are known and evolutional covariance matrices W[1], ..., W[T]
are indirectly modelled through a discount factor δ
. See West & Harrison (1996) for further information of the discount factor apporach. Y
is the matrix of observations with T
rows and n
columns. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior.
Returns one-step ahead prior means and covariances a
and R
, and online means and covariances m
and C
.
DynamicLinearModels.kfilter
— Methodkfilter(Y, F, G, V, η, δ[, m₀, C₀])
Filtering routine for a discount factor Dynamic Linear Model (F
, G
) where the observational covariance matrix V
is known and constants and evolutional covariance matrices W[1], ..., W[T]
are indirectly modelled through a discount factor δ
and observations have replications. Y
is the matrix of observations with T
rows and n * nreps
columns, each replicate with a weightη[i]
. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior.
Returns one-step ahead prior means and covariances a
and R
, and online means and covariances m
and C
.
DynamicLinearModels.kfilter
— Methodkfilter(Y, F, G, V, η, δ[, m₀, C₀])
Filtering routine for a discount factor Dynamic Linear Model (F
, G
) where the observational covariance matrix V
is known and constants and evolutional covariance matrices W[1], ..., W[T]
are indirectly modelled through a discount factor δ
and observations have replications. Y
is the matrix of observations with T
rows and n * nreps
columns, each replicate with dynamic weights η[t,i]
. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior.
Returns one-step ahead prior means and covariances a
and R
, and online means and covariances m
and C
.
DynamicLinearModels.kfilter
— Methodkfilter(Y, F, G, V, W[, m₀, C₀])
Filtering routine for the Dynamic Linear Model (F
, G
) where the observational and evolutional covariance matrices V
and W
are known and constant. Y
is the matrix of observations with T
rows and n
columns. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior.
Returns one-step ahead prior means and covariances a
and R
, and online means and covariances m
and C
.
DynamicLinearModels.kfilter
— Methodkfilter(Y, F, G, V, δ[, m₀, C₀])
Filtering routine for a discount factor Dynamic Linear Model (F
, G
) where the observational covariance matrix V
is known and constant and evolutional covariance matrices W[1], ..., W[T]
are indirectly modelled through a discount factor δ
. See West & Harrison (1996) for further information of the discount factor apporach. Y
is the matrix of observations with T
rows and n
columns. Prior parameters m₀
and C₀
may be omitted, in which case compute_prior
kicks in to assign a prior.
Returns one-step ahead prior means and covariances a
and R
, and online means and covariances m
and C
.
DynamicLinearModels.ksmoother
— Methodksmoother(G, a, R, m, C)
Filtering routine for a Dynamic Linear Model ( ⋅, G
), where a
and R
are the filtered one-step ahead prior means and covariances, and m
and C
are the filtered online means and covariances.
Returns the posterior means and covariances s
and S
.
DynamicLinearModels.simulate
— Methodsimulate(F, G, V, W, θ₀, T[, nreps])
Simulates a time-series Dynamic Linear Model specified by the quadruple (F
, G
, V
, W
) with a starting state of θ₁ <- Nₚ(G θ₀, W)
, with T
observations. A parameter nreps
may be passed indicating the number of replicates to be generated. Returns the generated θ
and y
.
Note that the parametrizations being considered in this package is such that y[t] = F * y[t-1] + ϵ
and not the notation from West and Harrison (1996) where y[t] = F' * y[t-1] + ϵ
.
DynamicLinearModels.to_matrix
— Methodto_matrix(x)
Converts a vector of vectors to a matrix.
DynamicLinearModels.CovMat
— TypeCovMat
Alias for symmetric, real valued, dense matrices.
DynamicLinearModels.exclude_low_weights
— Methodexclude_low_weights(Y, η, ϵ)
Internal function which returns a version of the original Y
and η
variables, containing only the observations with weights above ϵ
.
DynamicLinearModels.kfilter_core
— Methodkfilter_core(y, F, G, V, W, a, R)
Internal function which actually performs the computation step.
DynamicLinearModels.kfilter_core
— Methodkfilter_core(y, F, G, V, W, a, R)
Internal function which actually performs the computation step.
RecipesBase.apply_recipe
— Methodplot(::DLMPlot, Y, f, Q[, fh, Qh; factor = 1.64, index = 1])
Recipe for easily plotting the results obtained by the package routines, where Y
is the observations matrix, f
and Q
are results from fitted
, and fh
and Qh
are the results from forecast
. Factor implies the credibility or the credibility intervals interval, e.g. a factor of 1.64 implies a credibility of 90%. Index indicates which observational index is to be plotted.