Announcement

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

  • #16
    Nick

    It does not work in my case. The Beta and Constant I get is by month id, but Y is daily.....
    Last edited by Olena Onishchenko; 02 Nov 2018, 02:47.

    Comment


    • #17
      On "does not work" as not a helpful report, please do see the FAQ Advice.

      Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
      That shouldn't matter one bit. In fact a regression was fruitless if the residuals are the same (namely zero) within the set of observations used in the regression. You can only regress for a month with several days worth of observations.

      So, did you even try it? Here is a slightly silly example as you don't give a data example.

      Code:
      . webuse grunfeld, clear
      
      . rangestat (reg) mvalue invest, int(year 0 0)
      
      . gen double residual = mvalue - b_cons - b_invest * invest
      
      . list mvalue invest b_cons b_invest residual if year == 1950
      
           +------------------------------------------------------+
           | mvalue   invest      b_cons    b_invest     residual |
           |------------------------------------------------------|
       16. | 3755.6    642.9   221.98708   4.9984306    320.12187 |
       36. | 1677.4    418.8   221.98708   4.9984306   -637.92973 |
       56. | 1610.5     93.5   221.98708   4.9984306    921.15966 |
       76. |  693.5   100.66   221.98708   4.9984306   -31.629126 |
       96. |  240.1    55.74   221.98708   4.9984306   -260.49961 |
           |------------------------------------------------------|
      116. |  673.8    77.34   221.98708   4.9984306      65.2343 |
      136. |  140.8    42.53   221.98708   4.9984306   -293.77033 |
      156. |  635.2    32.24   221.98708   4.9984306    252.06352 |
      176. |  274.6    43.48   221.98708   4.9984306   -164.71884 |
      196. |  69.05     3.42   221.98708   4.9984306   -170.03171 |
           +------------------------------------------------------+
      So, in this case the coefficient estimates are the same for each year, because that is how we are regressing, but the residuals in general will not be.

      Comment


      • #18
        Hi Nick,

        What you put if your interval is not constant across grouped observations?

        Comment


        • #19
          As the help file tells you, interval() allows you to specify variables as defining the ends of each interval.

          Comment


          • #20
            Originally posted by Nick Cox View Post
            rangestat doesn't support weights, if that is what you are asking. summarize supports the calculation you want, so you could use rangerun (SSC) if you have a problem with similar flavour to rangestat.
            Hi, Nick. How can I use the "excludeself" option with rangerun ? Because I need caculate the mean excluding the current observation and I need weights. Thank you!

            Comment


            • #21
              rangerun has no excludeself option. You need to write your code for rangestat

              Comment


              • #22
                ... or arrange exclusion in your rangerun code.

                Comment


                • #23
                  Originally posted by Nick Cox View Post
                  rangerun has no excludeself option. You need to write your code for rangestat
                  All right. Thanks a lot.

                  Comment


                  • #24
                    Originally posted by Nick Cox View Post
                    ... or arrange exclusion in your rangerun code.
                    I don't know how to arrange exclusion in my rangerun code. Because I want mean and median excluding the current observation with weight , I can use sum/tabstat like
                    program myprog
                    sum temp [pw=weight]
                    gen mean=r(mean)
                    gen median=r(median)
                    end
                    rangerun myprog ,by(group) interval(group . .)

                    How should I arrange exclution condition?

                    Comment


                    • #25
                      There is a detailed example in the help on excluding the present observation.

                      Comment


                      • #26
                        A small query regarding rangestat, why rangestat regression command takes a much longer time in Stata Mac version as opposed to Stata Windows version (I tried the same variables and data). All other commands are equally fast in both versions. Just curious to find out.

                        Comment


                        • #27
                          #26 It's exactly the same code, so the answer lies either in your machine(s) or in how Mata is implemented, so utterly beyond the program authors.

                          Comment


                          • #28
                            Hi. Just a small query with regards to 'rangestat'. When using 'rangestat' for regression is it possible to use the no constant option? If yes, where should the option be specified. Thanks.

                            Comment


                            • #29
                              #28 Zain Mian rangestat doesn't support such regressions. rangestat is programmable, so why not write your own code? Or use rangerun (SSC)? Alternatively, asreg (SSC) may be closer to what you want.

                              Comment


                              • #30
                                Can I use this to solve the problem of obtaining Anova information, specifically RSS and df for a set of loops of a random variable? I can't find a way to save my y variable and the errors here:
                                clear
                                local mc = 10
                                set obs `mc'
                                g data_store_x3 = .
                                g data_store_x2 = .
                                g data_store_con = .
                                g data_store_y = .

                                quietly{
                                forvalues i = 1(1) `mc' {
                                if floor((`i'-1)/100) == ((`i'-1)/100) {
                                noisily display "Working on `i' out of `mc' at $S_TIME"
                                }
                                preserve
                                clear
                                set obs 50
                                g x2 = runiform()
                                g x3 = runiform()
                                g e = rnormal()
                                g y = 1 -3*x2 + 2*x3 + e
                                reg y x2 x3
                                local x2coeff = _b[x2]
                                local x3coeff = _b[x3]
                                local const = _b[_cons]
                                restore
                                replace data_store_x3 = `x3coeff' in `i'
                                replace data_store_x2 = `x2coeff' in `i'
                                replace data_store_con = `const' in `i'
                                foreach var of varlist `x2coeff' `x3coeff' `const' {
                                noisily oneway `var' treatment
                                }

                                }
                                }

                                Comment

                                Working...
                                X