How do I estimate a state-space model using ParamMap?

2 visualizaciones (últimos 30 días)
Ed
Ed el 28 de Jul. de 2023
Respondida: Shantanu Dixit el 23 de Ag. de 2024
I created an implicit state-space model Md1 with a function ParamMap.
When I use the command EstMd1=estimate(Md1,Y,parms0) where Y is my observed data and params0 is a vector containing my initial values for the unknow state I get the error "Length of the state type vector must agree with the number of states."
Is the bolded command the correct syntax for estimating implicit state-space model?
(note that when I estimate the model by creating the state-space matrices explicitly in the main program it works and so I know that the number of states agrees with the length of the state vector)
function [A,B,C,D,Mean0,Cov0,StateType] = ParamMap(parms0)
var1=exp(parms0(2)); % Positive variance constraint
var2=exp(parms0(3));
A=[1 0; 0 parms0(1)];
C=[1 1];
B=[var1 0;0 var2];
D = [];
Mean0 = 0.5;
Cov0 = 10;
StateType = 0;
end

Respuestas (1)

Shantanu Dixit
Shantanu Dixit el 23 de Ag. de 2024
Hi Ed, the error you are encountering is due to the fact both 'Cov0' and 'StateType' are defined in 'ParamMap'. When implicitly creating a model by specifying 'ParamMap', both 'Cov0' and 'StateType' are empty vectors [ ] and are specified by 'estimate' function after estimation.
Refer to the below sample code
% dummy data
Y = randn(100, 1);
parms0 = [0.9, log(0.1), log(0.2)];
function [A, B, C,D, Mean0, Cov0, StateType] = ParamMap(parms0)
var1 = exp(parms0(2));
var2 = exp(parms0(3));
A = [1 0; 0 parms0(1)];
C = [1 1];
B = [var1 0; 0 var2];
D = [];
Mean0 = [0.5; 0.5];
Cov0 = [];
StateType = [];
end
% Create the implicit state-space model
Md1 = ssm(@ParamMap);
% Estimate the model parameters
EstMd1 = estimate(Md1, Y, parms0);
Refer to the following MathWorks documentation for better understanding:

Categorías

Más información sobre Standard State-Space Model en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by