搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  TommasoBelluzzo-SystemicRisk-2b4ebd0.zip
资料下载链接地址: https://bbs.pinggu.org/a-2933936.html
附件大小:
这个是一个MATLAB 可以计算 CoVaR
SRISK finance-network 的程序;他分享在MATHWORK 公司的程序分享网站以及github网站。

前后有好几个版本,四月份我下载的其他版本。然后最新的这个版本,还可以计算 finance risk spillover 金融风险溢出。
三个代码:第一个为这个版本的主程序 run 里的代码;只给大家看,这个程序不一定能运行到最后,而且电脑最后是6核16G内存的,比如我的4核4G内存的电脑就无法运行第三部分 金融分享溢出。
第二个代码和第三个代码是上一个版本的,我不上传,因为有朋友的数据,我只发给他修改的主程序。大家对比看自己怎么修改主程序。
Tommaso Belluzzo ,意大利人,他这个系列的程序都是用 run.m 代表调用工具箱。

第一个代码,请参阅。
  1. warning('off','all');

  2. spmd
  3. warning('off','all')
  4. end

  5. close('all');
  6. clearvars();
  7. clc();
  8. delete(allchild(0));

  9. [path_base,~,~] = fileparts(mfilename('fullpath'));

  10. if (~strcmpi(path_base(end),filesep()))
  11. path_base = [path_base filesep()];
  12. end

  13. if (~isempty(regexpi(path_base,'Editor')))
  14. path_base_fs = dir(path_base);
  15. is_live = ~all(cellfun(@isempty,regexpi({path_base_fs.name},'LiveEditorEvaluationHelper')));

  16. if (is_live)
  17. pwd_current = pwd();

  18. if (~strcmpi(pwd_current(end),filesep()))
  19. pwd_current = [pwd_current filesep()];
  20. end

  21. while (true)
  22. answer = inputdlg('It looks like the program is being executed in a non-standard mode. Please, confirm or change the root folder of this package:','Manual Input Required',1,{pwd_current});

  23. if (isempty(answer))
  24. return;
  25. end

  26. path_base_new = answer{:};

  27. if (isempty(path_base_new) || strcmp(path_base_new,path_base) || strcmp(path_base_new(1:end-1),path_base) || ~exist(path_base_new,'dir'))
  28. continue;
  29. end

  30. path_base = path_base_new;

  31. break;
  32. end
  33. end
  34. end

  35. if (~strcmpi(path_base(end),filesep()))
  36. path_base = [path_base filesep()];
  37. end

  38. paths_base = genpath(path_base);
  39. paths_base = strsplit(paths_base,';');

  40. for i = numel(paths_base):-1:1
  41. path_current = paths_base{i};

  42. if (~strcmp(path_current,path_base) && isempty(regexpi(path_current,[filesep() 'Scripts'])))
  43. paths_base(i) = [];
  44. end
  45. end

  46. paths_base = [strjoin(paths_base,';') ';'];
  47. addpath(paths_base);

  48. dataset = fullfile(path_base,['Datasets' filesep() 'Example_Large.xlsx']);
  49. data = parse_dataset(dataset);

  50. out_temp_stochastic = fullfile(path_base,['Templates' filesep() 'TemplateStochastic.xlsx']);
  51. out_file_stochastic = fullfile(path_base,['Results' filesep() 'ResultsStochastic.xlsx']);
  52. result_stochastic = run_stochastic(data,out_temp_stochastic,out_file_stochastic,0.95,0.40,0.08,0.40,true);
  53. mat_stochastic = fullfile(path_base,['Results' filesep() 'DataStochastic.mat']);
  54. save(mat_stochastic,'result_stochastic');

  55. pause(2);

  56. out_temp_connectedness = fullfile(path_base,['Templates' filesep() 'TemplateConnectedness.xlsx']);
  57. out_file_connectedness = fullfile(path_base,['Results' filesep() 'ResultsConnectedness.xlsx']);
  58. result_connectedness = run_connectedness(data,out_temp_connectedness,out_file_connectedness,252,0.05,true,0.06,true);
  59. mat_connectedness = fullfile(path_base,['Results' filesep() 'DataConnectedness.mat']);
  60. save(mat_connectedness,'result_connectedness');

  61. pause(2);

  62. out_temp_spillover = fullfile(path_base,['Templates' filesep() 'TemplateSpillover.xlsx']);
  63. out_file_spillover = fullfile(path_base,['Results' filesep() 'ResultsSpillover.xlsx']);
  64. result_spillover = run_spillover(data,out_temp_spillover,out_file_spillover,252,2,4,true,true);
  65. mat_spillover = fullfile(path_base,['Results' filesep() 'DataSpillover.mat']);
  66. save(mat_spillover,'result_spillover');

  67. mat_dataset = fullfile(path_base,['Results' filesep() 'Dataset.mat']);
  68. save(mat_dataset,'data');
复制代码


后面两个我将演示修改主程序,下载ZIP 文件的人记得修改 run.m
  1. warning('off','all');

  2. close('all');
  3. clearvars();
  4. clc();
  5. delete(allchild(0));

  6. [path_base,~,~] = fileparts(mfilename('fullpath'));

  7. if (~strcmpi(path_base(end),filesep()))
  8. path_base = [path_base filesep()];
  9. end

  10. paths_base = genpath(path_base);
  11. addpath(paths_base);

  12. path_dset = strrep('Datasets\Example.xlsx','\',filesep()); % 修改这里替换为你的表格文件名字
  13. path_rpro = strrep('Results\ResultsPRO.xlsx','\',filesep());
  14. path_rnet = strrep('Results\ResultsNET.xlsx','\',filesep());

  15. data = parse_dataset(fullfile(path_base,path_dset));

  16. main_pro(data,fullfile(path_base,path_rpro),0.95,0.40,0.08,true);
  17. pause(2);
  18. main_net(data,fullfile(path_base,path_rnet),0.05,true,true);

  19. save('data.mat','data');

  20. rmpath(paths_base);
复制代码


第二个文件17行我已经注释修改为你的数据文件哪里修改 excel 表格文件名字即可。这里我发一个修改的给你们看,当然没数据。

  1. warning('off','all');

  2. close('all');
  3. clearvars();
  4. clc();
  5. delete(allchild(0));

  6. [path_base,~,~] = fileparts(mfilename('fullpath'));

  7. if (~strcmpi(path_base(end),filesep()))
  8. path_base = [path_base filesep()];
  9. end

  10. paths_base = genpath(path_base);
  11. addpath(paths_base);

  12. path_dset = strrep('Datasets\weiFinanceData.xlsx','\',filesep()); % 修改这里替换为你的表格文件名字
  13. path_rpro = strrep('Results\wei20190825ResultsPRO.xlsx','\',filesep()); % 修改这里保存为另外的CoVaR结果表格名字
  14. path_rnet = strrep('Results\wei20190825ResultsNET.xlsx','\',filesep()); % 修改这里保存为另外的金融网络表格文件名字

  15. data = parse_dataset(fullfile(path_base,path_dset));

  16. main_pro(data,fullfile(path_base,path_rpro),0.95,0.40,0.08,true);
  17. pause(2);
  18. main_net(data,fullfile(path_base,path_rnet),0.05,true,true);

  19. save('weidata.mat','data');

  20. rmpath(paths_base);
复制代码







    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

GMT+8, 2026-2-8 02:33