Announcement

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

  • Error: r(451) repeated time values within panel

    Code: Summarize

    Variable | Obs Mean Std. Dev. Min Max
    -------------+---------------------------------------------------------
    Country | 0
    countryid | 544 1 0 1 1
    Mrket | 0
    Marketid | 544 1.5 .5004602 1 2
    latitude | 544 9.117635 2.748222 6.37194 11.86333
    -------------+---------------------------------------------------------
    longitude | 544 2.9095 .4751769 2.43476 3.38424
    closestmar~t | 0
    euclideankm | 544 88.01 28.35607 59.68 116.34
    subscription | 544 42.29927 37.05158 .37 97.13
    proportion | 544 .165 .025023 .14 .19
    -------------+---------------------------------------------------------
    scaledsubs~n | 544 6.979319 6.273235 .0518 18.4547
    commodity | 0
    commodityid | 544 1.5 .5004602 1 2
    quarter | 544 2.5 1.119063 1 4
    year | 544 2008 4.903488 2000 2016
    -------------+---------------------------------------------------------
    pricetype | 0
    price | 544 274.9063 127.5307 108.11 510
    unit | 0
    currency | 0
    rainfall | 544 11.77351 11.09635 .4435913 45.95602

    Apologies, as I am new to Stata and I was wondering if anyone could help. I am using Panel Data and my variable price should be the following function. Price (marketid, commodityid, quarter, year, pricetype) e.g. the price should be specific for the time, quarter, commodity, price type (retail or wholesale) and market.

    I have tried using the following code:

    xtset price year

    and I receive the error:

    repeated time values within panel
    r(451);

    My data is organised as a column for year, and one for quarter (and one for each of the variables listed above)

    This would be hugely appreciated. Thanks in advance

  • #2
    Well, the error message means exactly what it says. There are some situations where the same value of price occurs in more than one year. Ordinarily, I tell people when this happens to review their data for errors. But in this case, from your description, I see no reason to expect that each value of price will occur only in one year. In fact, it's hard for me to imagine that that would make sense in any realistic context.

    I think perhaps you have misunderstood how -xtset- works and what it does. The purpose of -xtset- is to identify for Stata which variable (it must be only one) identifies the panel, and which variable marks time within panels. I cannot tell from your description whether in your case the panel variable should be the market id or the commodity id, or perhaps the combination of both. I imagine that for the time variable, it should be the combination of the quarter and year. To capture that properly, you need to create a Stata internal format quarterly date variable from them:

    Code:
    gen qdate = quarterly(string(quarter)+"q"+string(year), "QY")
    format qdate %tq
    qdate will then serve as a time variable in your -xtset- statement.

    As I said, I cannot tell from what you describe just what your panel is and whether it is captured in a single variable or whether you will need to make a new variable the identifies combinations (using, for example, -egen long panelid = group(something_or_other)-.

    For more help with that, a clearer explanation of the roles and relationships among commodity id, market id, and pricetype, as well as an example of your data would be necessary. Please be sure to use the -dataex- command to show your example data. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment


    • #3
      Hi,

      Thank you for the response. The code dataex results in the error:

      input statement exceeds linesize limit. Try specifying fewer variables
      r(1000);

      When I remove the top line (names of variables) and rerun the code i get the following:

      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str5 var1 byte var2 str16 var3 byte var4 float(var5 var6) str4 var7 float(var8 var9 var10) str6 var11 byte(var12 var13) int var14 str8 var15 float var16 str2 var17 str3 var18 float var19
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .37 .0518 "Millet" 1 1 2000 "Producer" 110 "KG" "XOF" .8320871
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .59 .0826 "Millet" 1 2 2000 "Producer" 130 "KG" "XOF" 9.266488
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .69 .0966 "Millet" 1 3 2000 "Producer" 115 "KG" "XOF" 17.017979
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .81 .1131182 "Millet" 1 4 2000 "Producer" 110 "KG" "XOF" 2.7170014
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .97 .1358 "Millet" 1 1 2001 "Producer" 131.81 "KG" "XOF" .4435913
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.21 .1694 "Millet" 1 2 2001 "Producer" 135 "KG" "XOF" 8.8764305
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.49 .2086 "Millet" 1 3 2001 "Producer" 170 "KG" "XOF" 15.918653
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.77 .24728926 "Millet" 1 4 2001 "Producer" 172.22 "KG" "XOF" 1.1938106
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.03 .2842 "Millet" 1 1 2002 "Producer" 175 "KG" "XOF" 1.2990117
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.4 .336 "Millet" 1 2 2002 "Producer" 175 "KG" "XOF" 9.72025
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.51 .3514 "Millet" 1 3 2002 "Producer" 110 "KG" "XOF" 17.741055
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3 .4198238 "Millet" 1 4 2002 "Producer" 115 "KG" "XOF" 3.802082
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.03 .4242 "Millet" 1 1 2003 "Producer" 115 "KG" "XOF" 1.2800548
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.06 .4284 "Millet" 1 2 2003 "Producer" 111.11 "KG" "XOF" 12.08556
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.11 .4354 "Millet" 1 3 2003 "Producer" 135 "KG" "XOF" 21.25432
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.14 .4396551 "Millet" 1 4 2003 "Producer" 131.22 "KG" "XOF" 3.5291195
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.99 .5586 "Millet" 1 1 2004 "Producer" 142.19 "KG" "XOF" .776113
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 4.19 .5866 "Millet" 1 2 2004 "Producer" 175 "KG" "XOF" 11.494287
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.01 .7014 "Millet" 1 3 2004 "Producer" 152.22 "KG" "XOF" 17.888
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.93 .8297426 "Millet" 1 4 2004 "Producer" 142.22 "KG" "XOF" 2.598993
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.28 .8792 "Millet" 1 1 2005 "Producer" 135 "KG" "XOF" 1.9511178
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.71 .9394 "Millet" 1 2 2005 "Producer" 115 "KG" "XOF" 9.160417
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.02 .9828 "Millet" 1 3 2005 "Producer" 141.11 "KG" "XOF" 16.668852
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.47 1.0457909 "Millet" 1 4 2005 "Producer" 111.11 "KG" "XOF" 2.5000436
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 8.01 1.1214 "Millet" 1 1 2006 "Producer" 138.11 "KG" "XOF" 1.093254
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 9.98 1.3972 "Millet" 1 2 2006 "Producer" 211.22 "KG" "XOF" 8.828572
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 11.09 1.5526 "Millet" 1 3 2006 "Producer" 152.22 "KG" "XOF" 17.47267
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 12.85 1.7987545 "Millet" 1 4 2006 "Producer" 150 "KG" "XOF" 3.420969
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 14.91 2.0874 "Millet" 1 1 2007 "Producer" 155 "KG" "XOF" .8597299
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 17.05 2.387 "Millet" 1 2 2007 "Producer" 111.11 "KG" "XOF" 12.250764
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 20.79 2.9106 "Millet" 1 3 2007 "Producer" 145 "KG" "XOF" 19.497534
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 24.27 3.397466 "Millet" 1 4 2007 "Producer" 115.89 "KG" "XOF" 2.830138
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 27.89 3.9046 "Millet" 1 1 2008 "Producer" 111.11 "KG" "XOF" 1.162299
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 31.89 4.4646 "Millet" 1 2 2008 "Producer" 141.11 "KG" "XOF" 11.977502
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 36.98 5.1772 "Millet" 1 3 2008 "Producer" 175 "KG" "XOF" 22.16582
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 41.69 5.835991 "Millet" 1 4 2008 "Producer" 132.22 "KG" "XOF" 3.137085
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 45.95 6.433 "Millet" 1 1 2009 "Producer" 175 "KG" "XOF" 1.074003
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 47.23 6.6122 "Millet" 1 2 2009 "Producer" 141.11 "KG" "XOF" 10.02601
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 52.38 7.3332 "Millet" 1 3 2009 "Producer" 138.11 "KG" "XOF" 18.241352
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 56.27 7.878055 "Millet" 1 4 2009 "Producer" 188.11 "KG" "XOF" 4.314962
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 61.02 8.5428 "Millet" 1 1 2010 "Producer" 111.11 "KG" "XOF" 1.2736073
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 67.01 9.3814 "Millet" 1 2 2010 "Producer" 142.22 "KG" "XOF" 8.645645
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 68.89 9.6446 "Millet" 1 3 2010 "Producer" 111.22 "KG" "XOF" 17.182041
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 76.91 10.76704 "Millet" 1 4 2010 "Producer" 175 "KG" "XOF" 3.729227
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 80.12 11.2168 "Millet" 1 1 2011 "Producer" 110.28 "KG" "XOF" 1.3433656
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 79.48 11.1272 "Millet" 1 2 2011 "Producer" 155 "KG" "XOF" 6.857734
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.79 11.4506 "Millet" 1 3 2011 "Producer" 118.11 "KG" "XOF" 13.282522
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 82.08 11.490874 "Millet" 1 4 2011 "Producer" 150 "KG" "XOF" 3.2788765
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 82.73 11.5822 "Millet" 1 1 2012 "Producer" 113.42 "KG" "XOF" .695286
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 84.41 11.8174 "Millet" 1 2 2012 "Producer" 180 "KG" "XOF" 8.839492
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.51 11.9714 "Millet" 1 3 2012 "Producer" 152.22 "KG" "XOF" 12.117025
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.42 12.098664 "Millet" 1 4 2012 "Producer" 175 "KG" "XOF" 2.5099454
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.98 12.1772 "Millet" 1 1 2013 "Producer" 108.11 "KG" "XOF" 1.4844406
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 92.19 12.9066 "Millet" 1 2 2013 "Producer" 131.22 "KG" "XOF" 11.528778
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 93.71 13.1194 "Millet" 1 3 2013 "Producer" 131.22 "KG" "XOF" 13.377524
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 96.23 13.47243 "Millet" 1 4 2013 "Producer" 180 "KG" "XOF" 3.35759
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 97.13 13.5982 "Millet" 1 1 2014 "Producer" 188.11 "KG" "XOF" 1.2139716
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 91.34 12.7876 "Millet" 1 2 2014 "Producer" 111.11 "KG" "XOF" 10.257064
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 83.23 11.6522 "Millet" 1 3 2014 "Producer" 132.22 "KG" "XOF" 18.031187
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 84.19 11.786667 "Millet" 1 4 2014 "Producer" 201.11 "KG" "XOF" 3.15808
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.18 11.9252 "Millet" 1 1 2015 "Producer" 131.22 "KG" "XOF" 2.468094
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.99 12.0386 "Millet" 1 2 2015 "Producer" 171.22 "KG" "XOF" 6.944751
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 87.01 12.1814 "Millet" 1 3 2015 "Producer" 131.11 "KG" "XOF" 15.586768
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 88.11 12.334717 "Millet" 1 4 2015 "Producer" 151.11 "KG" "XOF" 3.730871
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.1 12.054 "Millet" 1 1 2016 "Producer" 132.22 "KG" "XOF" 3.4156
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.34 11.3876 "Millet" 1 2 2016 "Producer" 171.22 "KG" "XOF" 8.3423
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 83.45 11.683 "Millet" 1 3 2016 "Producer" 208.08 "KG" "XOF" 18.4363
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.79 11.450648 "Millet" 1 4 2016 "Producer" 205 "KG" "XOF" 3.9235
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .37 .0518 "Millet" 1 1 2000 "Retail" 271.22 "KG" "XOF" .8320871
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .59 .0826 "Millet" 1 2 2000 "Retail" 285 "KG" "XOF" 9.266488
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .69 .0966 "Millet" 1 3 2000 "Retail" 248.11 "KG" "XOF" 17.017979
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .81 .1131182 "Millet" 1 4 2000 "Retail" 232.22 "KG" "XOF" 2.7170014
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 .97 .1358 "Millet" 1 1 2001 "Retail" 252.22 "KG" "XOF" .4435913
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.21 .1694 "Millet" 1 2 2001 "Retail" 251.22 "KG" "XOF" 8.8764305
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.49 .2086 "Millet" 1 3 2001 "Retail" 285 "KG" "XOF" 15.918653
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.77 .24728926 "Millet" 1 4 2001 "Retail" 285 "KG" "XOF" 1.1938106
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.03 .2842 "Millet" 1 1 2002 "Retail" 285 "KG" "XOF" 1.2990117
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.4 .336 "Millet" 1 2 2002 "Retail" 285 "KG" "XOF" 9.72025
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.51 .3514 "Millet" 1 3 2002 "Retail" 214 "KG" "XOF" 17.741055
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3 .4198238 "Millet" 1 4 2002 "Retail" 210 "KG" "XOF" 3.802082
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.03 .4242 "Millet" 1 1 2003 "Retail" 208.11 "KG" "XOF" 1.2800548
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.06 .4284 "Millet" 1 2 2003 "Retail" 200 "KG" "XOF" 12.08556
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.11 .4354 "Millet" 1 3 2003 "Retail" 222.22 "KG" "XOF" 21.25432
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.14 .4396551 "Millet" 1 4 2003 "Retail" 215 "KG" "XOF" 3.5291195
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.99 .5586 "Millet" 1 1 2004 "Retail" 221.22 "KG" "XOF" .776113
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 4.19 .5866 "Millet" 1 2 2004 "Retail" 251.22 "KG" "XOF" 11.494287
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.01 .7014 "Millet" 1 3 2004 "Retail" 228.11 "KG" "XOF" 17.888
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.93 .8297426 "Millet" 1 4 2004 "Retail" 218.11 "KG" "XOF" 2.598993
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.28 .8792 "Millet" 1 1 2005 "Retail" 205 "KG" "XOF" 1.9511178
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.71 .9394 "Millet" 1 2 2005 "Retail" 185 "KG" "XOF" 9.160417
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.02 .9828 "Millet" 1 3 2005 "Retail" 210 "KG" "XOF" 16.668852
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.47 1.0457909 "Millet" 1 4 2005 "Retail" 178.11 "KG" "XOF" 2.5000436
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 8.01 1.1214 "Millet" 1 1 2006 "Retail" 205 "KG" "XOF" 1.093254
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 9.98 1.3972 "Millet" 1 2 2006 "Retail" 277.11 "KG" "XOF" 8.828572
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 11.09 1.5526 "Millet" 1 3 2006 "Retail" 215 "KG" "XOF" 17.47267
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 12.85 1.7987545 "Millet" 1 4 2006 "Retail" 210 "KG" "XOF" 3.420969
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 14.91 2.0874 "Millet" 1 1 2007 "Retail" 215 "KG" "XOF" .8597299
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 17.05 2.387 "Millet" 1 2 2007 "Retail" 170 "KG" "XOF" 12.250764
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 20.79 2.9106 "Millet" 1 3 2007 "Retail" 201.11 "KG" "XOF" 19.497534
      "Benin" 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 24.27 3.397466 "Millet" 1 4 2007 "Retail" 170 "KG" "XOF" 2.830138
      end
      [/CODE]

      Apologies as I was not able to format the above

      Comment


      • #4
        Well, thank you for the effort. From the perspective of formatting the -dataex- output, you had it almost right. You just needed to include the [ C O D E ] at the top of the output in your copy/paste and it would have been perfectly formatted.

        The problem now is that you have changed the variable names so that nobody, except perhaps somebody who is intensely familiar with your particular data source, can figure out what variables are what. OK, var1 is clearly country, and var11 is clearly a commodity. var13 and var14 are clearly quarter and year. But the rest are mysterious. Also, a number of them don't vary at all: var2, var4, var12, and var1, var3, var7, var11, and var17. The reason I asked for a data example was that I hoped to see how the market_id and commodity_id (and perhaps the country) are related through either nesting or crossing. But since I can't even tell which variables these are (except country), no progress is possible at this point.

        Comment


        • #5
          Country Country ID Market Market ID Latitude Longitude Closest Market Euclidean (KM) Subscription Proportion Scaled subscription Commodity Commodity ID Quarter Year Price Type Price Unit Currency Rainfall
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.37 0.14 0.0518 "Millet" 1 1 2000 "Producer" 110 "KG" "XOF" 0.832087
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.59 0.14 0.0826 "Millet" 1 2 2000 "Producer" 130.00 "KG" "XOF" 9.266488
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.69 0.14 0.0966 "Millet" 1 3 2000 "Producer" 115.00 "KG" "XOF" 17.01798
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.81 0.14 0.113118 "Millet" 1 4 2000 "Producer" 110.00 "KG" "XOF" 2.717002
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.97 0.14 0.1358 "Millet" 1 1 2001 "Producer" 131.81 "KG" "XOF" 0.443591
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.21 0.14 0.1694 "Millet" 1 2 2001 "Producer" 135.00 "KG" "XOF" 8.87643
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.49 0.14 0.2086 "Millet" 1 3 2001 "Producer" 170.00 "KG" "XOF" 15.91865
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.77 0.14 0.247289 "Millet" 1 4 2001 "Producer" 172.22 "KG" "XOF" 1.193811
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.03 0.14 0.2842 "Millet" 1 1 2002 "Producer" 175.00 "KG" "XOF" 1.299012
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.40 0.14 0.336 "Millet" 1 2 2002 "Producer" 175.00 "KG" "XOF" 9.720251
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.51 0.14 0.3514 "Millet" 1 3 2002 "Producer" 110.00 "KG" "XOF" 17.74105
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.00 0.14 0.419824 "Millet" 1 4 2002 "Producer" 115.00 "KG" "XOF" 3.802082
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.03 0.14 0.4242 "Millet" 1 1 2003 "Producer" 115.00 "KG" "XOF" 1.280055
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.06 0.14 0.4284 "Millet" 1 2 2003 "Producer" 111.11 "KG" "XOF" 12.08556
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.11 0.14 0.4354 "Millet" 1 3 2003 "Producer" 135.00 "KG" "XOF" 21.25432
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.14 0.14 0.439655 "Millet" 1 4 2003 "Producer" 131.22 "KG" "XOF" 3.52912
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.99 0.14 0.5586 "Millet" 1 1 2004 "Producer" 142.19 "KG" "XOF" 0.776113
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 4.19 0.14 0.5866 "Millet" 1 2 2004 "Producer" 175.00 "KG" "XOF" 11.49429
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.01 0.14 0.7014 "Millet" 1 3 2004 "Producer" 152.22 "KG" "XOF" 17.888
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.93 0.14 0.829743 "Millet" 1 4 2004 "Producer" 142.22 "KG" "XOF" 2.598993
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.28 0.14 0.8792 "Millet" 1 1 2005 "Producer" 135.00 "KG" "XOF" 1.951118
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.71 0.14 0.9394 "Millet" 1 2 2005 "Producer" 115.00 "KG" "XOF" 9.160417
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.02 0.14 0.9828 "Millet" 1 3 2005 "Producer" 141.11 "KG" "XOF" 16.66885
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.47 0.14 1.045791 "Millet" 1 4 2005 "Producer" 111.11 "KG" "XOF" 2.500044
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 8.01 0.14 1.1214 "Millet" 1 1 2006 "Producer" 138.11 "KG" "XOF" 1.093254
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 9.98 0.14 1.3972 "Millet" 1 2 2006 "Producer" 211.22 "KG" "XOF" 8.828572
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 11.09 0.14 1.5526 "Millet" 1 3 2006 "Producer" 152.22 "KG" "XOF" 17.47267
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 12.85 0.14 1.798754 "Millet" 1 4 2006 "Producer" 150.00 "KG" "XOF" 3.420969
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 14.91 0.14 2.0874 "Millet" 1 1 2007 "Producer" 155.00 "KG" "XOF" 0.85973
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 17.05 0.14 2.387 "Millet" 1 2 2007 "Producer" 111.11 "KG" "XOF" 12.25076
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 20.79 0.14 2.9106 "Millet" 1 3 2007 "Producer" 145.00 "KG" "XOF" 19.49753
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 24.27 0.14 3.397466 "Millet" 1 4 2007 "Producer" 115.89 "KG" "XOF" 2.830138
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 27.89 0.14 3.9046 "Millet" 1 1 2008 "Producer" 111.11 "KG" "XOF" 1.162299
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 31.89 0.14 4.4646 "Millet" 1 2 2008 "Producer" 141.11 "KG" "XOF" 11.9775
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 36.98 0.14 5.1772 "Millet" 1 3 2008 "Producer" 175.00 "KG" "XOF" 22.16582
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 41.69 0.14 5.835991 "Millet" 1 4 2008 "Producer" 132.22 "KG" "XOF" 3.137085
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 45.95 0.14 6.433 "Millet" 1 1 2009 "Producer" 175.00 "KG" "XOF" 1.074003
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 47.23 0.14 6.6122 "Millet" 1 2 2009 "Producer" 141.11 "KG" "XOF" 10.02601
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 52.38 0.14 7.3332 "Millet" 1 3 2009 "Producer" 138.11 "KG" "XOF" 18.24135
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 56.27 0.14 7.878055 "Millet" 1 4 2009 "Producer" 188.11 "KG" "XOF" 4.314962
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 61.02 0.14 8.5428 "Millet" 1 1 2010 "Producer" 111.11 "KG" "XOF" 1.273607
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 67.01 0.14 9.3814 "Millet" 1 2 2010 "Producer" 142.22 "KG" "XOF" 8.645645
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 68.89 0.14 9.6446 "Millet" 1 3 2010 "Producer" 111.22 "KG" "XOF" 17.18204
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 76.91 0.14 10.76704 "Millet" 1 4 2010 "Producer" 175.00 "KG" "XOF" 3.729227
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 80.12 0.14 11.2168 "Millet" 1 1 2011 "Producer" 110.28 "KG" "XOF" 1.343366
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 79.48 0.14 11.1272 "Millet" 1 2 2011 "Producer" 155.00 "KG" "XOF" 6.857734
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.79 0.14 11.4506 "Millet" 1 3 2011 "Producer" 118.11 "KG" "XOF" 13.28252
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 82.08 0.14 11.49087 "Millet" 1 4 2011 "Producer" 150.00 "KG" "XOF" 3.278877
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 82.73 0.14 11.5822 "Millet" 1 1 2012 "Producer" 113.42 "KG" "XOF" 0.695286
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 84.41 0.14 11.8174 "Millet" 1 2 2012 "Producer" 180.00 "KG" "XOF" 8.839492
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.51 0.14 11.9714 "Millet" 1 3 2012 "Producer" 152.22 "KG" "XOF" 12.11703
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.42 0.14 12.09866 "Millet" 1 4 2012 "Producer" 175.00 "KG" "XOF" 2.509945
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.98 0.14 12.1772 "Millet" 1 1 2013 "Producer" 108.11 "KG" "XOF" 1.484441
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 92.19 0.14 12.9066 "Millet" 1 2 2013 "Producer" 131.22 "KG" "XOF" 11.52878
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 93.71 0.14 13.1194 "Millet" 1 3 2013 "Producer" 131.22 "KG" "XOF" 13.37752
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 96.23 0.14 13.47243 "Millet" 1 4 2013 "Producer" 180.00 "KG" "XOF" 3.35759
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 97.13 0.14 13.5982 "Millet" 1 1 2014 "Producer" 188.11 "KG" "XOF" 1.213972
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 91.34 0.14 12.7876 "Millet" 1 2 2014 "Producer" 111.11 "KG" "XOF" 10.25706
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 83.23 0.14 11.6522 "Millet" 1 3 2014 "Producer" 132.22 "KG" "XOF" 18.03119
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 84.19 0.14 11.78667 "Millet" 1 4 2014 "Producer" 201.11 "KG" "XOF" 3.15808
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.18 0.14 11.9252 "Millet" 1 1 2015 "Producer" 131.22 "KG" "XOF" 2.468094
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 85.99 0.14 12.0386 "Millet" 1 2 2015 "Producer" 171.22 "KG" "XOF" 6.944751
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 87.01 0.14 12.1814 "Millet" 1 3 2015 "Producer" 131.11 "KG" "XOF" 15.58677
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 88.11 0.14 12.33472 "Millet" 1 4 2015 "Producer" 151.11 "KG" "XOF" 3.730871
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 86.10 0.14 12.054 "Millet" 1 1 2016 "Producer" 132.22 "KG" "XOF" 3.4156
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.34 0.14 11.3876 "Millet" 1 2 2016 "Producer" 171.22 "KG" "XOF" 8.3423
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 83.45 0.14 11.683 "Millet" 1 3 2016 "Producer" 208.08 "KG" "XOF" 18.4363
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 81.79 0.14 11.45065 "Millet" 1 4 2016 "Producer" 205.00 "KG" "XOF" 3.9235
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.37 0.14 0.0518 "Millet" 1 1 2000 "Retail" 271.22 "KG" "XOF" 0.832087
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.59 0.14 0.0826 "Millet" 1 2 2000 "Retail" 285.00 "KG" "XOF" 9.266488
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.69 0.14 0.0966 "Millet" 1 3 2000 "Retail" 248.11 "KG" "XOF" 17.01798
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.81 0.14 0.113118 "Millet" 1 4 2000 "Retail" 232.22 "KG" "XOF" 2.717002
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 0.97 0.14 0.1358 "Millet" 1 1 2001 "Retail" 252.22 "KG" "XOF" 0.443591
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.21 0.14 0.1694 "Millet" 1 2 2001 "Retail" 251.22 "KG" "XOF" 8.87643
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.49 0.14 0.2086 "Millet" 1 3 2001 "Retail" 285.00 "KG" "XOF" 15.91865
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 1.77 0.14 0.247289 "Millet" 1 4 2001 "Retail" 285.00 "KG" "XOF" 1.193811
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.03 0.14 0.2842 "Millet" 1 1 2002 "Retail" 285.00 "KG" "XOF" 1.299012
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.40 0.14 0.336 "Millet" 1 2 2002 "Retail" 285.00 "KG" "XOF" 9.720251
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 2.51 0.14 0.3514 "Millet" 1 3 2002 "Retail" 214.00 "KG" "XOF" 17.74105
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.00 0.14 0.419824 "Millet" 1 4 2002 "Retail" 210.00 "KG" "XOF" 3.802082
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.03 0.14 0.4242 "Millet" 1 1 2003 "Retail" 208.11 "KG" "XOF" 1.280055
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.06 0.14 0.4284 "Millet" 1 2 2003 "Retail" 200.00 "KG" "XOF" 12.08556
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.11 0.14 0.4354 "Millet" 1 3 2003 "Retail" 222.22 "KG" "XOF" 21.25432
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.14 0.14 0.439655 "Millet" 1 4 2003 "Retail" 215.00 "KG" "XOF" 3.52912
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 3.99 0.14 0.5586 "Millet" 1 1 2004 "Retail" 221.22 "KG" "XOF" 0.776113
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 4.19 0.14 0.5866 "Millet" 1 2 2004 "Retail" 251.22 "KG" "XOF" 11.49429
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.01 0.14 0.7014 "Millet" 1 3 2004 "Retail" 228.11 "KG" "XOF" 17.888
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 5.93 0.14 0.829743 "Millet" 1 4 2004 "Retail" 218.11 "KG" "XOF" 2.598993
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.28 0.14 0.8792 "Millet" 1 1 2005 "Retail" 205.00 "KG" "XOF" 1.951118
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 6.71 0.14 0.9394 "Millet" 1 2 2005 "Retail" 185.00 "KG" "XOF" 9.160417
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.02 0.14 0.9828 "Millet" 1 3 2005 "Retail" 210.00 "KG" "XOF" 16.66885
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 7.47 0.14 1.045791 "Millet" 1 4 2005 "Retail" 178.11 "KG" "XOF" 2.500044
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 8.01 0.14 1.1214 "Millet" 1 1 2006 "Retail" 205.00 "KG" "XOF" 1.093254
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 9.98 0.14 1.3972 "Millet" 1 2 2006 "Retail" 277.11 "KG" "XOF" 8.828572
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 11.09 0.14 1.5526 "Millet" 1 3 2006 "Retail" 215.00 "KG" "XOF" 17.47267
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 12.85 0.14 1.798754 "Millet" 1 4 2006 "Retail" 210.00 "KG" "XOF" 3.420969
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 14.91 0.14 2.0874 "Millet" 1 1 2007 "Retail" 215.00 "KG" "XOF" 0.85973
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 17.05 0.14 2.387 "Millet" 1 2 2007 "Retail" 170.00 "KG" "XOF" 12.25076
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 20.79 0.14 2.9106 "Millet" 1 3 2007 "Retail" 201.11 "KG" "XOF" 19.49753
          Benin 1 "Dantokpa" 1 6.37194 2.43476 "Come" 59.68 24.27 0.14 3.397466 "Millet" 1 4 2007 "Retail" 170.00 "KG" "XOF" 2.830138
          Hi,

          Unfortunately the code would not format properly. However, I created a table and inputted the values. I was wondering if this made the data any clearer

          Comment


          • #6
            Well, the problem is that the example you show contains only one countryid, one marketid, and one commodityid. Since what we need to figure out is what combinations of these variables occur in your data, this isn't informative. You need to show an example of your data set that incorporates the various combinations of values of these variables that can occur. Let's make it simpler. Run the following command

            Code:
            table countryid marketid commodityid, by(pricetype)
            and post the output you get from Stata.

            Comment


            • #7
              Thank for you for all the help.

              This is the output (tabular form)
              Price type and Country ID Commodity ID and Market ID Commodity ID and Market ID Commodity ID and Market ID Commodity ID and Market ID
              Price type and Country ID 1 1 2 2
              Price type and Country ID 1 2 1 2
              Producer 1 68 68 68 68
              Retailer 1 68 68 68 68
              This is the copy and paste:
              . table countryid marketid commodityid, by(pricetype)

              ------------------------------------
              Price | Commodity ID and Market
              Type and | ID
              Country | ---- 1 --- ---- 2 ---
              ID | 1 2 1 2
              ----------+-------------------------
              Producer |
              1 | 68 68 68 68
              ----------+-------------------------
              Retail |
              1 | 68 68 68 68
              ------------------------------------

              Comment


              • #8
                From this output, as best I can read it (neither one that you showed is really readable. The copy/paste would have been readable if you had put it between code delimiters. Please read FAQ #12 and learn how to do that.) There are exactly two price types and two commodity IDs and two market types, and all 8 combinations of these occur 68 times (which I'm going to assume are once for each month-year combination.)

                That said, I don't understand why you have a country variable when there is only one country.

                So to return to your original concern about how to xtset this data, it would be:

                Code:
                gen qdate = quarterly(string(quarter)+"q"+string(year), "QY")
                format qdate %tq
                
                egen panel_id = group(commodity_id market_id price_type)
                xtset panel_id qdate
                That said, this is not typical panel data because there are multiple crossed effects here. Without knowing your research goals, I can't know if this is a problem, but treating this as panel data will make it impossible to identify effects of commodity, market, or price type separately. You may be better off with a different way of thinking about and using this data, depending on what your goals are.

                Comment


                • #9
                  As Clyde says, the key questions are What defines a panel here? Is that helpful?

                  A footnote to all that is that

                  Code:
                    
                   gen qdate = yq(year, quarter)
                  is another way to get a quarterly date.
                  Last edited by Nick Cox; 11 Mar 2018, 12:59.

                  Comment


                  • #10
                    Thank you both for the help!

                    Comment


                    • #11
                      Dear Clyde

                      I am trying to estimate a regression (using first differences estimator). My aim is to see the impact of the variable price (dependant) on euclideankm (distance) scaledsubscription (mobile phone subscription per 100 in the region) and rainfall (average mm for region for the quarter) . However when I collapse commodityid, marketid and pricetype into panel_id all the independant variables become statistically insignficant

                      Comment


                      • #12
                        It isn't possible to comment on this without seeing the code you used (both the -collapse- and the subsequent analysis) and the actual Stata output.

                        Comment


                        • #13
                          Code:
                           egen panel_price = group(commodityid marketid pricetype)
                          
                          gen qdate = quarterly(string(quarter)+"q"+string(year), "QY")
                          
                          format qdate %tq
                          
                          xtset panel_price qdate
                                 panel variable:  panel_price (strongly balanced)
                                  time variable:  qdate, 2000q1 to 2016q4
                                          delta:  1 quarter
                          
                          . global xlist euclideankm scaledsubscription rainfall
                          
                          . global ylist price
                          
                          
                           xtreg price euclideankm scaledsubscription rainfall, fe
                          note: euclideankm omitted because of collinearity
                          
                          Fixed-effects (within) regression               Number of obs     =        680
                          Group variable: panel_price                     Number of groups  =         10
                          
                          R-sq:                                           Obs per group:
                               within  = 0.0059                                         min =         68
                               between = 0.0717                                         avg =       68.0
                               overall = 0.0004                                         max =         68
                          
                                                                          F(2,668)          =       1.97
                          corr(u_i, Xb)  = -0.0857                        Prob > F          =     0.1404
                          
                          ------------------------------------------------------------------------------
                                 price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          -------------+----------------------------------------------------------------
                           euclideankm |          0  (omitted)
                          scaledsubs~n |  -.9440255    .481446    -1.96   0.050    -1.889355    .0013041
                              rainfall |  -.1394603   .3085255    -0.45   0.651    -.7452568    .4663362
                                 _cons |   282.9662   5.836717    48.48   0.000     271.5057    294.4267
                          -------------+----------------------------------------------------------------
                               sigma_u |  110.70201
                               sigma_e |  78.556019
                                   rho |  .66508988   (fraction of variance due to u_i)
                          ------------------------------------------------------------------------------
                          F test that all u_i=0: F(9, 668) = 133.02                    Prob > F = 0.0000
                          
                          . reg D.($ylist $xlist), noconstant
                          note: D.euclideankm omitted because of collinearity
                          
                                Source |       SS           df       MS      Number of obs   =       670
                          -------------+----------------------------------   F(2, 668)       =      0.31
                                 Model |  5059.38465         2  2529.69232   Prob > F        =    0.7308
                              Residual |  5385184.62       668  8061.65362   R-squared       =    0.0009
                          -------------+----------------------------------   Adj R-squared   =   -0.0021
                                 Total |     5390244       670   8045.1403   Root MSE        =    89.787
                          
                          ------------------------------------------------------------------------------
                               D.price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          -------------+----------------------------------------------------------------
                           euclideankm |
                                   D1. |          0  (omitted)
                                       |
                          scaledsubs~n |
                                   D1. |   4.818568   7.470972     0.64   0.519    -9.850847    19.48798
                                       |
                              rainfall |
                                   D1. |  -.0969628   .2492065    -0.39   0.697    -.5862851    .3923595
                          ------------------------------------------------------------------------------

                          Comment


                          • #14
                            OK, everything looks like it has been done correctly.

                            It is often said that first-differences regression and fixed-effects regression are equivalent. But that is only true when each panel contains exactly two observations. When there are more than 2 observations, the results can differ--as your example clearly shows. There is nothing wrong here, and there is nothing to explain. Your expectation that the results should be similar is incorrect. They are different models, of different things, and they give different results.

                            By the way, you should not be focusing on whether results are "significant" or not. I could write a very long essay about this, but in this instance I'll just point out one glaring issue: your "significant" result in the first model is just exactly so (at the conventional 0.50 level), so there is little hope that it won't oscillate back and forth over the .05 line with even minor changes to the data sample of the model, let alone major model changes. And I'll make one other point that it is insufficiently taught but easy to remember: the difference between statistically significant and not statistically significant is, itself, not statistically significant.

                            Comment


                            • #15
                              Dear Clyde,

                              Apologies as I believe I have made a mistake. My regression is suppose to take the following:

                              Pricemarket1,t commodity i - Pricemarket2,,t commodity i = euclideankmmarket1,t commodity i - euclideankmmarket2,,t commodity i +scaledsubscriptionmarket1,t commodity i - scaledsubscriptionmarket2,,t commodity i +rainfallmarket1,t commodity i - rainfallmarket2,,t commodity i

                              I am trying to estimate a regression for price dispersion over time (difference between price of commodity i at time t in markets 1 and 2 over time)

                              Comment

                              Working...
                              X