Apply the Baxter-King filter to all variables in input table variables.
Load the Schwert stock data set Data_SchwertStock.mat, which contains monthly returns of the NYSE index from 1871 through 2008 in DataTimeTableMth, among three other variables (for details, enter Description). Remove all missing observations from all series.
Aggregate the monthly data in the timetable to quarterly measurements.
Apply the Baxter-King filter to all variables in the quarterly timetable. Use the default cutoffs and lag length for the moving average.
TQTT and CQTT are 220-by-4 timetables containing the trend and cyclical components, respectively, of the series in TTQ. Variables in the input and output timetables correspond. By default, bkfilter filters all variables in the input table or timetable. To select a subset of variables, set the DataVariables option.
The default lag length is 12. Consequently, the first and last 12 rows in the output timetable are NaN-valued.
Remove the leading and lagging NaNs from the trends and display what remains.
TQTTCut=196×4 timetable
       Time          Return       DivYld       CapGain       CapGainA 
    ___________    __________    _________    __________    __________
    31-Mar-1874     -0.039822    0.0032538     -0.028711     -0.043076
    30-Jun-1874     -0.017105    0.0044321     -0.023919     -0.021537
    30-Sep-1874     0.0039487    0.0010179      0.002954     0.0029307
    31-Dec-1874    -0.0078419    0.0050448    -0.0063275     -0.012887
    31-Mar-1875      0.020326    0.0024432      0.015128      0.017883
    30-Jun-1875    -0.0020712    0.0038703     -0.017158    -0.0059416
    30-Sep-1875    -0.0085514    0.0044146      -0.01171     -0.012966
    31-Dec-1875     -0.006103    0.0036185    -0.0058395    -0.0097214
    31-Mar-1876    -0.0055681    0.0031237    -0.0059341    -0.0086918
    30-Jun-1876      0.013271    0.0044001     0.0034571     0.0088705
    30-Sep-1876     -0.033603    0.0042907      -0.03317     -0.037894
    31-Dec-1876       0.04053    0.0045942      0.031644      0.035936
    31-Mar-1877     0.0023469    0.0032843     -0.014032    -0.0009374
    30-Jun-1877     -0.061762     0.004893     -0.049214     -0.066655
    30-Sep-1877      0.066959    0.0047892      0.058975       0.06217
    31-Dec-1877     -0.017554    0.0029106     -0.026179     -0.020464
      ⋮
CQTTCut=196×4 timetable
       Time          Return        DivYld        CapGain       CapGainA 
    ___________    __________    ___________    __________    __________
    31-Mar-1874       0.01699       -0.00117      0.015758       0.01816
    30-Jun-1874      0.020025     -0.0013329      0.018379      0.021358
    30-Sep-1874      0.016201    -0.00079002      0.013713      0.016991
    31-Dec-1874     0.0064867     1.9907e-06     0.0036027     0.0064847
    31-Mar-1875     -0.002434     0.00036989    -0.0041687    -0.0028039
    30-Jun-1875    -0.0061591     3.1258e-05    -0.0050638    -0.0061903
    30-Sep-1875    -0.0033857    -0.00076308    0.00044226    -0.0026226
    31-Dec-1875     0.0015781     -0.0013475     0.0058395     0.0029255
    31-Mar-1876     0.0017405     -0.0010938     0.0031869     0.0028343
    30-Jun-1876    -0.0062558     1.9708e-05    -0.0094095    -0.0062755
    30-Sep-1876     -0.021212      0.0013923     -0.026956     -0.022604
    31-Dec-1876     -0.034671      0.0023024      -0.03854     -0.036974
    31-Mar-1877     -0.039779      0.0023122     -0.038012     -0.042091
    30-Jun-1877     -0.028847      0.0017301     -0.022516     -0.030577
    30-Sep-1877     -0.003445      0.0011069     0.0022493    -0.0045519
    31-Dec-1877      0.023547     0.00090623      0.022362      0.022641
      ⋮
To compare outputs between different tabular inputs, apply the Baxter-King filter to all variables in the table of monthly data DataTableMth and the timetable of monthly data TTM.
                 Return       DivYld       CapGain       CapGainA 
               __________    _________    __________    __________
    May1924    -0.0016302     0.002973    -0.0046032    -0.0046032
    Jun1924      0.047692    0.0065778      0.041115      0.041115
    Jul1924      0.044844    0.0060522      0.038792      0.038792
    Aug1924      0.010929    0.0019358     0.0089936     0.0089936
    Sep1924    -0.0086959     0.006971     -0.015667     -0.015667
    Oct1924    -0.0014852    0.0049456    -0.0064308    -0.0064308
    Nov1924      0.062927    0.0020931      0.060834      0.060834
    Dec1924      0.045108    0.0070319      0.038076      0.038076
                Return        DivYld        CapGain     CapGainA 
               _________    ___________    _________    _________
    May1924    0.0074662    -4.9042e-05    0.0075152    0.0075152
    Jun1924     0.017044     0.00019971     0.016844     0.016844
    Jul1924     0.016657     0.00028124     0.016376     0.016376
    Aug1924    0.0096193     0.00019693    0.0094224    0.0094224
    Sep1924    0.0035508     0.00014389    0.0034069    0.0034069
    Oct1924    0.0064063     7.9476e-05    0.0063268    0.0063268
    Nov1924     0.013666     7.2083e-05     0.013594     0.013594
    Dec1924     0.015515     0.00010861     0.015407     0.015407
       Time          Return       DivYld       CapGain       CapGainA 
    ___________    __________    _________    __________    __________
    01-May-1924    -0.0016302     0.002973    -0.0046032    -0.0046032
    01-Jun-1924      0.047692    0.0065778      0.041115      0.041115
    01-Jul-1924      0.044844    0.0060522      0.038792      0.038792
    01-Aug-1924      0.010929    0.0019358     0.0089936     0.0089936
    01-Sep-1924    -0.0086959     0.006971     -0.015667     -0.015667
    01-Oct-1924    -0.0014852    0.0049456    -0.0064308    -0.0064308
    01-Nov-1924      0.062927    0.0020931      0.060834      0.060834
    01-Dec-1924      0.045108    0.0070319      0.038076      0.038076
       Time         Return        DivYld        CapGain     CapGainA 
    ___________    _________    ___________    _________    _________
    01-May-1924    0.0074662    -4.9042e-05    0.0075152    0.0075152
    01-Jun-1924     0.017044     0.00019971     0.016844     0.016844
    01-Jul-1924     0.016657     0.00028124     0.016376     0.016376
    01-Aug-1924    0.0096193     0.00019693    0.0094224    0.0094224
    01-Sep-1924    0.0035508     0.00014389    0.0034069    0.0034069
    01-Oct-1924    0.0064063     7.9476e-05    0.0063268    0.0063268
    01-Nov-1924     0.013666     7.2083e-05     0.013594     0.013594
    01-Dec-1924     0.015515     0.00010861     0.015407     0.015407
Because the data is disaggregated, the outputs of the daily data have more rows than from the quarterly data. The filter results of the daily inputs are equal among the corresponding outputs, but bkfilter returns tables of results, instead of timetables, when you supply data in a table.