Announcement

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

  • -mipolate- function and its applications

    Previously, Nick Cox kindly introduces the mipolate and its applications at https://www.statalist.org/forums/for...-interpolation

    I follow his guidance and try to convert monthly to daily frequency, but it does properly process what I expect because my codes on daily parts are somewhat odd. Could you please advise me on how to fix the line? Thank you.

    clear all

    // Import Daily data

    input str11 sdate GNP(%)
    date TNA
    2019-12-31 0.743
    2020-01-31 1.037
    2020-02-29 1.37
    2020-03-31 1.923
    2020-04-30 3.132
    2020-05-31 3.593
    2020-06-30 4.401
    2020-07-31 6.694
    2020-08-31 7.213
    2020-09-30 7.952
    2020-10-31 11.893
    2020-11-30 16.556
    2020-12-31 37.326
    2021-01-31 56.148
    2021-02-28 71.492
    2021-03-31 74.326
    2021-04-30 85.461
    2021-05-31 98.696
    2021-06-30 94.388
    2021-07-31 106.678
    2021-08-31 126.547
    2021-09-30 126.002
    2021-10-31 151.083
    2021-11-30 153.071
    2021-12-31 130.322
    2022-01-31 98.111
    end

    generate mdate = monthly(sdate, "YMD")
    format mdate %tm
    generate ddate = day(dofc(mdate))
    tsset ddate
    format ddate %td
    tsfill
    sort ddate

  • #2
    Perhaps this code will be helpful.
    Code:
    generate ddate = daily(sdate, "YMD")
    format ddate %td
    tsset ddate
    tsfill
    mipolate gnp ddate, generate(dgnp)

    Comment


    • #3
      William Lisowski Thanks for your feedback. Unfortunately, it shows "no observations."

      input str11 sdate gnp
      2018-07 0.152
      2018-08 0.364
      2018-09 0.353
      2018-10 0.332
      2018-11 0.363
      2018-12 0.349
      2019-01 0.412
      2019-02 0.433
      2019-03 0.457
      2019-04 0.516
      2019-05 0.671
      2019-06 0.827
      2019-07 0.819
      2019-08 0.77
      2019-09 0.677
      2019-10 0.848
      2019-11 0.736
      2019-12 0.743
      2020-01 1.037
      2020-02 1.37
      2020-03 1.923
      2020-04 3.132
      2020-05 3.593
      2020-06 4.401
      2020-07 6.694
      2020-08 7.213
      2020-09 7.952
      2020-10 11.893
      2020-11 16.556
      2020-12 37.326
      2021-01 56.148
      2021-02 71.492
      2021-03 74.326
      2021-04 85.461
      2021-05 98.696
      2021-06 94.388
      2021-07 106.678
      2021-08 126.547
      2021-09 126.002
      2021-10 151.083
      2021-11 153.071
      2021-12 130.322
      2022-01 98.111
      end


      generate mdate = monthly(sdate, "YM")
      format mdate %tm

      generate ddate = daily(sdate, "YMD")
      format ddate %td
      tsset ddate
      tsfill
      mipolate gnp ddate, generate(dgnp)

      Comment


      • #4
        In post #1 your sdate variable was year-month-day. You have changed sdate to year-month in post #3.

        The code in post #2 was developed using the data in post #1.

        Comment


        • #5
          William Lisowski Thank you for your corrections. I did make some changes following your feedback, but still it says no observations.

          clear all

          input str6 sdate gnp
          2019-12-31 0.743
          2020-01-31 1.037
          2020-02-29 1.37
          2020-03-31 1.923
          2020-04-30 3.132
          2020-05-31 3.593
          2020-06-30 4.401
          2020-07-31 6.694
          2020-08-31 7.213
          2020-09-30 7.952
          2020-10-31 11.893
          2020-11-30 16.556
          2020-12-31 37.326
          2021-01-31 56.148
          2021-02-28 71.492
          2021-03-31 74.326
          2021-04-30 85.461
          2021-05-31 98.696
          2021-06-30 94.388
          2021-07-31 106.678
          2021-08-31 126.547
          2021-09-30 126.002
          2021-10-31 151.083
          2021-11-30 153.071
          2021-12-31 130.322
          2022-01-31 98.111
          end

          generate mdate = monthly(sdate, "YMD")
          format mdate %tm

          generate ddate = daily(sdate, "YMD")
          format ddate %td
          tsset ddate
          tsfill
          mipolate gnp ddate, generate(dgnp)

          Comment


          • #6
            In post #1 and in post #3 the input command reads sdate as str11 - a string variable of at most 11 characters. In post #5 it has been changed to str6 - a string variable of at most 6 characters.
            Code:
            . input str6 sdate gnp
            
                     sdate        gnp
              1. 2019-12-31 0.743
              2. 2020-01-31 1.037
              3. 2020-02-29 1.37
              4. end
            
            . list
            
                 +----------------+
                 |  sdate     gnp |
                 |----------------|
              1. | 2019-1    .743 |
              2. | 2020-0   1.037 |
              3. | 2020-0    1.37 |
                 +----------------+
            I'm sympathetic to you as a new user of Stata - there is quite a lot to absorb. And even worse if perhaps you are under pressure to produce some output quickly. Nevertheless, I'd like to encourage you to take a step back from your immediate tasks.

            When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. All of these manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

            The objective in doing the reading was not so much to master Stata - I'm still far from that goal - as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

            Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

            Comment


            • #7
              William Lisowski Thank you for your deep thoughts and advice. After graducation, I really need to know somewaht deep understainding for my job, so I regularly practice and try data management. Luckly, my company supports continuing education which provides a lot of useful techniques and skills for my work.

              With your corrections, I do generate daily variables, but honestly do not fully understand the functions. However, I really thank you to all thoughful supports.

              clear all

              input str11 sdate gnp
              2019-12-31 0.743
              2020-01-31 1.037
              2020-02-29 1.37
              2020-03-31 1.923
              2020-04-30 3.132
              2020-05-31 3.593
              2020-06-30 4.401
              2020-07-31 6.694
              2020-08-31 7.213
              2020-09-30 7.952
              2020-10-31 11.893
              2020-11-30 16.556
              2020-12-31 37.326
              2021-01-31 56.148
              2021-02-28 71.492
              2021-03-31 74.326
              2021-04-30 85.461
              2021-05-31 98.696
              2021-06-30 94.388
              2021-07-31 106.678
              2021-08-31 126.547
              2021-09-30 126.002
              2021-10-31 151.083
              2021-11-30 153.071
              2021-12-31 130.322
              2022-01-31 98.111
              end

              generate mdate = monthly(sdate, "YMD")
              format mdate %tm

              generate ddate = daily(sdate, "YMD")
              format ddate %td
              tsset ddate
              tsfill
              mipolate gnp ddate, generate(dgnp)

              Comment

              Working...
              X