Announcement

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

  • Panel data with three dimensions

    Hi!

    I am working on a project to estimate price elasticity. My data set is aggregated on product - store - week. We also have a dummy (Online) for whether the product were bought online or in-store. If Online = 1, product was bought Online.

    Data example:
    Product | Store | Week | Online
    001 | A | 1 | 0
    001 | A | 1 | 1
    001 | B | 1 | 0
    001 | B | 1 | 1
    001 | C | 1 | 0
    001 | C | 1 | 1
    002 | A | 2 | 0
    002 | B | 2 | 0
    005 | A | 3 | 1
    005 | C | 3 | 1
    etc.

    The data set consists of over 600 000 observations like the ones above. The data set contains observations for two years. I created a new variable that contains week and year (year_week).

    My basic model for estimating price elasicity is: log(q) = a + b*log(p) + ...

    I want to use fixed effect on product level.

    The problem: Since I have several dimensions in my data set, I get some trouble when I try to define our panel data. I first ran the following code:
    xtset product year_week
    But I got the error message "repeated time values within panel (r451)". I realize that this is because we are observing many stores, both online and offline.

    To overcome the problem, I created a new variable where I combined store, product and dummy Online so that I had an unique ID. Still I receive the error message: repeated time values within panel (r451) when I run the following code:
    xtset uniqueID year_week

    My uniqueID is a numberic value, that from our example data row 1 would look like this: 001A0 (product-store-Online).

    I believe that there are some product spesific effects, as well as some store effects and also a combination of product-store effects.

    Do anyone have any suggestions for how to overcome my problem?

    Thanks!


    Last edited by Ele Kol; 07 Nov 2021, 04:52.

  • #2
    Ele:
    1) to overcome the issue that Stata warns you about, you cam -xtset- your datset with -panelid- only, provided that this fix comes at the cost of making time-series related commands, such as lags and leads, unfeasible.
    2) if -fe- is actually the way to go with your dataset and you have more than one fixed effect you want to investigate for your analysis, you may want to consider the community-contributed module -reghdfe-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X