Announcement

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

  • unknown function runiformint()

    Hi

    I try to estimate the time varying granger causalities in a set of interest rates using the following code

    Code:
     
     tvgc us uk gm, trend win(24) sizecontrol(12) p(2) d(1) boot(499) graph eps  pdf notitle restab robust
    The stata returns the following error:

    HTML Code:
      unknown function runiformint()
    I cannot find any resolution to this error.

    I would appreciate any help.

  • #2
    Try this to see if works:
    gen x = runiformint(1,10) runiformint is a Stata command, so it should be there. If not, then you may have to update Stata or replace the ado.

    Comment


    • #3
      -runiformint()- came into Stata about version 14, maybe 15, so maybe Evamgelos has an older version? A standard replacement would be something using -floor(runiform() * SomeTopNumber)- so it might be possible to make -tvgc- (from Stata Journal, apparently) work by making appropriate substitutions in -tvgc.ado-. However, take into account that I know less than zero about -tvgc- or its purposes.(<grin>)

      Comment


      • #4
        help whatsnew13to14 in a recent version of Stata confirms that function runiformint() was introduced in Stata 14. (Strictly, it is not a command. In Stata, commands and functions are disjoint.)

        So, Evamgelos Salachas is likely to be using Stata 13 or an earlier version. If so then the help file just mentioned is not in their Stata, but the same help is on the internet at

        https://www.stata.com/help.cgi?whatsnew13to14

        See long-standing advice in the FAQ:

        11. What should I say about the version of Stata I use?

        The current version of Stata is 18. Please specify if you are using an earlier version; otherwise, the answer to your question may refer to commands or features unavailable to you. Moreover, as bug fixes and new features are issued frequently by StataCorp, make sure that you update your Stata before posting a query, as your problem may already have been solved.
        @Mike Lacy's work-around is the way to go. If you need more than 2 distinct values, choose your own "value of 2". If you need values to start at some value not 0, add a constant accordingly.

        Code:
        , clear
        
        . set obs 100
        Number of observations (_N) was 0, now 100.
        
        . set seed 2803
        
        . gen foo = floor(runiform() * 2)
        
        .. tab foo
        
                foo |      Freq.     Percent        Cum.
        ------------+-----------------------------------
                  0 |         53       53.00       53.00
                  1 |         47       47.00      100.00
        ------------+-----------------------------------
              Total |        100      100.00
        
        .

        Last edited by Nick Cox; 18 Jan 2024, 05:47.

        Comment


        • #5
          Perhaps, the authors of tvgc should be notified? If the command is advertised for (and, technically, runs under) version 13, then it should not use functions (or commands) introduced later.

          Comment


          • #6
            #5 is a good point. I will flag to the authors.

            Comment


            • #7
              tvgc should be labeled as requiring version 14, as that is the version of official Stata in which the runiformint() function was introduced.

              Comment


              • #8
                The tvgc.ado file says 14 or later.

                The runiformint() function is on line 135 if the tvgc_boot.ado. You could recode it.

                What's there: qui replace `indx`j'' = runiformint(`pp1',`T')

                What might work: qui replace `indx`j'' = floor(runiform(`pp1',`T'+1)

                You've got to add the 1 to get the full range.

                Comment


                • #9
                  Originally posted by George Ford View Post
                  The tvgc.ado file says 14 or later.
                  Yes, since today. If the declaration had always been version 14, then the error reported in #1 would never have appeared in the first place. Instead, we would have seen something like

                  Code:
                  this is version 13.0 of Stata; it cannot run version 14.0 programs
                       You can purchase the latest version of Stata by visiting https://www.stata.com.
                  r(9);

                  Comment


                  • #10
                    Most people don't read ado files, so stating it there isn't much help.

                    Dan's error message would have been quite useful.

                    I wonder if replacing the runiformint code would solve all the version problems.

                    Comment


                    • #11
                      I can't speak for the program authors, but I would imagine that they want any update to be sure to produce exactly the same results.

                      The easiest way to ensure that is to correct the version statement.

                      Otherwise, it's a user prerogative and a user responsibility to clone the code under a different name and make changes.

                      Comment


                      • #12
                        Originally posted by George Ford View Post
                        I wonder if replacing the runiformint code would solve all the version problems.
                        We can only know for sure by running the thing on a physical copy of Stata 13 (or older). It seems to be a common misconception that by setting the version to an older version of Stata, all changes and improvements are undone. That is not how version control works in Stata. And, that's a good thing.

                        Comment


                        • #13
                          Adopt a suitably inscrutable expression and intone as this week's mantra:

                          version is not a time machine.
                          Less cryptically, more at https://www.stata.com/support/faqs/p...stata-version/

                          Confession: When I accepted the challenge of writing that FAQ, I underestimated how many details there are, and they exist with good reasons!

                          Comment


                          • #14
                            I downloaded interest rate data from Fred for US, UK, and Germany; 10-year bonds.

                            I tried it with the code as is (using v18). The seed was set in the tvgc options. I got the same results in 2 runs so setting the seed worked an intended.

                            I then tried it with the replacement code in #8. (It needs an extra close paren at the end.) The results were not the same (though close). I don't know why.

                            Note that the first set of the four results is identical.
                            Last edited by George Ford; 18 Jan 2024, 14:21.

                            Comment


                            • #15
                              The replacement in #8 would not work because runiform() did not accept arguments in Stata 13. It is not supposed to do so in 18 either, according to the syntax diagram. Not sure why the results do not match; I believe they should.

                              The replacement for Stata 13 should be (see Gould, 2012)

                              Code:
                              qui replace `indx`j'' = floor((`T'-`pp1'+1)*runiform() + `pp1')

                              Edit: On setting the seed: that one is quite complex. There is a separate user-version that is only set in the command line and do-files but in ado-files (unless forced by adding the respective option), there are now different random number generators that can be explicitly specified when setting the seed (e.g., set_seed_mt64) but can also be set for the entire session. It is hard to fully understand what is going on when such things are involved.
                              Last edited by daniel klein; 18 Jan 2024, 14:45.

                              Comment

                              Working...
                              X