Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plot line not appearing

    Hi,

    I am looking to plot a line graph for the first difference of variable lvixprice.

    I am using
    Code:
    twoway (tsline D.lvixprice)
    but the line is not plotting- nothing is shown on the line graph

    Data:
    Code:
    input int date float(vixprice lvixprice)
    16284 13.34  2.590767
    16315 12.45  2.521721
    16345 14.02  2.640485
    16376 12.64 2.5368664
    16406 10.84  2.383243
    16437 10.84  2.383243
    16468 10.95 2.3933394
    16496 10.72  2.372111
    16527  13.1  2.572612
    16557 10.84  2.383243
    16588 10.07 2.3095608
    16618 10.59 2.3599102
    16649 11.65  2.455306
    16680 10.27  2.329227
    16710 14.73  2.689886
    16741 12.26  2.506342
    16771 11.63  2.453588
    16802 12.77 2.5470986
    16833 12.69  2.540814
    16861 12.44  2.520917
    16892 12.23  2.503892
    16922 21.27  3.057298
    16953  16.8  2.821379
    16983 16.48 2.8021474
    17014 13.93  2.634045
    17045  14.2  2.653242
    17075 12.62  2.535283
    17106 13.52   2.60417
    17136 13.05  2.568788
    17167 14.36 2.6644466
    17198 16.87  2.825537
    17226 14.89   2.70069
    17257 15.34  2.730464
    17287 14.28   2.65886
    17318 14.69  2.687167
    17348  21.8   3.08191
    17379 23.62  3.162094
    17410 20.65  3.027715
    17440 21.01 3.0449984
    17471 23.74 3.1671615
    17501 23.24  3.145875
    17532 29.03   3.36833
    17563 29.06 3.3693626
    17592 26.09  3.261552
    17623 19.79  2.985177
    17653 21.25  3.056357
    17684  23.4  3.152736
    17714 21.79  3.081451
    17745 19.51  2.970927
    17776 39.68 3.6808474
    17806 54.15  3.991758
    17837 44.65  3.798854
    17867  38.9  3.660994
    17898 41.76  3.731939
    17929 38.43 3.6488385
    17957  36.4  3.594569
    17988 30.99 3.4336646
    18018 26.83  3.289521
    18049 25.03  3.220075
    18079 23.77 3.1684244
    18110  23.1  3.139833
    18141 22.35  3.106826
    18171 27.67  3.320349
    18202 25.82 3.2511494
    18232  20.3  3.010621
    18263  22.9  3.131137
    18294 18.45  2.915064
    Is there a minimum number of values required to plot the first difference of a time series variable?

  • #2
    The first difference in your data is always missing if you tsset in terms of daily date, which is my guess at why you see nothing. The previous daily date is never to be found in the dataset as the data are monthly but reported in terms of daily dates. You need to map your dates to monthly dates using mofd() and then tsset in terms of that. new variable.

    Comment


    • #3
      The only issue I have is that this is part of a larger dataset, which is at daily intervals. I have also mapped this into a business calendar-

      Code:
      input int date double FTSE100 float(CCI lvixprice) long my_date
      18631 5899.94        .        . 1771
      18632 6013.87        .        . 1772
      18633 6043.86        .        . 1773
      18634 6019.51        .        . 1774
      18637 5984.33        .        . 1775
      18638  5956.3        .        . 1776
      18639 6014.03        .        . 1777
      18640 6050.72        .        . 1778
      18641 6023.88        .        . 1779
      18644 6002.07        .        . 1780
      18645  5985.7        .        . 1781
      18646 6056.43        .        . 1782
      18647  5976.7        .        . 1783
      18648 5867.91        .        . 1784
      18651 5896.25        .        . 1785
      18652 5943.85        .        . 1786
      18653 5917.71        .        . 1787
      18654 5969.21        .        . 1788
      18655 5965.08        .        . 1789
      18658 5881.37        .        . 1790
      18659 5862.94 96.98054 2.952303 1791
      18660 5957.82        .        . 1792
      18661 6000.07        .        . 1793
      18662 5983.34        .        . 1794
      18665 5997.38        .        . 1795
      18666 6051.03        .        . 1796
      18667 6091.33        .        . 1797
      18668 6052.29        .        . 1798
      18669 6020.01        .        . 1799
      18672  6062.9        .        . 1800
      18673 6060.09        .        . 1801
      18674 6037.08        .        . 1802
      18675 6085.27        .        . 1803
      18676 6087.38        .        . 1804
      18679 6082.99        .        . 1805
      18680  6014.8        .        . 1806
      18681 5996.76        .        . 1807
      18682 5923.53        .        . 1808
      18683 5919.98        .        . 1809
      18686  6001.2        .        . 1810
      18687 5994.01  96.8317   2.7985 1811
      18688 5935.76        .        . 1812
      18689 5914.89        .        . 1813
      18690 6005.09        .        . 1814
      18693 5990.39        .        . 1815
      18694 5973.78        .        . 1816
      18695 5974.76        .        . 1817
      18696  5937.3        .        . 1818
      18697 5845.29        .        . 1819
      18700 5828.67        .        . 1820
      18701 5775.24        .        . 1821
      18702 5695.28        .        . 1822
      18703 5598.23        .        . 1823
      18704 5696.11        .        . 1824
      18707 5718.13        .        . 1825
      18708 5786.09        .        . 1826
      18709 5762.71        .        . 1827
      18710 5795.88        .        . 1828
      18711 5880.87        .        . 1829
      18714 5900.76        .        . 1830
      18715 5904.49        .        . 1831
      18716 5932.17        .        . 1832
      18717  5948.3        .        . 1833
      18718 5908.76 96.86478 2.711378 1834
      18721 6009.92        .        . 1835
      18722 6016.98        .        . 1836
      18723 6007.06        .        . 1837
      18724 6041.13        .        . 1838
      18725 6007.37        .        . 1839
      18728 6055.75        .        . 1840
      18729 6053.44        .        . 1841
      18730 5964.47        .        . 1842
      18731 6010.44        .        . 1843
      18732  5963.8        .        . 1844
      18735 5996.01        .        . 1845
      18736 5870.08        .        . 1846
      18737 5896.87        .        . 1847
      18738 6022.26        .        . 1848
      18743  6018.3        .        . 1849
      18744 6069.36        .        . 1850
      18745 6068.16        .        . 1851
      18750  6069.9        .        . 1852
      18751 6082.88        .        . 1853
      18752 5984.07        .        . 1854
      18753 5919.98        .        . 1855
      18756 5976.77        .        . 1856
      18757 5942.69        .        . 1857
      18758 6018.89        .        . 1858
      18759    5976        .        . 1859
      18760 5944.96        .        . 1860
      18763 5925.87        .        . 1861
      18764 5923.69        .        . 1862
      18765    5861        .        . 1863
      18766 5923.49        .        . 1864
      18767 5955.99        .        . 1865
      18770 5948.49        .        . 1866
      18771 5835.89        .        . 1867
      18772 5858.41        .        . 1868
      18773 5870.14        .        . 1869
      18774 5880.99        .        . 1870
      end
      format %tdnn/dd/CCYY date
      format %td my_date
      The date variable is the business calendar, and the my_date variable is the original daily dates from 2004-2022 (not sure why it is from 1960-1973 but I guess that is irrelevant to my question).

      Comment


      • #4
        The key point remains that in #2. The graph you ask for is of monthly data and a difference operator manifestly produces useless results with a tsset in terms of daily dates.

        If you want a graph that is a matter for extracting the data to a different dataset (a frame might work, but I don't know) and declaring it as monthly data.

        A crude alternative if the data are exactly as in #1 is to calculate the difference yourself

        Code:
        gen diff = lvixprice -  lvixprice[_n-1]
        but a graph in terms of a daily date axis is going to be harder work to do well than you want.


        Sorry. but business calendars, as previously mentioned to you, are a question for somebody else. I have never used one.
        Last edited by Nick Cox; 03 Feb 2023, 07:31.

        Comment

        Working...
        X