Announcement

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

  • Multiple regression

    Hi!
    I'd be grateful for help with that:
    I have over 1000 products and I would like to test for unit root in their prices- each of them separately.
    I tried (after tsset)

    foreach x in product{
    dfuller price L.price if product==`x'
    }

    But the results are the same as if I just ran
    dfuller price L.price

    What I would like to see is the result of dfuller test FOR EACH product, ie.
    product=="a"
    dfuller results

    product=="b"
    dfuller results

    etc

    Thanks!

  • #2
    Your loop is

    Code:
     
    foreach x in product {
         dfuller price L.price if product == `x'
    }
    but evidently not what you want. For Stata the loop reduces to a single statement

    Code:
     
    dfuller price L.price if product == product
    and the qualifier does not bite as the test always returns true, just as surely as 42 always equals 42.

    You're imagining somehow, or so I guess, that "in" somehow means that Stata will look inside your variable, identify distinct values, and then work at the contents of the loop separately for each distinct value. I don't know why you thought that; perhaps it's how some other software you know would work with similar syntax. If you found any guide to Stata implying that this is what Stata does, please tell us because that is totally wrong and we should avoid your guide like the proverbial plague.

    For other ways to do this, see http://www.stata.com/support/faqs/da...ach/index.html

    How you expect to scan the results of a thousand tests is a different question.


    Comment

    Working...
    X