char05SAS金融应用程序举例.doc

char05SAS金融应用程序举例.doc

ID:61496952

大小:137.00 KB

页数:10页

时间:2021-02-06

char05SAS金融应用程序举例.doc_第1页
char05SAS金融应用程序举例.doc_第2页
char05SAS金融应用程序举例.doc_第3页
char05SAS金融应用程序举例.doc_第4页
char05SAS金融应用程序举例.doc_第5页
资源描述:

《char05SAS金融应用程序举例.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、5.2.2单个股票波动率计算日对数收益率计算:optionsnodatenonotesnosource;datalog_ret(keep=date);setstoindiv.a1a0001;where1995<=year(date)<=2000;%macroa(x);dataa(keep=dater_1);setstoindiv.a&x;where1995<=year(date)<=2000;r_1=log(clpr)-log(lag(clpr));clpr_1=clpr*(1+divrat+rigrat+reisvol/lag(shrout))-rigpr*rigrat-reis

2、pr*reisvol/lag(shrout)+divamt;ifclpr_1=.thenclpr_1=clpr;r_2=log(clpr_1)-log(lag(clpr_1));ifexdt=.thenr_2=0;ifexdt^=.thenr_1=0;r_1=r_1+r_2;ifr_1=.thenr_1=0;elser_1=r_1;datalog_ret(rename=(r_1=r&x));mergelog_reta;bydate;datalog_ret;setlog_ret;ifr&x=.thenr&x=0;elser&x=r&x;rr&x=r&x**2;%menda;%a(1a

3、0001);%a(600652);run;简单加权移动平均(SMA)计算的波动率:procsortdata=log_ret;bydate;datasma(keep=date);setlog_ret;%macroa(x);dataa;setlog_ret;sum+rr&x;datab(keep=datesma&x);mergeaa(firstobs=21rename=(sum=sum_1));sma&x=(sum_1-sum)/(20-1);/*这里计算的是20天移动平均*/sma&x=sqrt(sma&x);procsortdata=b;bydate;datasma;mergesm

4、ab;bydate;ifsma&x=.thendelete;%menda;%a(1a0001);%a(600652);run;指数加权(EWMA)计算的波动率:方法一:dataewma(keep=date);setlog_retnobs=nobs;aaa=nobs;callsymput('n',aaa);/*创建宏变量n,将数据集log_ret中观测值个数赋于它*/%macroa(x);dataa(keep=dateewma&x);setlog_ret;if_n_=2thenewma&x=rr&x;i_1=lag(ewma&x);%doi=3%to%eval(&n);if_n_=&

5、ithenewma&x=.94*i_1+(1-.94)*rr&x;i_1=lag(ewma&x);%end;ewma&x=sqrt(ewma&x);dataewma;mergeewmaa;bydate;%menda;%a(1a0001);%a(600652);run;方法二:datab;setlog_ret;if_n_=1thendelete;/*删除第一个全为0的观测值*/datastoindiv.ewma(keep=date);setb;%macroa(x);dataa(keep=dateewma&x);setb;w=0.94;/*指数平滑权*/retainewma&x;/*序

6、列的初始值*/if_n_=1thenewma&x=rr&x;/*单指数平滑*/elseewma&x=w*rr&x+(1-w)*ewma&x;ewma&x=sqrt(ewma&x);datastoindiv.ewma;mergestoindiv.ewmaa;bydate;%menda;%a(1a0001);%a(600652);run;GARCH(1,1)计算的波动率:datagarch(keep=date);setlog_ret;%macroa(x);procautoregdata=log_ret;modelr&x=/nlag=1garch=(q=1,p=1,tr);outputo

7、ut=outcev=cev;dataout(keep=datecev&x);setout;cev&x=sqrt(cev);datagarch;mergegarchout;bydate;%menda;%a(1a0001);%a(600652);run;5.2.3三种模型结果比较将上述三种模型计算的收益波动率全并在一个数据集C中:datac;mergesmaewmagarch;bydate;run;分别画出1995~2000年,股票600652(爱使股份)和上证指数各自的

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。