Moving or rolling skewness

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Moving or rolling skewness

Hi there,

I have a list of daily returns and i wanna compute the rolling skewness. What code can i use here to generate many values of skewness.. Take for instance the following data;

Date                Returns

25/03/20130.8
26/03/20130.83
27/03/20130.82
28/03/20130.83
29/03/20130.83
01/04/20130.83
02/04/20130.83
03/04/20130.81
04/04/20130.81
05/04/20130.77
08/04/20130.79
09/04/20130.77
10/04/20130.77
11/04/20130.79
12/04/20130.78
15/04/20130.76
16/04/20130.77
17/04/20130.77

Accepted Solutions
Solution
‎04-04-2015 11:22 AM
Super User
Posts: 10,035

Re: Moving or rolling skewness

Posted in reply to ivanpersie

OK . Here is .

data have;
input Date  : ddmmyy10.            Returns ;
format date ddmmyy10.;
cards;
25/03/2013     0.8
26/03/2013     0.83
27/03/2013     0.82
28/03/2013     0.83
29/03/2013     0.83
01/04/2013     0.83
02/04/2013     0.83
03/04/2013     0.81
04/04/2013     0.81
05/04/2013     0.77
08/04/2013     0.79
09/04/2013     0.77
10/04/2013     0.77
11/04/2013     0.79
12/04/2013     0.78
15/04/2013     0.76
16/04/2013     0.77
17/04/2013     0.77
;
run;

proc summary data=have  nway;
 class      date  ;
 format date monyy7.;
 var returns;
 output out=want skewness=skewness;
run;

Xia Keshan

View solution in original post


All Replies
Super User
Posts: 10,035

Re: Moving or rolling skewness

Posted in reply to ivanpersie

What is the window length of rolling skewness ? a month , a year ?

Contributor
Posts: 27

Re: Moving or rolling skewness

The window length is a month

Super User
Posts: 10,035

Re: Moving or rolling skewness

Posted in reply to ivanpersie

For a day you want a previous month's skewness or a next month's ?

And the window length should be the exact integer , a month could have 30 days 31 days .


And better post the output you want according to your sample data .

Message was edited by: xia keshan

Contributor
Posts: 27

Re: Moving or rolling skewness

Sorry just to clarify i have monthly data. So i want to find out skewness this month and last month

Super User
Posts: 19,822

Re: Moving or rolling skewness

Posted in reply to ivanpersie

Do you have proc expand? Though your question doesn't appear to be a rolling window but a simple aggregation, how to calculate skewness from daily data for a months worth of data.

Contributor
Posts: 27

Re: Moving or rolling skewness

Hi Reeza. Here is my interpretation for the Skewness i am trying to calculate.

"SKEW is the third standardized moment of return of the past 22 trading days". So meaning i have daily data for a given month and Ticker. So i want to find the skewness for each month for each ticker in each year.

Super User
Posts: 19,822

Re: Moving or rolling skewness

Posted in reply to ivanpersie

I understand the definition of skewness. It isn't a moving or rolling calculation. In moving/rolling calculations the periods overlap. You appear to have distinct periods.

At any rate, you have the correct answer above from Xia.

Contributor
Posts: 27

Re: Moving or rolling skewness

Thanks Reeza.Oh yes i had confused it as moving/trailing. I got it now. Thanks @Keshan too.

Solution
‎04-04-2015 11:22 AM
Super User
Posts: 10,035

Re: Moving or rolling skewness

Posted in reply to ivanpersie

OK . Here is .

data have;
input Date  : ddmmyy10.            Returns ;
format date ddmmyy10.;
cards;
25/03/2013     0.8
26/03/2013     0.83
27/03/2013     0.82
28/03/2013     0.83
29/03/2013     0.83
01/04/2013     0.83
02/04/2013     0.83
03/04/2013     0.81
04/04/2013     0.81
05/04/2013     0.77
08/04/2013     0.79
09/04/2013     0.77
10/04/2013     0.77
11/04/2013     0.79
12/04/2013     0.78
15/04/2013     0.76
16/04/2013     0.77
17/04/2013     0.77
;
run;

proc summary data=have  nway;
 class      date  ;
 format date monyy7.;
 var returns;
 output out=want skewness=skewness;
run;

Xia Keshan

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 656 views
  • 4 likes
  • 3 in conversation