标题: 望高手指教 [打印本页] 作者: shiyiming 时间: 2008-3-11 16:44 标题: 望高手指教 是关于event study的, 简单来讲,就是把发生事情日期定义为t那么要研究的事件时间段就是[t-20,t+10]这一段时间我们称之为不正常事件段而与它比较的正常时间段是[t-81,t-21],把对正常时间段每天的交易量取自然对数然后再取平均来表示正常交易量,也就是说这时候算出来的正常交易量是一个常数。用不正常时间段每天的交易量减去刚刚定义的正常交易量也就是那个常数来表示每天的非正常交易。然后就可以把 t之前20天的每天的不正常交易量加起来的到我们要的不正常交易量。
本人中文不太好不知道表达是否清楚,在用英文讲一遍。
Following the standard event methodology, employ the fixed mean model to compute abnormal option trading volume. More specifically, [t-20, t+10] and [t-81, t-21] are defined as event window and estimation window respectively12. Normal trading volume is then computed over the estimation window by taking the average of the natural log of the raw trading volume. Daily abnormal trading volume is computed by subtracting the normal trading volume from the daily trading volume in the event window. Cumulative abnormal trading volume is then computed by cumulating the daily abnormal trading volume over the 20 days leading up to the announcement dates.
希望高手们能够赐教,先谢谢啦。
简单的数据小样如下:
date volume
20051104 0
20051105 0
20051106 543
20051108 10
20051109 246
20051112 65
20051123 1059
20060601 40
20060608 50
20060702 90
20060703 100作者: shiyiming 时间: 2008-3-11 22:15 标题: Re: 望高手指教 看了半天没明白你具体意思,现在按我的理解给出代码如下,希望对你有帮助!
[code:2fv5owgi]
data a;
format date yymmdd10.;
do date='01jan2005'd to '01jan2007'd;
volume=ceil(ranuni(0)*1000);
output;
end;
run;
%let event_date=2005-10-1;
%let event_date=%sysfunc(inputn(&event_date,yymmdd10.));
data t1 t2;
set a;
if date>&event_date then output t2;
else output t1;
run;
proc sort data=t1;
by descending date;
run;
data t1;
set t1;
if _n_<=80;
run;
data t2;
set t2;
if _n_<=10;
run;
data result;
set t1 t2;
run;
proc sort data=result;
by date;
run;
data result(drop=sum);
set result;
retain sum mean;
if _n_=1 then sum=0;
sum+log(volume);
if _n_=60 then mean=sum/60;
if _n_>60 then do;
abVolume=volume-mean;
output;
end;
run;
[/code:2fv5owgi]作者: shiyiming 时间: 2008-3-12 15:04 标题: Re: 望高手指教 Thank you very much, Byes!! This realy helps me a lot.
Sorry that I did not give you a clear illustration about the problem.
每一家公司都会有发生一些特别的事情的日子(也就是我们说的event date)比如说像合并阿收购什么的,我呢就是想研究在这些事情发生前后交易量有没有什么不正常的变化。所以主要就是算不正常交易量(abvolume).
abvolume的计算方法还是像之前提到的。先对event date 之前的80天的volume 先取自然对数接着取平均,得到一个常数,再用event date 之前的20天和之后10天每天的交易量的自然对数减去这个常数得到的就是不正常交易量(abvolume).之后我们把前面20天的不正常交易量(abvolume)加起来就叫做累计不正常交易量(abvolume).
算出不正常交易量(abvolume)之后再把数据进行分类,主要是按照1.买卖(Call Options 和Put Options) ,2.到期日(maturity date)(<=60天和>60)3.moneyness : ITM:S/K >1.1, ATM: 0.9<S/K <1.1, OTM: S/K <0.9, S/K就是Stock price/Strike price,
分出来得数据形式大概如下:也就是关于这几类期权的平均的累计不正常交易量。这也就是我最后想要的结果。
Days to Expiration <= 60 Days Days to Expiration > 60 Days
Moenyness
Call Options
OTM
ATM
ITM
Put Options
OTM
ATM
ITM
现在我有几百家公司3年的数据,所以对我这个刚刚接触SAS不久的人来说就有很多问题。首先是几百家公司每一家的event date都是不一样的,是不是只能一家一家的去算, 另外几年的数据放在一个表里面计算会不会有问题还是说需要一年一年计算。还有就是我又试了很多次,我在前面提到的问题还是存在,不知道是不是我哪里写错了。
另外如果方便的话我可以发一些数据到你的邮箱,相信看了数据你会更了解我的问题。
我的邮箱是kirstenzhang13@gmail.com,如果有任何指教可以直接邮件给我,真的非常感谢你的帮助。作者: shiyiming 时间: 2008-3-16 00:24 标题: Re: 望高手指教 根据你给我的代码,我自己在计算时的代码如下,希望可以提供参考,帮我看出问题出在那里,再次表示感谢。
libname out 'D:\DATA\out';
data top20_04_call;
set out.top20_04_call OUT.top20_05_call;
run;
proc means data=top20_04_call nway noprint;
class ticker date;
var volume;
output out=top20_04_call1(drop=_type_ _freq_) mean(volume)=Volume;
run;
data top20_04_call1;
set top20_04_call1;
run;
data top20_04_call1 MSFT_call04_MA;
modify top20_04_call1;
if TICKER="MSFT"
then do;
output MSFT_call04_MA;
end;
RUN;
DATA MSFT_call04_MA;
SET MSFT_call04_MA;
RUN;
data MSFT_call04_MA;
format date yymmdd10.;
do date='07jan2004'd to '31dec2005'd;
VOLUME=CEIL(RANUNI(0)*10000);
output;
end;
run;
%let event_date=2005-10-18;
%let event_date=%sysfunc(inputn(&event_date,yymmdd10.));
data t1 t2;
set MSFT_call04_MA;
if date>&event_date then output t2;
else output t1;
run;
proc sort data=t1;
by descending date;
run;
data t1;
set t1;
if _n_<=82;
run;
data t2;
set t2;
if _n_<=10;
run;
data result;
set t1 t2;
run;
proc sort data=result;
by date;
run;
data result(drop=sum);
set result;
retain sum mean;
if _n_=1 then sum=0;
sum+log(volume);
if _n_=61 then mean=sum/61;
if _n_>61 then do;
abVolume=log(volume)-mean;
output;
end;
run;
proc sort data=result;
by descending date;
run;
data MSFT_call_MA0426;
set result;
retain sum;
if _n_=12 then sum=abvolume;
if _n_>12 then do;
sum=sum+abvolume;
output;
end;
run;作者: shiyiming 时间: 2008-3-16 09:55 标题: Re: 望高手指教 首先帮你该了下代码
[code:1gfs0pw5]
libname out 'D:\DATA\out';
data top20_04_call;
set out.top20_04_call OUT.top20_05_call;
run;
proc means data=top20_04_call nway noprint;
class ticker date;
var volume;
output out=top20_04_call1(drop=_type_ _freq_) mean(volume)=Volume;
run;
data MSFT_call04_MA;
set top20_04_call1;
if TICKER="MSFT";
RUN;
%let event_date=2005-10-18;
%let event_date=%sysfunc(inputn(&event_date,yymmdd10.));
data t1 t2;
set MSFT_call04_MA;
if date>&event_date then output t2;
else output t1;
run;
proc sort data=t1;
by descending date;
run;
data t1;
set t1;
if _n_<=82;
run;
data t2;
set t2;
if _n_<=10;
run;
data result;
set t1 t2;
run;
proc sort data=result;
by date;
run;
data result(drop=sum);
set result;
retain sum mean;
if _n_=1 then sum=0;
sum+log(volume);
if _n_=61 then mean=sum/61;
if _n_>61 then do;
abVolume=log(volume)-mean;
output;
end;
run;
proc sort data=result;
by descending date;
run;
data MSFT_call_MA0426;
set result;
retain sum;
if _n_=12 then sum=abvolume;
if _n_>12 then do;
sum=sum+abvolume;
output;
end;
run;
NOTE: There were 252 observations read from the data set WORK.MSFT_CALL04_MA.
NOTE: The data set WORK.T1 has 0 observations and 3 variables.
NOTE: The data set WORK.T2 has 252 observations and 3 variables.
好像不format date 的话,t1 t2就挑不出来。
不好意思又要麻烦各位了,谢谢。作者: shiyiming 时间: 2008-3-16 20:29 标题: Re: 望高手指教 [quote="janezhang":15nzu26p]我又再次用了下面这段程序计算,
data MSFT_call04_MA;
format date yymmdd10.;
do date='07jan2004'd to '31dec2005'd;
VOLUME=CEIL(RANUNI(0)*10000);
output;
end;
run;[/quote:15nzu26p]
这段程序没用的,你有自己的数据,因为我没有你的数据,所以我模拟的数据,我服了你了.
你自己表格里面有date ,volume为什么还要生成date,volume(上面那段程序).
希望bbs的高手给他点建议把.作者: shiyiming 时间: 2008-3-17 17:11 标题: Re: 望高手指教 真的为本人的粗心大意和知识浅薄而感到不好意思。