Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: reshaping data?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: reshaping data?
Date   Thu, 25 Oct 2012 15:16:58 +0100

This model formulation makes me feel a bit queasy, but I think what
you want is something like this.

Suppose for concreteness the number of items is fixed at 8. (I don't
see how this will work if the number is not fixed.) So, "for any value
of 8"

sort code_family code_item
forval i = 1/8 {
       by code_family : gen P`i' = P[`i']
}

Note that, contrary to your title, there is no -reshape- here as you
want your observations to remain observations; at least that's my
understanding.

Nick

On Thu, Oct 25, 2012 at 3:08 PM,  <[email protected]> wrote:

> I have to estimate the equation
>
> Q1=a+b1P1+b2P2+…bnPn+e
>
> Where Q1 is the quantity of item 1 sold by a supermarket during a week , P1
> is the price of item 1 in that week, the other prices are those of the n
> items belonging to the same family of items. My data set is organized as
> follows:
>
>
> Code_item       week    Q       P       Code_family
> 789             1       8       2       1
> 790             1       25      4       1
> 791             1       9       1.3     1
>
> 792             1       12      2       1
>
> 800             1       7       2       2
> 801             1       20      1.2     2
> 802             1       11      1.6     2
>
> 803             1       12      2       2
>
> And so forth for the other weeks and families…
>
> For each item, how can I include in my regression the prices of the other
> (n-1) items of the same family, ignoring the prices of the items belonging
> to other families?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index