[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'; |
---|
[964] | 12 | A1.yrv = y; |
---|
| 13 | A1.rv = RV({'theta','r'},[3,1]); |
---|
[640] | 14 | A1.rgr = RVtimes([y,u],[-3,-1]) ; |
---|
[924] | 15 | A1.log_level = 'logbounds'; |
---|
[904] | 16 | A1.frg = 0.98; |
---|
[1001] | 17 | % A1.prior.class='egiw'; |
---|
| 18 | % A1.prior.dimx=1; |
---|
| 19 | % A1.prior.nu=10; |
---|
| 20 | % A1.prior.V=diag([1,0.01,0.01,0.01]); |
---|
[640] | 21 | A1.name = 'A1'; |
---|
| 22 | |
---|
[895] | 23 | |
---|
[640] | 24 | %%%%%% Random walk on frg - Dirichlet |
---|
| 25 | phi_pdf.class = 'mDirich'; % random walk on coefficient phi |
---|
[700] | 26 | phi_pdf.rv = RV({'phi','1_phi'}); % 2D random walk - frg is the first element |
---|
[964] | 27 | phi_pdf.k = 0.001; % width of the random walk |
---|
[895] | 28 | phi_pdf.betac = [0.1 0.1]; % stabilizing elememnt of random walk |
---|
[640] | 29 | |
---|
[895] | 30 | %%%%%% Particle |
---|
| 31 | p.class = 'MarginalizedParticle'; |
---|
| 32 | p.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model |
---|
| 33 | p.bm = A1; |
---|
| 34 | |
---|
| 35 | % prior on ARX |
---|
[640] | 36 | %%%%%% Combining estimators in Marginalized particle filter |
---|
[895] | 37 | E.class = 'PF'; |
---|
| 38 | E.particle = p; % ARX is the analytical part |
---|
[1001] | 39 | E.res_threshold = 0.7; % resampling parameter |
---|
| 40 | E.n = 10; % number of particles |
---|
[640] | 41 | E.prior.class = 'eDirich'; % prior on non-linear part |
---|
[1001] | 42 | E.prior.beta = [10 1]; % |
---|
[964] | 43 | E.log_level = 'logbounds,logweights,logmeans,logvars'; |
---|
[640] | 44 | E.name = 'MPF'; |
---|
| 45 | |
---|
[964] | 46 | A2=A1; |
---|
| 47 | A2.class='ARX'; |
---|
| 48 | A2.frg=1.0; |
---|
[1001] | 49 | A2.name = 'MPFf'; |
---|
[640] | 50 | |
---|
[964] | 51 | [M,Str]=estimator(DS,{E,A2}); |
---|
| 52 | |
---|
[640] | 53 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 54 | % plot results |
---|
[924] | 55 | ndat = size(M.DS_dt_u,1); |
---|
[640] | 56 | |
---|
| 57 | figure(1); |
---|
| 58 | subplot(2,2,1); |
---|
[924] | 59 | plotestimates(true_theta, M.MPF_apost_mean_theta, M.MPF_apost_lbound_theta, M.MPF_apost_ubound_theta); |
---|
[640] | 60 | title(' Regression parameters \theta') |
---|
| 61 | set(gca,'YLim',[-1.5,1]); |
---|
| 62 | |
---|
| 63 | subplot(2,2,2); |
---|
[924] | 64 | plotestimates(true_R, M.MPF_apost_mean_r,M.MPF_apost_lbound_r,M.MPF_apost_ubound_r); |
---|
[640] | 65 | title('Variance parameters r') |
---|
| 66 | |
---|
| 67 | subplot(2,2,3); |
---|
[924] | 68 | plotestimates(1, M.MPF_apost_mean_phi(:,1),M.MPF_apost_lbound_phi(:,1),M.MPF_apost_ubound_phi(:,1)); |
---|
[640] | 69 | title('Forgetting factor') |
---|
| 70 | |
---|
[950] | 71 | |
---|