1
$\begingroup$

I have a GDP quarterly series and IND.P monthly series, which I need to detrend. I am following Bernanke et al. paper from 1995 and the way they do it is:

enter image description here

> GDPQ
        Qtr1      Qtr2      Qtr3      Qtr4
1    717.790   730.191   749.323   771.857
2    795.734   804.981   819.638   833.302
3    844.170   848.983   865.233   881.439
4    909.387   934.344   950.825   968.030
5    993.337  1009.020  1029.956  1038.147
6   1051.200  1067.375  1086.059  1088.608
7   1135.156  1156.271  1177.675  1190.297
8   1230.609  1266.369  1290.566  1328.904
9   1377.490  1413.887  1433.838  1476.289
10  1491.209  1530.056  1560.026  1599.679
11  1616.116  1651.853  1709.820  1761.831
12  1820.487  1852.332  1886.558  1934.273
13  1988.648  2055.909  2118.473  2164.270
14  2202.760  2331.633  2395.053  2476.949
15  2526.610  2591.247  2667.565  2723.883
16  2789.842  2797.352  2856.483  2985.557
17  3124.206  3162.532  3260.609  3280.818
18  3274.302  3331.972  3366.322  3402.561
19  3473.413  3578.848  3689.179  3794.706
20  3908.054  4009.601  4084.250  4148.551
21  4230.168  4294.887  4386.773  4444.094
22  4507.894  4545.340  4607.669  4657.627
23  4722.156  4806.160  4884.555  5007.994
24  5073.372  5190.036  5282.835  5399.509
25  5511.253  5612.463  5695.365  5747.237
26  5872.701  5960.028  6015.116  6004.733
27  6035.178  6126.862  6205.937  6264.540
28  6363.102  6470.763  6566.641  6680.803
29  6729.459  6808.939  6882.098  7013.738
30  7115.652  7246.931  7331.075  7455.288
31  7522.289  7580.997  7683.125  7772.586
32  7868.468  8032.840  8131.408  8259.771
33  8362.655  8518.825  8662.823  8765.907
34  8866.480  8969.699  9121.097  9293.991
35  9417.264  9524.152  9681.856  9899.378
36 10002.857 10247.679 10319.825 10439.025
37 10472.879 10597.822 10596.294 10660.294
38 10788.952 10893.207 10992.051 11071.463
39 11183.507 11312.875 11567.326 11769.275
INDPM
       Jan     Feb     Mar     Apr     May     Jun     Jul     Aug     Sep     Oct     Nov     Dec
