# Documentation

## Specify a Time-Invariant State-Space Model

This example shows how to specify a time-invariant state-space model by passing a parameter-mapping function describing the model to `ssm` (i.e., implicitly specify a state-space model). The state model is AR(1), and there is no observation error. Set the initial state mean and variance, and specify that the state is stationary.

Create the function `timeInvariantParamMap.m`, which specifies how the parameters in `params` map to the state-space model matrices, the initial state values, and the type of state. Symbolically, the model is

$\begin{array}{c}{x}_{t}=\varphi {x}_{t-1}+\sigma {u}_{t}\\ {y}_{t}=a{x}_{t}\end{array}.$

```function [A,B,C,D,Mean0,Cov0,StateType] = timeInvariantParamMap(params) % Time-invariant state-space model parameter mapping function example. This % function maps the vector params to the state-space matrices (A, B, C, and % D), the initial state value and the initial state variance (Mean0 and % Cov0), and the type of state (StateType). The state model is AR(1) % without observation error. varu1 = exp(params(2)); % Positive variance constraint A = params(1); B = sqrt(vare1); C = params(3); D = []; Mean0 = 0.5; Cov0 = 100; StateType = 0; end ```

Specify the state-space model by passing the function `timeInvariantParamMap` as a function handle to `ssm`.

`Mdl = ssm(@timeInvariantParamMap)`
```Mdl = The state space model is implicitly defined by the function: @timeInvariantParamMap```

The software implicitly defines the state-space model. Usually, you cannot verify state-space models that you implicitly define.

Pass `Mdl` and response data to `estimate` to estimate the model parameters.

Get trial now