| 1 | % name random variables |
|---|
| 2 | y = RV({'y'},1); |
|---|
| 3 | z = RV({'z'},1); |
|---|
| 4 | u = RV({'u'},1); |
|---|
| 5 | |
|---|
| 6 | % create f(y_t| z_{t-1}, z_{t-2}) |
|---|
| 7 | fy.class = 'mlnorm<ldmat>'; |
|---|
| 8 | fy.rv = y; |
|---|
| 9 | fy.rvc = RVtimes([z,z], [0, -1]); |
|---|
| 10 | fy.A = [1.8, -0.9]; |
|---|
| 11 | fy.const = 0.2; |
|---|
| 12 | fy.R = 1e-2; |
|---|
| 13 | |
|---|
| 14 | fz.class = 'mlnorm<ldmat>'; |
|---|
| 15 | fz.rv = z; |
|---|
| 16 | fz.rvc = RVtimes([u,u], [0, -1]); |
|---|
| 17 | fz.A = [1.8, -0.9]; |
|---|
| 18 | fz.const = -0.2; |
|---|
| 19 | fz.R = 1e-2; |
|---|
| 20 | |
|---|
| 21 | fu.class = 'enorm<ldmat>'; |
|---|
| 22 | fu.rv = u; |
|---|
| 23 | fu.mu = [0]; |
|---|
| 24 | fu.R = 0.001; |
|---|
| 25 | |
|---|
| 26 | f.class = 'mprod'; |
|---|
| 27 | f.pdfs = {fy,fz,fu}; |
|---|
| 28 | |
|---|
| 29 | DS.class = 'PdfDS'; |
|---|
| 30 | DS.pdf = f; |
|---|
| 31 | |
|---|
| 32 | % create ARX estimator |
|---|
| 33 | A1.class = 'ARX'; |
|---|
| 34 | A1.rv = y; |
|---|
| 35 | A1.rgr = RVtimes([z,z],[0,-1]) ; % correct structure is {y,y} |
|---|
| 36 | A1.options ='logfull,logll'; |
|---|
| 37 | A1.frg = 0.95; |
|---|
| 38 | A1.constant = 1; |
|---|
| 39 | |
|---|
| 40 | A2=A1; |
|---|
| 41 | A2.rv = z; |
|---|
| 42 | A2.rgr = RVtimes([u,u],[0,-1]) ; % correct structure is {y,y} |
|---|
| 43 | |
|---|
| 44 | [M,Set]=estimator(DS,{A1,A2},struct('ndat',100)); |
|---|
| 45 | |
|---|
| 46 | %% post-merging |
|---|
| 47 | |
|---|
| 48 | Merger.class='merger_mix'; |
|---|
| 49 | Merger.method='lognormal'; |
|---|
| 50 | Merger.beta=1.2; |
|---|
| 51 | Merger.ncoms=20; |
|---|
| 52 | Merger.stop_niter=10; |
|---|
| 53 | Merger.effss_coef=0.9; |
|---|
| 54 | |
|---|
| 55 | support.class='discrete_support'; |
|---|
| 56 | support.epdf= struct('class','enorm<ldmat>','mu',[1,1,1,1,0.1],'R',eye(5)); |
|---|
| 57 | support.npoints=[100]; |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 62 | % plot results |
|---|
| 63 | ndat = size(M.DS_u,1); |
|---|
| 64 | |
|---|
| 65 | true_theta1 = [fy.A fy.const]; |
|---|
| 66 | true_theta2 = [fz.A fy.const]; |
|---|
| 67 | true_R = fy.R; |
|---|
| 68 | |
|---|
| 69 | A1_mean = zeros(4,ndat); |
|---|
| 70 | A2_mean = zeros(4,ndat); |
|---|
| 71 | MG_mean = zeros(5,ndat); |
|---|
| 72 | |
|---|
| 73 | for t=1:ndat |
|---|
| 74 | f1=Set.Est0_apost{t}; |
|---|
| 75 | f1.rv = RV({'a','b','c','r'}); |
|---|
| 76 | f2=Set.Est1_apost{t}; |
|---|
| 77 | f2.rv = RV({'a','b','d','r'}); |
|---|
| 78 | |
|---|
| 79 | [res,ftilde] = merger({f1,f2},support,Merger); |
|---|
| 80 | |
|---|
| 81 | A1_mean(:,t) = epdf_mean(f1); |
|---|
| 82 | A2_mean(:,t) = epdf_mean(f2); |
|---|
| 83 | MG_mean(:,t) = epdf_mean(ftilde); |
|---|
| 84 | end; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | figure(1); |
|---|
| 88 | subplot(3,1,1); |
|---|
| 89 | plot(M.DS_y); |
|---|
| 90 | title('y'); |
|---|
| 91 | |
|---|
| 92 | subplot(3,1,2); |
|---|
| 93 | plot(M.DS_z); |
|---|
| 94 | title('z') |
|---|
| 95 | |
|---|
| 96 | subplot(3,1,2); |
|---|
| 97 | plot(M.DS_u); |
|---|
| 98 | title('u') |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | figure(2) |
|---|
| 102 | subplot(2,2,1); |
|---|
| 103 | plot(A1_mean'); |
|---|
| 104 | subplot(2,2,2); |
|---|
| 105 | plot(A2_mean'); |
|---|
| 106 | subplot(2,2,3); |
|---|
| 107 | plot(MG_mean'); |
|---|