Debian Codegraph @

tests/estimation/MH_recover/fs2000_recover_tmp.mod

raw
1 //Test mh_recover function for RW-MH
2
3 @#include "fs2000.common.inc"
4
5 if ~isoctave
6 estimation(order=1, datafile='../fsdat_simul',nobs=192, mode_compute=0,mode_file=fs2000_recover_tmp_mode,loglinear, mh_replic=1000, mh_nblocks=1, mh_jscale=0.8,posterior_sampler_options=('save_tmp_file',1));
7 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.dname '_mh1_blck1.mat'])
8 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'])
9 copyfile([M_.fname '_mh_tmp_blck1.mat'],[M_.dname filesep 'metropolis' filesep M_.dname '_mh_tmp_blck1.mat'])
10
11 estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file=fs2000_recover_tmp_mode, nobs=192, loglinear, mh_replic=1000, mh_nblocks=1, mh_jscale=0.8,mh_recover);
12
13 %check first unaffected chain
14 temp1=load([M_.dname '_mh1_blck1.mat']);
15 temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat']);
16
17 if max(max(abs(temp1.x2./temp2.x2-1)))>5e-3
18 max(max(abs(temp1.x2./temp2.x2-1)))
19 format long
20 temp1.x2-temp2.x2
21 if max(max(abs(temp1.x2./temp2.x2-1)))>0.05
22 error('Draws of unaffected chain are not the same')
23 else
24 warning('Draws of unaffected chain are not the same')
25 end
26 end
27
28 if max(max(abs(temp1.feval_this_chain-temp2.feval_this_chain)))>1e-6
29 temp1.feval_this_chain
30 temp2.feval_this_chain
31 error('feval_this_chain are not the same')
32 end
33
34 if max(max(abs(temp1.logpo2-temp2.logpo2)))>1e-2
35 max(max(abs(temp1.logpo2-temp2.logpo2)))
36 temp1.logpo2
37 temp2.logpo2
38 error('logpo2 is not the same')
39 end
40
41 if max(max(abs(temp1.accepted_draws_this_file-temp2.accepted_draws_this_file)))>1e-6
42 temp1.accepted_draws_this_file
43 temp2.accepted_draws_this_file
44 error('accepted_draws_this_file are not the same')
45 end
46
47 if max(max(abs(temp1.accepted_draws_this_chain-temp2.accepted_draws_this_chain)))>1e-6
48 temp1.accepted_draws_this_chain
49 temp2.accepted_draws_this_chain
50 error('accepted_draws_this_chain are not the same')
51 end
52 end