1  31.1821 31.3760 31.7913 31.9298 32.1790 32.4283 32.7329 32.8713 32.9544 33.2868 33.4252 33.8406
2  34.1729 34.3945 34.8652 34.9206 35.2529 35.4191 35.6129 35.6406 35.9729 36.2221 35.9729 36.0560
3  36.2261 35.8152 35.6133 35.9492 35.6356 35.6311 35.5500 36.2311 36.1723 36.4669 36.9884 37.3868
4  37.3465 37.4804 37.5974 37.6518 38.0741 38.2140 38.1554 38.2619 38.4068 38.4830 38.9808 39.1039
5  39.3405 39.5922 39.9027 39.7559 39.6056 39.9925 40.2037 40.2961 40.2870 40.2988 39.9189 39.8118
6  39.0746 39.0488 38.9981 38.8979 38.8525 38.7269 38.8219 38.7527 38.4856 37.7157 37.4873 38.3482
7  38.6432 38.5695 38.5278 38.7441 38.9407 39.1040 38.9905 38.7642 39.3942 39.6891 39.8576 40.3177
8  41.2876 41.6865 41.9746 42.4183 42.3963 42.5166 42.4980 43.0629 43.3918 43.9718 44.4919 45.0015
9  45.2942 45.9656 45.9872 45.9237 46.2192 46.2509 46.4421 46.3648 46.7803 47.0954 47.3445 47.2315
10 46.8994 46.7538 46.7685 46.6069 46.9743 46.9233 46.9464 46.4907 46.5136 46.3401 44.8209 43.2340
11 42.6409 41.6602 41.2135 41.2460 41.1515 41.4224 41.8234 42.2573 42.7796 42.9687 43.0614 43.5973
12 44.2288 44.6725 44.7125 44.9643 45.1741 45.1830 45.4535 45.7737 45.9031 45.9207 46.5978 47.0854
13 46.8276 47.5417 48.1310 48.5838 48.9891 49.3428 49.4120 49.4259 49.6639 49.7592 49.8117 49.8949
14 49.2066 49.4502 50.3928 51.4368 51.6276 51.9833 51.9592 52.1543 52.2860 52.7054 53.1047 53.3886
15 53.0453 53.3303 53.4973 52.8938 53.3187 53.3157 53.2433 52.8899 52.9486 53.2390 53.1918 53.2603
16 53.5037 53.5053 53.3294 52.2336 50.9638 50.3348 49.9462 50.1256 50.9386 51.5813 52.4717 52.7685
17 52.4668 52.2260 52.5025 52.2691 52.5803 52.8284 53.1751 53.1679 52.8514 52.4949 51.8940 51.3274
18 50.3043 51.3016 50.9104 50.4627 50.1380 49.9692 49.8138 49.3773 49.2260 48.7874 48.5920 48.2424
19 49.1762 48.8688 49.2654 49.8675 50.2084 50.5089 51.2733 51.8454 52.6303 53.0679 53.2534 53.5343
20 54.6008 54.8350 55.1052 55.4514 55.7141 55.9085 56.0842 56.1376 56.0382 55.9459 56.1667 56.2296
21 56.1398 56.3323 56.4232 56.2693 56.3488 56.3901 56.0234 56.2555 56.4983 56.2648 56.4549 57.0458
22 57.3104 56.9344 56.5420 56.5599 56.6823 56.4976 56.8140 56.7381 56.8532 57.1191 57.3792 57.8623
23 57.6850 58.4399 58.5160 58.8851 59.2653 59.5409 59.9536 60.4517 60.6069 61.4910 61.8137 62.1190
24 62.1469 62.4169 62.5418 62.8959 62.8223 62.9823 63.0093 63.2723 63.0990 63.4122 63.5128 63.8233
25 64.0153 63.7242 63.8691 63.9124 63.4884 63.5187 62.9354 63.5168 63.2954 63.2542 63.4616 63.8467
26 63.4228 64.0446 64.3580 64.2602 64.3973 64.6041 64.5205 64.7326 64.8145 64.3274 63.5753 63.1594
27 62.8852 62.4462 62.1190 62.2415 62.8646 63.4372 63.5128 63.5671 64.1330 64.0213 63.9480 63.6937
28 63.3374 63.7911 64.3212 64.8088 65.0202 65.0295 65.6172 65.2943 65.4460 65.9369 66.2174 66.2772
29 66.5643 66.8594 66.7658 67.0000 66.7674 66.8781 67.0845 67.0140 67.3345 67.8515 68.1326 68.5054
30 68.7648 68.7836 69.4766 69.8703 70.2281 70.6763 70.7846 71.2053 71.4767 72.0820 72.5263 73.2879
31 73.4219 73.3025 73.4081 73.3612 73.6104 73.8602 73.5664 74.4950 74.7937 74.7017 74.8897 75.1755
32 74.6841 75.8344 75.7631 76.4562 77.0161 77.6669 77.5662 78.0160 78.5532 78.5065 79.1996 79.7143
33 79.8273 80.7930 81.3340 81.3531 81.8293 82.2285 82.8557 83.7214 84.4651 85.1918 85.9397 86.2047
34 86.6474 86.7612 86.8198 87.1411 87.6952 87.1450 86.8423 88.6247 88.4515 89.1677 89.1098 89.4407
35 89.8594 90.3386 90.4819 90.7274 91.3520 91.1994 91.7766 92.1629 91.7740 92.9979 93.4371 94.1593
36 94.1758 94.4557 94.7980 95.4808 95.6435 95.7353 95.5906 95.3112 95.6790 95.3970 95.4229 95.1573
37 94.5448 93.9398 93.7201 93.4469 92.8760 92.3208 91.7933 91.6795 91.3289 90.9315 90.4860 90.5073
38 91.0794 91.0553 91.7980 92.1771 92.5668 93.4476 93.2237 93.2359 93.3654 93.0834 93.5693 93.1103
39 93.8198 93.9532 93.7358 93.0657 93.0918 93.2476 93.6582 93.5246 94.0751 94.2079 94.9338 94.8662
dec.GDP <- stl(GDPQ, s.window = "periodic")

plot(dec.GDP)

my.trend.data <- data.frame(dec.GDP[["time.series"]])

T_gdp <- ts(my.trend.data$trend, frequency = 4)

detrended.GDP <- log(GDPQ) - log(T_gdp)
  
plot(detrended.GDP)

acf(detrended.GDP, lag.max = 156)  

checkresiduals(detrended.GDP) 

# Multiplicative decompositions


dec.INDP <- stl(INDPM, s.window = 7, t.degree = 1)

plot(dec.INDP)

my.trend.data2 <- data.frame(dec.INDP[["time.series"]])

T_indp <- ts(my.trend.data2$trend , frequency = 12)

detrended.INDP <- log(INDPM) - log(T_indp)
  
acf(detrended.INDP, lag = 156)

ts.plot(detrended.INDP)

checkresiduals(detrended.INDP)

According to adf.test my data is stationary, which could be also seen, when the detrended version is plotted. Yet, the residuals do not look like white noise to me and this concerns me greatly. Could anyone advise what I am doing wrong/missing? Thank you very much in advance!

IP RESIDUALS

GDP residuals:

enter image description here

EDIT: GDP residuals use much better, when one uses: dec.GDPQ <-stl(log(GDPQ), s.window = "periodic", t.window = 6, t.degree = 0)

I hope someone will find this useful. I will update for the IP series if eventually.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.