How to split a daily DateList by week?

• To: mathgroup at smc.vnet.net
• Subject: [mg114862] How to split a daily DateList by week?
• From: "Sohn Hyun-U" <hsohn at student.ethz.ch>
• Date: Tue, 21 Dec 2010 00:16:33 -0500 (EST)

Hi there,

Suppose I have a weekdaily DateList of financial data. Sometimes, a day is
missing due to holidays etc.
I would like to split it by quarter (Q), calendar month (M), and calendar week (W), for example to compute intra-\${Q,M,W} statistics.

For months, I did the following:

splitByMonth[ts_] := (
maxYear = Max[ts[[All, 1, 1]]];
minYear = Min[ts[[All, 1, 1]]];
dummy =
Table[Select[ts, #[[1, 1]] == year && #[[1, 2]] == month &], {year,
minYear, maxYear}, {month, 1, 12}] // Sort;
Flatten[dummy, {1, 2}]
)

The problem with weeks is that there is no counter in the DateList format, so the only way I at the moment uses date conversions to strings of "DayName", which looks rather crummy, particularly if there are days missing sometimes due to holidays etc.

I'm sure there is a better way but I can't find it. Can anyone here help me out?

Kind regards,
Hyun-U Sohn

• Prev by Date: Compare matrices using Chi square for Exploratory Factor Analysis
• Next by Date: Re: "Accumulate" with operator Times.
• Previous by thread: Re: Compare matrices using Chi square for Exploratory
• Next by thread: Re: How to split a daily DateList by week?