root/applications/bdmtoolbox/tutorial/userguide/partfrg_estim.m @ 1195

Revision 1100, 2.0 kB (checked in by smidl, 14 years ago)

marg ARXpartialforg

Line 
1clear all
2% load data created by the MpdfDS_example
3load pdfds_results
4
5DS.class   = 'MemDS';
6DS.Data    = Data;
7DS.drv     = drv;
8
9
10%%%%%% ARX estimator conditioned on frg
11
12A1.class = 'ARXpartialforg';
13A1.yrv = y;
14A1.rv = RV({'theta','r'},[2,1]);
15A1.rgr = RVtimes([y,u],[-3,-1]) ;
16A1.log_level = 'logbounds';
17A1.constant = 0;
18A1.name = 'A1';
19
20Apri =A1;
21Apri.class = 'ARX';
22DSpri = DS;
23DSpri.Data = DS.Data(:,1:6);
24% get decent prior -- estimate with data first
25[Dum,post]=estimator(DSpri,{Apri});
26
27A1.prior = post.estimators{1}.posterior;
28
29% we have 2 parameters - i.e. 4 hypotheses
30
31%%%%%% Random walk on frg - Dirichlet
32walk.class = 'mDirich';         % random walk on coefficient phi
33walk.rv    = RV({'phi'},4);       % 2D random walk - frg is the first element
34walk.k     = 0.001;              % width of the random walk
35walk.betac = 0.1*ones(1,4);         % stabilizing elememnt of random walk
36
37%%%%%% Particle
38p.class = 'MarginalizedParticle';
39p.parameter_pdf = walk;         % Random walk is the parameter evolution model
40p.bm    = A1;
41
42% prior on ARX
43%%%%%% Combining estimators in Marginalized particle filter
44E.class = 'PF';
45E.particle = p;                    % ARX is the analytical part
46E.res_threshold = 0.7;             % resampling parameter
47E.n = 100;                           % number of particles
48E.prior.class = 'eBeta';         % prior on non-linear part
49E.prior.alpha = 5*ones(1,4); %
50E.prior.beta  = ones(1,4); %
51E.log_level = 'logbounds,logweights';
52E.name = 'MPF';
53
54[M,Str]=estimator(DS,{E});
55
56%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57% plot results
58ndat = size(M.DS_dt_u,1);
59
60figure(1);
61subplot(2,2,1);
62plotestimates(true_theta, M.MPF_apost_mean_theta, M.MPF_apost_lbound_theta, M.MPF_apost_ubound_theta);
63title(' Regression parameters \theta')
64set(gca,'YLim',[-1.5,1]);
65
66subplot(2,2,2);
67plotestimates(true_R, M.MPF_apost_mean_r,M.MPF_apost_lbound_r,M.MPF_apost_ubound_r);
68title('Variance parameters r')
69
70subplot(2,2,3);
71plotestimates(1, M.MPF_apost_mean_phi(:,1),M.MPF_apost_lbound_phi(:,1),M.MPF_apost_ubound_phi(:,1));
72title('Forgetting factor')
73
74
Note: See TracBrowser for help on using the browser.