股票价格累积概率分布

sample.txt为上证指数 ,读入sas.

filename in 'c:\sample.txt';
data a; 
  infile in  dlm='09'x;
  input id   date :  yymmdd10.  (x1-x7) (: $12.) ;
  format date yymmdd10.;
proc print data=a;run;


进一步研究其开盘价趋势图:

data spprice( keep=price lprice );
   set a;
   price=input(x2,8.);
   lprice=log(price);
run;
ods graphics on;
proc timeseries data=spprice out=newprice plot=series;
  var price lprice;
run;
ods graphics off;


当然还可以看看其描述性统计和简单检验的结果:

proc univariate data=spprice normal plot;
   var price lprice;
run;


试图查找价格指数的分布情况

1.各个价格出现比率

proc freq data=spprice ;
   table price / noprint out=spfreq(keep=price percent);
run;


2.将比率看做价格出现的概率,试图求出价格的累积分布密度

proc freq data=spprice ;
   table price / noprint out=spfreq(keep=price percent);
run;

data  _null_;
   if 0 then set spfreq nobs=n;
   if _n_=1 then call symput('n',compress(put(n,8.0)));
   stop;
run;;

data rndprice (keep=price) spcdf(keep=price spprob);
   set spfreq end=endofprc;

   array prices(&n) prc1-prc&n;
   array prob(&n) prb1-prb&n;
   retain prc1-prc&n prb1-prb&n;
   prices(_n_)=price;
   prob(_n_)=percent/100;

if endofprc then do;
   spprob=0;
   do i=1 to dim(prices);
      price=prices(i);
   spprob=spprob+prob(i);
   output ;
   end;
   do j=1 to 1000;
      price=prices(rantbl(123,of prob(*)));
      output ;
   end;
 end;
 run;

proc freq data=rndprice;
   table price / noprint out=rndcdf(keep=price percent);
run;

data rndcdf2(keep=price rndprob);
   set rndcdf;
   retain rndprob 0;
   rndprob=rndprob+percent/100;
run;


作出累积分布密度图

data both;
   set spcdf(rename=(spprob=prob))
       rndcdf2(rename=(rndprob=prob) in=rnd);
   retain sample 'theoretical';
   if rnd then sample='random';
   output;
run;

proc gplot data=both;
  plot prob*price=sample;
run;
quit;


http://blog.renren.com/blog/220869953/729348859?from=fanyeNew

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值