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

附件下载

所在主题:
文件名:  matlab的ar模型参数估计.pdf
资料下载链接地址: https://bbs.pinggu.org/a-1698891.html
附件大小:
77.22 KB   举报本内容

量化板块任何资源如果您的论坛币不足以下载可以向版主fantuanxiaot索要(10论坛币下载以内的资源)!!发站内信索要即可!




小的不才,在离歌版主,weitingkoala,faruto等人和大家的支持下,fantuanxiaot成为了实习版主,希望和各界已经工作的量化宽客人士、老师、还有兄长兄弟姐妹们一起打造量化投资这个小小板块!!!

请随时关注:量化投资

为了鼓励大家关注量化板块,我决定颁布这个板块的帖子发布激励规则:


1,原创帖(尤其是原创的代码,支持matlab、python、R、C++、C、C#等各类软件)
2,学术资源帖(金融学、统计学、计量经济学、量化、各类软件教程等)
3,量化idea交流帖(不要重复灌水)


针对以上帖子看情况我将奖励10~100经验,和10~100个论坛币不等,有重要珍贵的代码帖或者资源帖idea帖奖励会更多!!


更多量化资源请关注:离歌量化stata matlab python实战


废话不多说了,先分享一下:基于MATLAB的三类方法来模拟几何布朗运动的代码
[hide]
  1. close all
  2. format compact
  3. %参数的设置
  4. %第一类方法生成
  5. miu=0.001;
  6. sigma=0.05;
  7. base_price=10;
  8. N=30;
  9. stock_return=normrnd(miu,sigma,1,N);
  10. cum_return=cumprod(1+stock_return);
  11. price=base_price*cum_return;
  12. figure(1)
  13. set(gcf,'color',[0.5,1,1])
  14. subplot(3,1,1)
  15. plot(price,'rv-','linewidth',1.5,'markerfacecolor','g','markeredgecolor','g','markersize',8)
  16. set(subplot(3,1,1),'fontname','Times New Roman')
  17. title('First Method to Generate The Equity Price')
  18. legend('First Method to Generate The Equity Price')
  19. %第二类方法生成
  20. cumexp_return=exp(cumsum(stock_return));
  21. exp_price=base_price*cumexp_return;
  22. subplot(3,1,2)
  23. plot(price,'bo-','linewidth',1.5,'markerfacecolor','m','markeredgecolor','m','markersize',8)
  24. set(subplot(3,1,2),'fontname','Times New Roman')
  25. title('Second Method to Generate The Equity Price')
  26. legend('Second Method to Generate The Equity Price')
  27. %第三类方法生成
  28. M=20;
  29. delta_t=ones(M,1);
  30. sigma_M=sigma*ones(M,1);
  31. miu_M=miu*ones(M,1);
  32. equity_matrix=zeros(M,N);
  33. equity_matrix(:,1)=ones(M,1)*base_price;
  34. for i=2:N
  35. equity_matrix(:,i)=equity_matrix(:,i-1)+miu_M.*...
  36. equity_matrix(:,i-1).*delta_t+sigma_M.*randn(M,1).*equity_matrix(:,i-1).*sqrt(delta_t);
  37. end
  38. subplot(3,1,3)
  39. equity_trend=(max(equity_matrix)+min(equity_matrix))./2;
  40. equity_matrix=equity_matrix';
  41. plot(equity_trend,'ks-','linewidth',1.5,'markerfacecolor','r','markeredgecolor','r','markersize',8)
  42. hold on
  43. plot(equity_matrix,'linewidth',1)
  44. set(subplot(3,1,3),'fontname','Times New Roman')
  45. str={'The Matrix Method Generate The Equity Price';'The Third Method'};
  46. title(str)
  47. legend('The trend of Equity Price')
  48. hold off
复制代码
[/hide]



matlab的ar模型参数估计文献一篇:


基于R语言的三类方法来模拟几何布朗运动的代码


[hide]


  1. #基于R语言的三类方法生成几何布朗运动
  2. #基于三类方法生成几何布朗运动
  3. Brownian_Motion1<-function(n,mu,sigma,baseprice)
  4. {
  5. #n是几何布朗运动的个数
  6. #mu是几何布朗运动的参数
  7. #Sigma也是几何布朗运动的参数
  8. Brownian_Motion_Return=mu+sigma*rnorm(n)
  9. Brownian_Motion_Return=1+Brownian_Motion_Return
  10. Brownian_Motion_Return=cumprod(Brownian_Motion_Return)
  11. Brownian_Motion_Price=baseprice*Brownian_Motion_Return
  12. return(Brownian_Motion_Price)
  13. }
  14. Brownian_Motion2<-function(n,mu,sigma,baseprice)
  15. {
  16. #n是几何布朗运动的个数
  17. #mu是几何布朗运动的参数
  18. #Sigma也是几何布朗运动的参数
  19. Brownian_Motion_Return=mu+sigma*rnorm(n)
  20. Brownian_Motion_Return=cumsum(Brownian_Motion_Return)
  21. Brownian_Motion_Return=exp(Brownian_Motion_Return)
  22. Brownian_Motion_Price=baseprice*Brownian_Motion_Return
  23. return(Brownian_Motion_Price)
  24. }
  25. hist(Brownian_Motion1(100,0.001,0.01,10))
  26. plot(Brownian_Motion1(100,0.001,0.01,10))
  27. hist(Brownian_Motion2(100,0.001,0.01,10))
  28. plot(Brownian_Motion2(100,0.001,0.01,10))
  29. Brownian_Motion1(10,0,0.001,10)
  30. Brownian_Motion2(10,0,0.001,10)

  31. Brownian_Motion3<-function(n,mu,sigma,deltaT,baseprice)
  32. {
  33. #n是几何布朗运动的个数
  34. #mu是几何布朗运动的参数
  35. #Sigma也是几何布朗运动的参数
  36. Return=mu+sigma*rnorm(n)
  37. #
  38. Price=c(1:(n+1))
  39. Price[1]=baseprice
  40. for (n in 1:n)
  41. {
  42. #基于第三类方法生成几何布朗运动
  43. Price[n+1]=Price[n]+mu*Price[n]*deltaT+
  44. sigma*rnorm(1)*sqrt(deltaT)*Price[n]

  45. }
  46. return(Price[2:(n+1)])
  47. }
  48. Brownian_Motion3(20,0,0.001,1,10)
复制代码


[/hide]



聚类作图代码

[hide]
  1. %%% 以下为聚类分析的第一幅图:Kmeans聚类分析
  2. N=250;
  3. X=[rand(N,2)+0.1*ones(N,2);rand(N,2)-0.1*ones(N,2)];
  4. options=statset('Display','final');
  5. [index,center1]=kmeans(X,2,'Distance','city',...
  6. 'Replicates',5,'Options',options);
  7. figure(1)
  8. set(figure(1),'color','w')
  9. hold on
  10. plot(X(index==1,1),X(index==1,2),'ro','markersize',9,'markeredgecolor',...
  11. 'k','markerfacecolor','r')
  12. plot(X(index==2,1),X(index==2,2),'ro','markersize',9,'markeredgecolor',...
  13. 'k','markerfacecolor','g')
  14. plot(center1(:,1),center1(:,2),'ko','markersize',15,'markeredgecolor',...
  15. 'k','markerfacecolor','k')
  16. grid on
  17. hold off

  18. %%% 以下为聚类分析的第二幅图:模糊聚类分析法
  19. X2=[rand(N,2)+0.2*ones(N,2);rand(N,2)+0.1*ones(N,2);rand(N,2)];
  20. opt=[2;200;1e-6;0];
  21. [center,U,obj]=fcm(X2,3,opt);
  22. MaxU=max(U);
  23. index1=(U(1,:)==MaxU);
  24. index2=(U(2,:)==MaxU);
  25. index3=(U(3,:)==MaxU);
  26. X21=X2(index1,:);
  27. X22=X2(index2,:);
  28. X23=X2(index3,:);
  29. figure(2)
  30. set(figure(2),'color','w')
  31. hold on
  32. plot(X21(:,1),X21(:,2),'ro','markersize',9,'markeredgecolor',...
  33. 'k','markerfacecolor','r')
  34. plot(X22(:,1),X22(:,2),'go','markersize',9,'markeredgecolor',...
  35. 'k','markerfacecolor','g')
  36. plot(X23(:,1),X23(:,2),'mo','markersize',9,'markeredgecolor',...
  37. 'k','markerfacecolor','m')
  38. plot(center(:,1),center(:,2),'kh','markersize',15,'markeredgecolor',...
  39. 'k','markerfacecolor','k')
  40. grid on
  41. hold off

  42. %%% 以下为聚类分析的第三幅图:模糊聚类分析法
  43. X3=[rand(N,2)+0.2*ones(N,2);rand(N,2)+0.1*ones(N,2);rand(N,2);rand(N,2)-0.1*ones(N,2)];
  44. opt=[2;200;1e-6;0];
  45. [center,U,obj]=fcm(X3,4,opt);
  46. MaxU=max(U);
  47. index1=(U(1,:)==MaxU);
  48. index2=(U(2,:)==MaxU);
  49. index3=(U(3,:)==MaxU);
  50. index4=(U(4,:)==MaxU);
  51. X31=X3(index1,:);
  52. X32=X3(index2,:);
  53. X33=X3(index3,:);
  54. X34=X3(index4,:);
  55. figure(3)
  56. set(figure(3),'color','w')
  57. hold on
  58. plot(X31(:,1),X31(:,2),'ro','markersize',9,'markeredgecolor',...
  59. 'k','markerfacecolor','r')
  60. plot(X32(:,1),X32(:,2),'go','markersize',9,'markeredgecolor',...
  61. 'k','markerfacecolor','g')
  62. plot(X33(:,1),X33(:,2),'mo','markersize',9,'markeredgecolor',...
  63. 'k','markerfacecolor','m')
  64. plot(X34(:,1),X34(:,2),'yo','markersize',9,'markeredgecolor',...
  65. 'k','markerfacecolor','y')
  66. plot(center(:,1),center(:,2),'kp','markersize',15,'markeredgecolor',...
  67. 'k','markerfacecolor','k')
  68. grid on
  69. hold off

  70. %%% 以下为聚类分析的第四幅图:Kmeans聚类分析
  71. X=[rand(N,2)+0.2*ones(N,2);rand(N,2)+0.1*ones(N,2);rand(N,2);...
  72. rand(N,2)-0.1*ones(N,2);rand(N,2)-0.2*ones(N,2)];
  73. options=statset('Display','final');
  74. [index,center1]=kmeans(X,5,'Distance','city',...
  75. 'Replicates',5,'Options',options);
  76. figure(4)
  77. set(figure(4),'color','w')
  78. hold on
  79. plot(X(index==1,1),X(index==1,2),'ro','markersize',9,'markeredgecolor',...
  80. 'k','markerfacecolor','r')
  81. plot(X(index==2,1),X(index==2,2),'go','markersize',9,'markeredgecolor',...
  82. 'k','markerfacecolor','g')
  83. plot(X(index==3,1),X(index==3,2),'bo','markersize',9,'markeredgecolor',...
  84. 'k','markerfacecolor','b')
  85. plot(X(index==4,1),X(index==4,2),'mo','markersize',9,'markeredgecolor',...
  86. 'k','markerfacecolor','m')
  87. plot(X(index==5,1),X(index==5,2),'yo','markersize',9,'markeredgecolor',...
  88. 'k','markerfacecolor','y')
  89. plot(center1(:,1),center1(:,2),'ks','markersize',15,'markeredgecolor',...
  90. 'k','markerfacecolor','k')
  91. grid on
  92. hold off
复制代码
[/hide]











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

扫码加我 拉你入群

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

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

GMT+8, 2026-1-9 02:31