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