[934] | 1 | clear all |
---|
[640] | 2 | % load data created by the MpdfDS_example |
---|
[709] | 3 | load pdfds_results |
---|
[640] | 4 | |
---|
| 5 | DS.class = 'MemDS'; |
---|
| 6 | DS.Data = Data; |
---|
| 7 | DS.drv = drv; |
---|
| 8 | |
---|
| 9 | %%%%%% ARX estimator conditioned on frg |
---|
| 10 | |
---|
| 11 | A1.class = 'ARXfrg'; |
---|
| 12 | A1.rv = y; |
---|
| 13 | A1.rgr = RVtimes([y,u],[-3,-1]) ; |
---|
[924] | 14 | A1.log_level = 'logbounds'; |
---|
[904] | 15 | A1.frg = 0.98; |
---|
[640] | 16 | A1.name = 'A1'; |
---|
| 17 | |
---|
[895] | 18 | |
---|
[640] | 19 | %%%%%% Random walk on frg - Dirichlet |
---|
| 20 | phi_pdf.class = 'mDirich'; % random walk on coefficient phi |
---|
[700] | 21 | phi_pdf.rv = RV({'phi','1_phi'}); % 2D random walk - frg is the first element |
---|
[640] | 22 | phi_pdf.k = 0.01; % width of the random walk |
---|
[895] | 23 | phi_pdf.betac = [0.1 0.1]; % stabilizing elememnt of random walk |
---|
[640] | 24 | |
---|
[895] | 25 | %%%%%% Particle |
---|
| 26 | p.class = 'MarginalizedParticle'; |
---|
| 27 | p.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model |
---|
| 28 | p.bm = A1; |
---|
| 29 | |
---|
| 30 | % prior on ARX |
---|
[640] | 31 | %%%%%% Combining estimators in Marginalized particle filter |
---|
[895] | 32 | E.class = 'PF'; |
---|
| 33 | E.particle = p; % ARX is the analytical part |
---|
[950] | 34 | E.res_threshold = 0.90; % resampling parameter |
---|
[900] | 35 | E.n = 100; % number of particles |
---|
[640] | 36 | E.prior.class = 'eDirich'; % prior on non-linear part |
---|
[661] | 37 | E.prior.beta = [2 1]; % |
---|
[950] | 38 | E.log_level = 'logbounds,logweights,logmeans'; |
---|
[640] | 39 | E.name = 'MPF'; |
---|
| 40 | |
---|
[900] | 41 | [M,Str]=estimator(DS,{E}); |
---|
[640] | 42 | |
---|
| 43 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 44 | % plot results |
---|
[924] | 45 | ndat = size(M.DS_dt_u,1); |
---|
[640] | 46 | |
---|
| 47 | figure(1); |
---|
| 48 | subplot(2,2,1); |
---|
[924] | 49 | plotestimates(true_theta, M.MPF_apost_mean_theta, M.MPF_apost_lbound_theta, M.MPF_apost_ubound_theta); |
---|
[640] | 50 | title(' Regression parameters \theta') |
---|
| 51 | set(gca,'YLim',[-1.5,1]); |
---|
| 52 | |
---|
| 53 | subplot(2,2,2); |
---|
[924] | 54 | plotestimates(true_R, M.MPF_apost_mean_r,M.MPF_apost_lbound_r,M.MPF_apost_ubound_r); |
---|
[640] | 55 | title('Variance parameters r') |
---|
| 56 | |
---|
| 57 | subplot(2,2,3); |
---|
[924] | 58 | plotestimates(1, M.MPF_apost_mean_phi(:,1),M.MPF_apost_lbound_phi(:,1),M.MPF_apost_ubound_phi(:,1)); |
---|
[640] | 59 | title('Forgetting factor') |
---|
| 60 | |
---|
[950] | 61 | |
---|
| 62 | for i=1:E.n |
---|
| 63 | |
---|