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

    %% Display State-Space Model and Initial Values
% Define a state-space model containing two independent, autoregressive
% states, and where the observations are the deterministic sum of the two states.
% Symbolically, the system of equations is
%
% $$\left[
% {\begin{array}{*{20}{c}}{{x_{t,1}}}\\{{x_{t,2}}}\end{array}} \right] =
% \left[ {\begin{array}{*{20}{c}}{{\phi _1}}&0\\0&{{\phi _2}}\end{array}}
% \right]\left[ {\begin{array}{*{20}{c}}{{x_{t - 1,1}}}\\{{x_{t -
% 1,2}}}\end{array}} \right] + \left[
% {\begin{array}{*{20}{c}}{\sigma_1} & 0\\0 & \sigma_2\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&1\end{array}}
% \right]\left[
% {\begin{array}{*{20}{c}}{{x_{t,1}}}\\{{x_{t,2}}}\end{array}}
% \right].$$
%
%%
% Specify the state-transition matrix.
A = [NaN 0; 0 NaN];
%%
% Specify the state-disturbance-loading matrix.
B = [NaN 0; 0 NaN];
%%
% Specify the measurement-sensitivity matrix.
C = [1 1];
%%
% Specify an empty matrix for the observation disturbance matrix.
D = [];
%%
% Use |ssm| to define the state-space model.  Specify the initial state means
% and covariance matrix to as unknown parameters.  Specify that the states
% are stationary.
Mean0 = nan(2,1);
Cov0 = nan(2,2);
StateType = zeros(2,1);
Mdl = ssm(A,B,C,D,'Mean0',Mean0,'Cov0',Cov0,'StateType',StateType);
%%
% |Mdl| is an |ssm| model containing unknown parameters.
%%
% Use |disp| to display the state-space model.  Specify initial values for
% the unknown parameters and the initial state means and covariance matrix
% as follows:
%
% * $\phi_{1,0} = \phi_{2,0} = 0.1$.
% * $\sigma_{1,0} = \sigma_{2,0} = 0.2$.
% * $x_{1,0} = 1$ and $x_{2,0} = 0.5$.
% * $\Sigma_{x_{1,0},x_{2,0}} = I_2$.
%
params = [0.1; 0.1; 0.2; 0.2; 1; 0.5; 1; 0; 0; 1];
disp(Mdl,params)