In reference to Rob Hyndman's post above https://stats.stackexchange.com/a/1214/70282
The find.freq function works brilliantly. On the daily data set I am using, it correctly worked out the frequency to be 7.
When I tried it on only the week days, it mentioned the frequency is 23, which is remarkably close to 21.42857=29.6*5/7 which is the average number of work days in a month. (Or conversely 23*7/5 is 32.)
Looking back at my daily data, I experimented with a hunch of taking the first period, averaging by that and then finding the next period, etc. See below:
find.freq.all=function(x){
f=find.freq(x);
freqs=c(f);
while(f>1){
start=1; #also try start=f;
x=period.apply(x,seq(start,length(x),f),mean);
f=find.freq(x);
freqs=c(freqs,f);
}
if(length(freqs)==1){ return(freqs); }
for(i in 2:length(freqs)){
freqs[i]=freqs[i]*freqs[i-1];
}
freqs[1:(length(freqs)-1)];
}
find.freq.all(dailyts) #using daily data
The above gives (7,28) or (7,35) depending on if the seq starts with 1 or f. (See comment above.)
Which would imply that the seasonal periods for msts(...) should be (7,28) or (7,35).
The logic appears sensitive to initial conditions given the sensitivity of the algorithm parameters. The mean of 28 and 35 is 31.5 which is close to the average length of a month.
I suspect I reinvented the wheel, what is the name of this algorithm? Is there a better implementation in R somewhere?
Later, I ran the above code in trying all starts of 1 through 7 and I got 35,35,28,28,28,28,28 for the second period. The average works out to 30 which is the average number of days in a month. Interesting...
Any thoughts or comments?