Announcement

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

  • J(): 3300 argument out of range

    Dear all,

    I tried to do hp filtering in Stata using tsfilter hp ct=pi command, but for some reason I get error message:

    J(): 3300 argument out of range
    _TSFILTER_getQ(): - function returned error
    _TSFILTER_hpFilter(): - function returned error
    <istmt>: - function returned error

    The data file is imported from Excel and includes quarterly panel data. Does anyone have idea why the error message shows up?
    Attached Files

  • #2
    No I have no idea since you didn't provide your example data using dataex and you didn't provide code. Please provide both your data using dataex and your exact code you used using

    Code:
    Code
    delimiters.

    Comment


    • #3
      Also, when I do
      Code:
      import delim "https://www.statalist.org/forums/filedata/fetch?id=1653360", clear
      I get a mess; this is why we ask you to use dataex (unless your dataset is from a public, easily accessible source which we can simply import) like say
      Code:
      import delim "https://www2.census.gov/geo/docs/reference/state.txt", clear

      Comment


      • #4
        I am not a user of tsfilter so I am unsure what the expected output is. But I'm up for a challenge.

        In post #3 Jared demonstrated something I hadn't realized before: that I can read an attached file using its URL rather than downloading it, which is particularly helpful for the Excel dataset you attached to post #1, since, as with many others here, I'm reluctant to download workbooks that can execute active content should they be opened in Excel. But it's not nearly as helpful as giving the actual data input to the tsfilter command.

        As Jared wrote in post #2, the data you have given us not only is not in dataex format, it is not even ready for use as Stata panel data. The date variable is a character string containing the first day of each fiscal quarter, e.g. "January 1, 1991", and the panelid is also a string variable. The following example demonstrates the basic technique for setting up your data as panel data, and then runs the tsfilter command without error, although it is up to you to determine if it was successful in giving you what you wanted.
        Code:
        import excel "https://www.statalist.org/forums/filedata/fetch?id=1653360", clear firstrow
        generate qtr = qofd(daily(date,"MDY"))
        format %tq qtr
        encode panelid, generate(id)
        tsset id qtr
        tsfilter hp ct=pi
        Code:
        . import excel "https://www.statalist.org/forums/filedata/fetch?id=1653360", clear firstrow
        (3 vars, 351 obs)
        
        . generate qtr = qofd(daily(date,"MDY"))
        
        . format %tq qtr
        
        . encode panelid, generate(id)
        
        . tsset id qtr
        
        Panel variable: id (strongly balanced)
         Time variable: qtr, 1991q1 to 2020q1
                 Delta: 1 quarter
        
        . tsfilter hp ct=pi 
        
        .

        Comment


        • #5
          William Lisowski It's a nice trick isn't it? I work with public data a lot. So if I don't need to use Python (as I sometimes must) to grab a dataset from a website, I'll literally just use the URL to grab it in my do files as I do above.

          The benefit of it is that you don't need to manually remember where you get stuff from, since assuming the URL doesn't change, your code does your data collection for you. In some of my files, I've literally looped through URLs with a common name to get multiple files at once.

          I honestly wish people were one, taught that this technique existed, and two, did it more for Statalist. Too often, we get people working with some abstract/nebulous dataset that seemingly came from nowhere, when all along their main outcome could have just been pulled it from the ether right into their data editor. It would help us quite a lot I think in seeing what certain issues are

          Comment


          • #6
            Jared Greathouse I installed dataex, but then using command seen on https://www.statalist.org/forums/for...-for-statalist

            Code:
            sysuse auto
            egen makeid = group(make)
            dataex makeid rep78 price foreign if rep78 == 5
            I get error message

            Code:
            no; data in memory would be lost
            I apologize for any beginner mistake in advance, I'm not sure if I should've adjusted the code in some way.

            The code I used on my file is:

            Code:
            import excel "Filter.xls", sheet("Filter") firstrow
            gen date1 = date(date, "mdy")
            tsset date1 date1, quarterly
            tsfilter hp ct=pi
            William Lisowski regarding the example of panel data, when I run the code I obtain the error message

            Code:
            file https://www.statalist.org/forums/filedata/fetch?id=1653360.xlsx not found

            Comment


            • #7
              Svit Valencic

              You should change your code in post #6 to
              Code:
              import excel "Filter.xls", sheet("Filter") firstrow
              gen date1 = qofd(date(date,"MDY"))
              format %tq date1
              encode panelid, generate(id)
              tsset id date1, quarterly
              tsfilter hp ct=pi
              There was no need for you to try to read the data directly from your Statalist post when you tried my example.

              In your code
              Code:
              gen date1 = date(date, "mdy")
              tsset date1 date1, quarterly
              tsfilter hp ct=pi
              • where you have "mdy" you should have "MDY"
              • when that is corrected, date1 is a Stata daily date, not a Stata quarterly date as my code creates
              • the first argument to your tsset command needs to be a numeric panel identifier
              My code corrects all those errors
              • it converts the Excel date to a quarterly date correctly
              • it creates a numeric panel id and uses that as the first argument to the tsset command
              Stata's "date and time" variables are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

              All Stata manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through the PDF D

              Comment


              • #8
                William Lisowski Amazing, the code works now, thank you. I will read that chapter.

                Comment


                • #9
                  Another question: the reason for hp filtering is that I'm trying to replicate data I obtained earlier, but I don't succeed in finding used procedure.

                  The transformation converts annual data for inflation into quarterly data. I'm attaching annual data and the quarterly output. Interestingly, the quarterly values aren't simply the annual values divided by four, but each is different. I'm assuming data were detrended or the fixed effect was subtracted. I'm also attaching my further work on decomposition of data of inflation and four other variables on trend and cycle components, as well as fixed effect. I would be most grateful for any insights, as I need data for my master thesis.
                  Attached Files

                  Comment

                  Working...
                  X