| 1 |
//Test mh_recover function for RW-MH when load_mh_file was also used |
| 2 |
//Previous chain did not fill last mh_file so mh_recover needs to fill that file |
| 3 |
|
| 4 |
@#include "fs2000.common.inc" |
| 5 |
|
| 6 |
options_.MaxNumberOfBytes=2000*11*8/4; |
| 7 |
estimation(order=1, datafile='../fsdat_simul',nobs=192, silent_optimizer,loglinear, mh_replic=999, mh_nblocks=2, mh_jscale=0.8); |
| 8 |
estimation(order=1,mode_compute=0,mode_file='fs2000_recover_2/Output/fs2000_recover_2_mode', datafile='../fsdat_simul',nobs=192, loglinear, load_mh_file,mh_replic=1002, mh_nblocks=2, mh_jscale=0.8); |
| 9 |
copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.dname '_mh1_blck1.mat']) |
| 10 |
copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat'],[M_.dname '_mh3_blck2.mat']) |
| 11 |
copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat'],[M_.dname '_mh4_blck2.mat']) |
| 12 |
copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh5_blck2.mat'],[M_.dname '_mh5_blck2.mat']) |
| 13 |
delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat']) |
| 14 |
delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat']) |
| 15 |
delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh5_blck2.mat']) |
| 16 |
|
| 17 |
estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file='fs2000_recover_2/Output/fs2000_recover_2_mode', nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover); |
| 18 |
|
| 19 |
%check first unaffected chain |
| 20 |
temp1=load([M_.dname '_mh1_blck1.mat']); |
| 21 |
temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat']); |
| 22 |
|
| 23 |
if max(max(abs(temp1.x2-temp2.x2)))>1e-10 |
| 24 |
error('Draws of unaffected chain are not the same') |
| 25 |
end |
| 26 |
|
| 27 |
%check second, affected chain with last unaffected file |
| 28 |
temp1=load([M_.dname '_mh3_blck2.mat']); |
| 29 |
temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat']); |
| 30 |
|
| 31 |
if max(max(abs(temp1.x2-temp2.x2)))>1e-10 |
| 32 |
error('Draws of affected chain''s unaffected files are not the same') |
| 33 |
end |
| 34 |
|
| 35 |
if ~isoctave |
| 36 |
%check second, affected chain with affected file |
| 37 |
temp1=load([M_.dname '_mh4_blck2.mat']); |
| 38 |
temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat']); |
| 39 |
|
| 40 |
if max(max(abs(temp1.x2-temp2.x2)))>1e-10 |
| 41 |
error('Draws of affected chain''s affected files are not the same') |
| 42 |
end |
| 43 |
|
| 44 |
%check second, affected chain with affected file |
| 45 |
temp1=load([M_.dname '_mh5_blck2.mat']); |
| 46 |
temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh5_blck2.mat']); |
| 47 |
|
| 48 |
if max(max(abs(temp1.x2-temp2.x2)))>1e-10 |
| 49 |
error('Draws of affected chain''s affected files are not the same') |
| 50 |
end |
| 51 |
end |