Announcement

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

  • Rangestat regression

    I have a code :
    Code:
    foreach v of var x1-x30 { 
      2. rangestat (reg) `v' smb , interval(mdate  0 5) 
      3. rename reg_nobs nobs_`v' 
      4. rename b_smb coef_`v' 
      5. drop reg_* b_* se_* 
      6. }
    where I am attempting to produce rolling regressions at daily intervals every 6 months for 18 years. However, when I see the results, each coefficient I see is the same for each day for each of the 6 month periods, even though the smb variable changes every day. Is this code correct for what I am trying to achieve, which is to regress each x variable on smb in 6 month increments- I am doing this so I can see those that have negative coefficients in that interval (not the entire 18 years), so I can use these variables only.

  • #2
    As you are pooling data for 6 month intervals, the coefficients are likely to change when the monthly date does, but not just because the daily date does. That is, 30 December and 31 December are always together in any 6 month interval that includes them.

    Comment


    • #3
      Is there a way to amend my code so it pools data for daily intervals but within a 6-month range? Because as you said it is only changing monthly not daily

      Comment


      • #4
        Naturally. Your intervals need to be specified in terms of a daily date variable with some convention about intervals 180 or so days long.

        Comment


        • #5
          So would this look like
          Code:
          gen ddate = doy(date) 
          foreach v of var ldiffcost_w - ldiffexpense_w { 
          rangestat (reg) `v' rmrf , interval(ddate  0 180) 
          rename reg_nobs nobs_`v' 
          rename b_rmrf coef_`v' 
          drop reg_* b_* se_* 
          }
          If I did every 180 days it will be a consistent 6 month interval- is there a way around this to include only windows from Jan 1st- june 30th and july 1st-december 31st for each window?

          Comment


          • #6
            You seem to be working on the same problem as Raul Athwall. Either you are the same person or if not you should study the threads under their name for advice.

            This similarity was disguised by changing variable names in #1 but the disguise didn’t last.

            Using day of the year really can’t achieve anything useful here, as intervals won’t wrap as desired at year ends.

            Otherwise you can get disjoint half-year intervals easily enough.

            Comment


            • #7
              Thanks, I will have a look at the other thread. Just another method:

              Code:
              foreach v of var ldiffcost_w - ldiffexpense_w {
                  rangestat (reg) `v' rmrf , interval(day_of_year  0 180)
                  rename reg_nobs nobs_`v'
                  rename b_rmrf coef_`v'_jan_jun
                  drop reg_* b_* se_*
                  rangestat (reg) `v' rmrf , interval(day_of_year  181 365)
                  rename reg_nobs nobs_`v'
                  rename b_rmrf coef_`v'_jul_dec
                  drop reg_* b_* se_*
              }
              Can splitting a year like this bring about a more suitable result with 'doy'?

              Comment


              • #8
                Not the same thing at all. Very confused. The numeric arguments to interval() are offsets, not absolute values.

                As said, please see my replies to Raul Athwall for my reluctance to support this way of treating the forum. Overlapping threads using different identities is not an improvement on overlapping threads,

                Comment

                Working...
                X