simsmooth
Bayesian nonlinear non-Gaussian state-space model simulation smoother
Since R2024a
Syntax
Description
simsmooth
provides random paths of states drawn from the
posterior smoothed state distribution, which is the distribution of the states conditioned on
model parameters Θ and the full-sample response data, of a Bayesian nonlinear non-Gaussian
state-space model (bnlssm
).
To draw state paths from the posterior smoothed state distribution,
simsmooth
uses the nonlinear forward-filtering,
backward-sampling method (FFBS), in which it implements sequential Monte Carlo
(SMC) to perform forward filtering, and then it resamples and reweights
particles (weighted random samples) generated by SMC to perform
backward sampling.
returns a randomly drawn path of states, simulated from the posterior smoothed state
distribution, by applying the simulation smoother to the input Bayesian nonlinear
non-Gaussian state-space model and responses data. X
= simsmooth(Mdl
,Y
,params
)simsmooth
uses
FFBS to obtain the random path from the posterior smoothed state distribution.
simsmooth
evaluates the parameter map
Mdl.ParamMap
by using the input vector of parameter values.
specifies additional options using one or more name-value arguments. For example,
X
= simsmooth(Mdl
,Y
,params
,Name=Value
)simsmooth(Mdl,Y,params,NumPaths=1e4,Resample="residual")
specifies
generating 1e4
random paths and to resample residuals.
[
additionally returns the following quantities using any of the input-argument combinations
in the previous syntaxes:X
,OutputFilter
,x0
] = simsmooth(___)
OutputFilter
— SMC forward filtering results by sampling time containing the following quantities:Approximate loglikelihood values associated with the input data, input parameters, particles, and posterior state filtering distribution
Filter estimate of state-distribution means
Filter estimate of state-distribution covariance
State particles and corresponding weights that approximate the filtering distribution
Effective sample size
Flags indicating which data the software used to filter
Flags indicating resampling
x0
— Simulation-smoothed initial state, computed only when you request the this output
Examples
Input Arguments
Output Arguments
Tips
Smoothing has several advantages over filtering.
The smoothed state estimator is more accurate than the online filter state estimator because it is based on the full-sample data, rather than only observations up to the estimated sampling time.
A stable approximation to the gradient of the loglikelihood function, which is important for numerical optimization, is available from the smoothed state samples of the simulation smoother (finite differences of the approximated loglikelihood computed from the filter state estimates is numerically unstable).
You can use the simulation smoother to perform Bayesian estimation of the nonlinear state-space model via the Metropolis-within-Gibbs sampler.
Unless you set
Cutoff=0
,simsmooth
resamples particles according to the specified resampling methodResample
. Although resampling particles with high weights improves the results of the SMC, you should also allow the sampler traverse the proposal distribution to obtain novel, high-weight particles. To do this, experiment withCutoff
.Avoid an arbitrary choice of the initial state distribution.
bnlssm
functions generate the initial particles from the specified initial state distribution, which impacts the performance of the nonlinear filter. If the initial state specification is bad enough, importance weights concentrate on a small number of particles in the first SMC iteration, which might produce unreasonable filtering results. This vulnerability of the nonlinear model behavior contrasts with the stability of the Kalman filter for the linear model, in which the initial state distribution usually has little impact on the filter because the prior is washed out as it processes data.
Algorithms
simsmooth
accommodates missing data by not updating filtered state estimates corresponding to missing observations. In other words, suppose there is a missing observation at period t. Then, the state forecast for period t based on the previous t – 1 observations and filtered state for period t are equivalent.
References
[5] Fernández-Villaverde, Jesús, and Juan F. Rubio-Ramírez. "Estimating Macroeconomic Models: A Likelihood Approach." Review of Economic Studies 70(October 2007): 1059–1087. https://doi.org/10.1111/j.1467-937X.2007.00437.x.
Version History
Introduced in R2024a