Hello,

I have this time series data looking at whether food contamination in a school district led to incidence of hospitalizations. I have already conducted other analysis but I am looking to find the lag time between peaks and troughs of food contamination with the incidence of hospitalizations. Does anyone know how to do this easily? I was using the below code which is not at all giving me what I want.


tsset id
dfuller numberofincidents, trend lag(2)
varbasic numberofincidents foodcontamination , lag(1)



Code:
* Example generated by -dataex-. For more info, type help dataex clear input int WeekOf byte id float(numberofincidents foodcontamination) 22283 1 0 102.41084 22290 2 20 74.084435 22297 3 0 61.01071 22304 4 20 34.863262 22311 5 0 17.431631 22318 6 0 15.252678 22325 7 20 17.431631 22332 8 0 10.89477 22339 9 0 10.89477 22346 10 0 13.073724 22353 11 0 6.536862 22360 12 0 13.073724 22367 13 0 19.610586 22374 14 20 30.505356 22381 15 0 28.3264 22388 16 40 28.3264 22395 17 0 15.252678 22402 18 20 6.536862 22409 19 0 6.536862 22416 20 0 8.715816 22423 21 20 10.89477 22430 22 20 2.178954 22437 23 0 2.178954 22444 24 0 4.357908 22451 25 0 6.536862 22458 26 0 6.536862 22465 27 0 15.252678 22472 28 20 17.431631 22479 29 20 74.084435 22486 30 40 78.44234 22493 31 80 56.65281 22500 32 20 69.726524 22507 33 60 71.90548 22514 34 40 54.47385 22521 35 0 71.90548 22528 36 20 98.05293 22535 37 0 80.6213 22542 38 0 87.15816 22549 39 0 50.11594 22556 40 0 32.68431 22563 41 0 32.68431 22570 42 0 30.505356 22577 43 0 41.40013 22584 44 0 56.65281 22591 45 0 74.084435 22598 46 20 61.01071 22605 47 0 135.09515 22612 48 0 93.69502 22619 49 20 93.69502 22626 50 20 296.33774 22633 51 20 745.2023 22640 52 60 1056.7927 22647 53 0 858.5079 22654 54 60 623.1808 22661 55 60 437.9698 22668 56 60 274.54822 22675 57 60 189.569 22682 58 0 102.41084 22689 59 20 78.44234 22696 60 0 65.36862 22703 61 0 47.93699 22710 62 20 50.11594 22717 63 20 61.01071 22724 64 0 93.69502 22731 65 0 132.9162 22738 66 0 204.82167 22745 67 0 211.35854 22752 68 40 222.2533 22759 69 0 392.2117 22766 70 20 394.3907 22773 71 0 416.1802 22780 72 60 418.3592 22787 73 20 337.7379 22794 74 20 385.6749 22801 75 40 366.0643 22808 76 40 383.4959 22815 77 80 372.6011 22822 78 20 337.7379 22829 79 20 268.01135 22836 80 60 350.8116 22843 81 20 324.66415 22850 82 60 344.2747 22857 83 60 300.69565 22864 84 40 300.69565 22871 85 20 246.2218 22878 86 40 211.35854 22885 87 0 220.07436 22892 88 20 265.8324 22899 89 40 246.2218 22906 90 0 209.1796 22913 91 60 180.8532 22920 92 20 185.2111 22927 93 20 185.2111 22934 94 60 169.9584 22941 95 160 165.6005 22948 96 40 165.6005 22955 97 20 102.41084 22962 98 120 159.06364 22969 99 120 119.84247 22976 100 20 176.49527 end format %tdnn/dd/CCYY WeekOf