How do I estimate a state-space model using ParamMap?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Shantanu Dixit
2024-8-23
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Standard State-Space Model 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!