www.gusucode.com > econ 案例源码程序 matlab代码 > econ/ExplicitlySpecifyAStateSpaceModelUnknownParametersExample.m

    %% Explicitly Create State-Space Model Containing Unknown Parameters
% This example shows how to create a time-invariant, state-space model
% containing unknown parameter values using |ssm|.
%%
% Define a state-space model containing two dependent MA(1) states, and
% an additive-error observation model. Symbolically, the equation is
%
% $$\left[
% \begin{array}{*{20}{c}}x_{t,1}\\x_{t,2}\\x_{t,3}\\x_{t,4}\end{array}
% \right] = \left[
% {\begin{array}{*{20}{c}}0&\theta_1&\lambda_1&0\\0&0&0&0\\0&0&0&\theta_3\\0&0&0&0\end{array}}
% \right]\left[ \begin{array}{*{20}{c}}x_{t - 1,1}\\x_{t -
% 1,2}\\x_{t - 1,3}\\x_{t - 1,4}\end{array}\right] + \left[
% \begin{array}{*{20}{c}}{\sigma_1} & 0\\1 & 0 \\0 &\sigma_2\\
% 0&1\end{array} \right]\left[
% \begin{array}{*{20}{c}}u_{t,1}\\u_{t,2}\end{array} \right]$$
%
% $${y_t} = \left[\begin{array}{*{20}{c}}1& 0 & 0 & 0\\0&0&1&0\end{array}
% \right]\left[
% \begin{array}{*{20}{c}}x_{t,1}\\x_{t,2}\\x_{t,3}\\x_{t,4}\end{array}
% \right] + \left[ {\begin{array}{*{20}{c}}\sigma_3& 0\\ 0&\sigma_4\end{array}}
% \right]\left[\begin{array}{*{20}{c}}\varepsilon_{t,1}\\\varepsilon_{t,2}\end{array}\right].$$
%
% Note that the states $x_{t,1}$ and $x_{t,3}$ are the two dependent MA(1)
% processes.  The states $x_{t,2}$ and $x_{t,4}$ help construct the
% lag-one, MA effects. For example, $x_{t,2}$ picks up the first disturbance
% ($u_{t,1}$), and $x_{t,1}$ picks up $x_{t - 1,2} = u_{t - 1,1}$.  In all,
% $x_{t,1} = \lambda_1x_{t-1,3} + u_{t,1} + \theta_1u_{t-1,1}$, which is an
% MA(1) with $x_{t-1,3}$ as an input.
%%
% Specify the state-transition coefficient matrix. Use |NaN| values to
% indicate unknown parameters.

% Copyright 2015 The MathWorks, Inc.

A = [0 NaN NaN 0; 0 0 0 0; 0 0 0 NaN; 0 0 0 0];
%%
% Specify the state-disturbance-loading coefficient matrix.
B = [NaN 0; 1 0; 0 NaN; 0 1];
%%
% Specify the measurement-sensitivity coefficient matrix.
C = [1 0 0 0; 0 0 1 0];
%%
% Specify the observation-innovation coefficient matrix.
D = [NaN 0; 0 NaN];
%%
% Use |ssm| to define the state-space model.
Mdl = ssm(A,B,C,D)
%%
% |Mdl| is an |ssm| model containing unknown parameters.  A detailed
% summary of |Mdl| prints to the Command Window. It is good practice to
% verify that the state and observations equations are correct.
%%
% Pass |Mdl| and data to |estimate| to estimate the unknown parameters.