Problems using retime within timetable

조회 수: 10 (최근 30일)
Gavin Goy
Gavin Goy 2018년 7월 19일
댓글: Akira Agata 2020년 2월 12일
Dear all,
Using daily zero coupon yields data from 16-Aug-1972 until 13-Jul-2018 (see Gurkaynak et al 2006), I used
rmissing(retime(data,'frequency',@mean))
to get monthly and quarterly averages. The resulting monthly averages were fine. The same holds for the quarterly averages, however, with the exemption that matlab skipped the calculation of 2008Q1. Only when first calculating monthly averages, all quarters were calculated.
Can someone educate me for why taking quarterly averages directly from daily worked for all quarters but 2008Q1?
Thanks. Best, Gavin

채택된 답변

Akira Agata
Akira Agata 2018년 7월 20일
편집: Akira Agata 2018년 7월 20일
I think your data set is the following:
Looking at the data, there is NaN at 2008-03-21 in the data set (feds200628.xls) and this causes your problem. In default settings, the nanflag of the function mean is set to 'includenan'. So, the mean value of 2008Q1 was not calculated.
To avoid this, please use
retime(data,'quarterly','mean')
or
retime(data,'quarterly',@(x) mean(x, 'omitnan'))
  댓글 수: 3
SEETHA JAYAN
SEETHA JAYAN 2020년 2월 11일
1)Wheather both gives results of nanmean.(by omiting mean)?
2)what is x over second code
Akira Agata
Akira Agata 2020년 2월 12일
Hi Seetha-san,
Yes, both gives the results of nanmean ( = mean with 'omitnan' option).
And 'x' in the second code is the input variable of anonymous function. I would recommend accessing the following documentation page for more details on 'anonymous function'.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by