Announcement

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

  • Problems with Nesting in Panel Regression "panels are not nested within clusters"

    Hi,

    I am not sure how to overcome this error message I am receiving "panels are not nested within clusters". The code I am trying to run is:

    xtset acode qdate
    xtreg recycling loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(cluster acode)


    I am regressing the recycling rate on income, population density, household size, dummies for method, waste and dry average frequencies, quarter dummies.

    Below is a sample of my data.

    Furthermore I am having trouble even when I don't cluster and just have the below code, my quarter dummy variables are omitted for collinearity. Why is this happening?

    xtreg recycling loginc logpopden loghhsize gcses alevels unitary md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(robust)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str43 name str9 code int year byte quarter float(qdate quarter2 quarter3 quarter4 recycling loginc logpopden loghhsize)
    "Hartlepool Borough Council"           "E06000001" 2012 1 208 0 0 0  31.64322 9.576926 2.2529745 .8586616
    "Hartlepool Borough Council"           "E06000001" 2012 2 209 1 0 0  29.11372 9.576926  2.261659 .8586616
    "Hartlepool Borough Council"           "E06000001" 2012 3 210 0 1 0 24.318804 9.576926  2.261659 .8586616
    "Hartlepool Borough Council"           "E06000001" 2012 4 211 0 0 1  23.49204 9.576926  2.261659 .8586616
    "Hartlepool Borough Council"           "E06000001" 2013 1 212 0 0 0  29.75906  9.58011 2.2631164 .8628899
    "Hartlepool Borough Council"           "E06000001" 2013 2 213 1 0 0 25.608576  9.58011 2.2631164 .8628899
    "Hartlepool Borough Council"           "E06000001" 2013 3 214 0 1 0  19.14898  9.58011 2.2631164 .8628899
    "Hartlepool Borough Council"           "E06000001" 2013 4 215 0 0 1 26.363016  9.58011 2.2631164 .8628899
    "Hartlepool Borough Council"           "E06000001" 2014 1 216 0 0 0  29.21854 9.606159 2.2677865 .8671005
    "Hartlepool Borough Council"           "E06000001" 2014 2 217 1 0 0 22.891203 9.606159 2.2631164 .8671005
    "Hartlepool Borough Council"           "E06000001" 2014 3 218 0 1 0 22.664324 9.606159 2.2677865 .8671005
    "Hartlepool Borough Council"           "E06000001" 2014 4 219 0 0 1    19.374 9.606159 2.2677865 .8671005
    "Hartlepool Borough Council"           "E06000001" 2015 1 220 0 0 0  25.64599 9.642772 2.2669578 .8671005
    "Hartlepool Borough Council"           "E06000001" 2015 2 221 1 0 0 24.093536 9.642772 2.2669578 .8671005
    "Hartlepool Borough Council"           "E06000001" 2015 3 222 0 1 0 23.910435 9.642772 2.2669578 .8671005
    "Hartlepool Borough Council"           "E06000001" 2015 4 223 0 0 1  22.74303 9.642772 2.2669578 .8671005
    "Hartlepool Borough Council"           "E06000001" 2016 1 224 0 0 0 25.628105 9.620527  2.265921 .8712934
    "Hartlepool Borough Council"           "E06000001" 2016 2 225 1 0 0 21.490993 9.620527  2.265921 .8712934
    "Hartlepool Borough Council"           "E06000001" 2016 3 226 0 1 0  20.56008 9.620527  2.265921 .8712934
    "Hartlepool Borough Council"           "E06000001" 2016 4 227 0 0 1  19.26644 9.620527  2.265921 .8712934
    "Middlesbrough Borough Council"        "E06000002" 2012 1 208 0 0 0  15.01909 9.554639  3.262778 .8586616
    "Middlesbrough Borough Council"        "E06000002" 2012 2 209 1 0 0 14.171424 9.554639  3.234316 .8586616
    "Middlesbrough Borough Council"        "E06000002" 2012 3 210 0 1 0 13.453314 9.554639  3.234316 .8586616
    "Middlesbrough Borough Council"        "E06000002" 2012 4 211 0 0 1  13.24626 9.554639  3.234316 .8586616
    "Middlesbrough Borough Council"        "E06000002" 2013 1 212 0 0 0  14.57947 9.564863  3.236794 .8628899
    "Middlesbrough Borough Council"        "E06000002" 2013 2 213 1 0 0 14.828068 9.564863  3.236794 .8628899
    "Middlesbrough Borough Council"        "E06000002" 2013 3 214 0 1 0 14.709766 9.564863  3.236794 .8628899
    "Middlesbrough Borough Council"        "E06000002" 2013 4 215 0 0 1  20.44064 9.564863  3.236794 .8628899
    "Middlesbrough Borough Council"        "E06000002" 2014 1 216 0 0 0 34.159927 9.601301 3.2381685 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2014 2 217 1 0 0  24.25953 9.601301  3.236794 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2014 3 218 0 1 0  24.04574 9.601301 3.2381685 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2014 4 219 0 0 1    24.127 9.601301 3.2381685 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2015 1 220 0 0 0  27.94404 9.626811  3.239502 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2015 2 221 1 0 0 23.334343 9.626811  3.239502 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2015 3 222 0 1 0  19.43632 9.626811  3.239502 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2015 4 223 0 0 1  23.32905 9.626811  3.239502 .8671005
    "Middlesbrough Borough Council"        "E06000002" 2016 1 224 0 0 0  23.50695 9.613669   3.24228 .8712934
    "Middlesbrough Borough Council"        "E06000002" 2016 2 225 1 0 0 20.070557 9.613669   3.24228 .8712934
    "Middlesbrough Borough Council"        "E06000002" 2016 3 226 0 1 0 19.601873 9.613669   3.24228 .8712934
    "Middlesbrough Borough Council"        "E06000002" 2016 4 227 0 0 1  21.82984 9.613669   3.24228 .8712934
    "Redcar and Cleveland Borough Council" "E06000003" 2012 1 208 0 0 0  23.51096 9.537339  1.728642 .8586616
    "Redcar and Cleveland Borough Council" "E06000003" 2012 2 209 1 0 0  20.10306 9.537339  1.712536 .8586616
    "Redcar and Cleveland Borough Council" "E06000003" 2012 3 210 0 1 0  19.72007 9.537339  1.712536 .8586616
    "Redcar and Cleveland Borough Council" "E06000003" 2012 4 211 0 0 1 22.403687 9.537339  1.712536 .8586616
    "Redcar and Cleveland Borough Council" "E06000003" 2013 1 212 0 0 0 24.170063 9.545955  1.710911 .8628899
    "Redcar and Cleveland Borough Council" "E06000003" 2013 2 213 1 0 0  23.99578 9.545955  1.710911 .8628899
    "Redcar and Cleveland Borough Council" "E06000003" 2013 3 214 0 1 0 24.617693 9.545955  1.710911 .8628899
    "Redcar and Cleveland Borough Council" "E06000003" 2013 4 215 0 0 1  30.60893 9.545955  1.710911 .8628899
    "Redcar and Cleveland Borough Council" "E06000003" 2014 1 216 0 0 0  36.69286 9.575816 1.7105495 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2014 2 217 1 0 0  23.24818 9.575816  1.710911 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2014 3 218 0 1 0  28.21425 9.575816 1.7105495 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2014 4 219 0 0 1    33.378 9.575816 1.7105495 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2015 1 220 0 0 0 34.828026 9.600556  1.711272 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2015 2 221 1 0 0 26.965475 9.600556  1.711272 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2015 3 222 0 1 0 18.484371 9.600556  1.711272 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2015 4 223 0 0 1   22.8024 9.600556  1.711272 .8671005
    "Redcar and Cleveland Borough Council" "E06000003" 2016 1 224 0 0 0 25.000637 9.583902  1.713077 .8712934
    "Redcar and Cleveland Borough Council" "E06000003" 2016 2 225 1 0 0  23.34894 9.583902  1.713077 .8712934
    "Redcar and Cleveland Borough Council" "E06000003" 2016 3 226 0 1 0  20.75586 9.583902  1.713077 .8712934
    "Redcar and Cleveland Borough Council" "E06000003" 2016 4 227 0 0 1 25.922733 9.583902  1.713077 .8712934
    "Stockton-on-Tees Borough Council"     "E06000004" 2012 1 208 0 0 0  20.72435 9.607841   2.19778 .8586616
    "Stockton-on-Tees Borough Council"     "E06000004" 2012 2 209 1 0 0  19.85636 9.607841 2.1946657 .8586616
    "Stockton-on-Tees Borough Council"     "E06000004" 2012 3 210 0 1 0 17.278917 9.607841 2.1946657 .8586616
    "Stockton-on-Tees Borough Council"     "E06000004" 2012 4 211 0 0 1  20.15345 9.607841 2.1946657 .8586616
    "Stockton-on-Tees Borough Council"     "E06000004" 2013 1 212 0 0 0  22.03593 9.608176  2.197891 .8628899
    "Stockton-on-Tees Borough Council"     "E06000004" 2013 2 213 1 0 0 18.222332 9.608176  2.197891 .8628899
    "Stockton-on-Tees Borough Council"     "E06000004" 2013 3 214 0 1 0  17.56083 9.608176  2.197891 .8628899
    "Stockton-on-Tees Borough Council"     "E06000004" 2013 4 215 0 0 1  19.13032 9.608176  2.197891 .8628899
    "Stockton-on-Tees Borough Council"     "E06000004" 2014 1 216 0 0 0 21.184946 9.632138  2.201991 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2014 2 217 1 0 0 13.187984 9.632138  2.201991 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2014 3 218 0 1 0 16.005465 9.632138  2.201991 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2014 4 219 0 0 1    18.041 9.632138  2.201991 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2015 1 220 0 0 0 20.246767 9.662816  2.206735 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2015 2 221 1 0 0 16.660748 9.662816  2.206735 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2015 3 222 0 1 0  15.44666 9.662816  2.206735 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2015 4 223 0 0 1 18.055502 9.662816  2.206735 .8671005
    "Stockton-on-Tees Borough Council"     "E06000004" 2016 1 224 0 0 0 17.611841 9.641798 2.2102504 .8712934
    "Stockton-on-Tees Borough Council"     "E06000004" 2016 2 225 1 0 0 14.851618 9.641798 2.2102504 .8712934
    "Stockton-on-Tees Borough Council"     "E06000004" 2016 3 226 0 1 0 14.507548 9.641798 2.2102504 .8712934
    "Stockton-on-Tees Borough Council"     "E06000004" 2016 4 227 0 0 1  17.83563 9.641798 2.2102504 .8712934
    "Darlington Borough Council"           "E06000005" 2012 1 208 0 0 0  42.36351 9.570878 1.6325684 .8586616
    "Darlington Borough Council"           "E06000005" 2012 2 209 1 0 0 32.836056 9.570878  1.678964 .8586616
    "Darlington Borough Council"           "E06000005" 2012 3 210 0 1 0  31.34309 9.570878  1.678964 .8586616
    "Darlington Borough Council"           "E06000005" 2012 4 211 0 0 1   32.1052 9.570878  1.678964 .8586616
    "Darlington Borough Council"           "E06000005" 2013 1 212 0 0 0 28.556936 9.597573 1.6757873 .8628899
    "Darlington Borough Council"           "E06000005" 2013 2 213 1 0 0 30.584833 9.597573 1.6757873 .8628899
    "Darlington Borough Council"           "E06000005" 2013 3 214 0 1 0  28.63693 9.597573 1.6757873 .8628899
    "Darlington Borough Council"           "E06000005" 2013 4 215 0 0 1  21.55379 9.597573 1.6757873 .8628899
    "Darlington Borough Council"           "E06000005" 2014 1 216 0 0 0  20.11268 9.606159 1.6770965 .8671005
    "Darlington Borough Council"           "E06000005" 2014 2 217 1 0 0 26.908495 9.606159 1.6757873 .8671005
    "Darlington Borough Council"           "E06000005" 2014 3 218 0 1 0  25.60923 9.606159 1.6770965 .8671005
    "Darlington Borough Council"           "E06000005" 2014 4 219 0 0 1  30.62015 9.606159 1.6770965 .8671005
    "Darlington Borough Council"           "E06000005" 2015 1 220 0 0 0 31.480186  9.65098 1.6769096 .8671005
    "Darlington Borough Council"           "E06000005" 2015 2 221 1 0 0  29.34417  9.65098 1.6769096 .8671005
    "Darlington Borough Council"           "E06000005" 2015 3 222 0 1 0   29.5002  9.65098 1.6769096 .8671005
    "Darlington Borough Council"           "E06000005" 2015 4 223 0 0 1 25.388384  9.65098 1.6769096 .8671005
    "Darlington Borough Council"           "E06000005" 2016 1 224 0 0 0  29.34344 9.647757 1.6770965 .8712934
    "Darlington Borough Council"           "E06000005" 2016 2 225 1 0 0  27.49854 9.647757 1.6770965 .8712934
    "Darlington Borough Council"           "E06000005" 2016 3 226 0 1 0  28.14532 9.647757 1.6770965 .8712934
    "Darlington Borough Council"           "E06000005" 2016 4 227 0 0 1  28.00815 9.647757 1.6770965 .8712934
    end
    format %tq qdate

  • #2
    Darcy:
    in order to save everybody's time, it is a good habit to check the consistency of the code to be tested with the data excerpt shared via -dataex-.
    This just to prevent something like:
    Code:
    .  xtset code adate
    variable adate not found
    r(111);
    Things do not change when the interested lister try to fix the matter her/himself:
    Code:
    . encode code, g(acode)
    
    . xtset acode qdate
           panel variable:  acode (strongly balanced)
            time variable:  qdate, 2012q1 to 2016q4
                    delta:  1 quarter
    
    . xtreg recycling loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25
    > md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(cluster acode)
    variable md11 not found
    r(111);
    As per FAQ (and a legal dose of poster's selfish utilitarism!), please help others helping yourself. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X