Announcement

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

  • Correlation Data where there is quarterly trends

    Hi,

    I would like to find if there is a correlation between Compost and Recycling rates in each local authority in my data, simply whether local authorities that recycle more also compost more.

    However there are seasonal trends that may mask these effects, I have posted a graph of the time average of my data. I am using panel data for twenty quarters.

    Is there a way to calculate -pwcorr- and also control for quarterly effects?

    As you can see when compost rates are at their highest recycling rates are at their lowest?

    Thank You
    Click image for larger version

Name:	Graph Rates over time.png
Views:	1
Size:	85.0 KB
ID:	1486331


  • #2
    You do not say it in so many words, but I gather you have panel data here. So -pwcorr- is not applicable. I think your best bet is to regress recycling rates on composting rates and include a seasonal effect. You don't provide example data, so the following is just a general outline of how you might code this:

    Code:
    gen byte quarter = quarter(dofq(quarterly_date)) // RESULT IS 1, 2, 3, or 4
    xtset community quarterly_date
    xtreg recycling_rate composting_rate i.quarter, fe
    Added: In the future, when asking for coding help, please include an example of your data. Code often depends on the details of the data set that are not conveyed by description. An example that actually replicates your data situation can be key to getting the code right. Please use the -dataex- command to do share an example of your data. If you are running version 15.1 or a fully updated version 14.2, -dataex- 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-.
    Last edited by Clyde Schechter; 03 Mar 2019, 11:12.

    Comment


    • #3
      Hi Clyde, Sorry I didn't include the data. I have already got the regression results

      xtreg recycling loginc logpopden loghhsize unitarydummy 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)

      and

      xtreg compost loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md31 md32 md33 md34 md35 md36 md37 wasteavg comavg quarter2 quarter3 quarter4, fe vce(cluster acode)

      Now I want to test if recycling and compost rates are correlated, whether local authorities that recycle more also compost more- is there a test for this?

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

      Comment


      • #4
        I would do it just as I showed in #2, except I would expand the -xtreg- command to include the other covariates. But I would also do the analysis that just adjusts out the seasonality and omits the other variables.

        Code:
        encode, gen(n_code)
        xtset n_code qdate
        
        xtreg recycling i.quarter compost loginc logpopden loghhsize unitarydummy md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg, fe vce(cluster n_code)
        
        xtreg recycling i.quarter compost, fe vce(cluster n_code)
        Note: The code you show and the data example you showed are not compatible with each other. Your data set has no variable for compost, nor the variable acode that you used for clustering. It is more helpful to post data that is suitable for the code you are asking for help with in this regard.


        Comment


        • #5
          Hi Clyde,

          Is this still valid even though I am running two separate regressions for recycling and compost with different variables? I want to test if recycling and compost are correlated.
          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)

          xtreg compost loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md31 md32 md33 md34 md35 md36 md37 wasteavg comavg quarter2 quarter3 quarter4, fe vce(cluster acode)


          I'm a little confused how this below code/result shows us correlation between compost and recycling?

          xtreg recycling compost quarter2 quarter3 quarter4, fe vce(cluster acode)

          Fixed-effects (within) regression Number of obs = 6,297
          Group variable: acode Number of groups = 318

          R-sq: Obs per group:
          within = 0.3463 min = 7
          between = 0.0072 avg = 19.8
          overall = 0.0675 max = 20

          F(4,317) = 683.37
          corr(u_i, Xb) = -0.2097 Prob > F = 0.0000

          (Std. Err. adjusted for 318 clusters in acode)
          ------------------------------------------------------------------------------
          | Robust
          recycling | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          compost | -.1606686 .0319099 -5.04 0.000 -.2234507 -.0978866
          quarter2 | -2.588885 .3672908 -7.05 0.000 -3.311521 -1.86625
          quarter3 | -2.370648 .3448915 -6.87 0.000 -3.049213 -1.692082
          quarter4 | -1.713804 .1587202 -10.80 0.000 -2.026082 -1.401526
          _cons | 28.67678 .3643364 78.71 0.000 27.95996 29.39361
          -------------+----------------------------------------------------------------
          sigma_u | 4.3579346
          sigma_e | 2.5973928
          rho | .73788024 (fraction of variance due to u_i)
          -------------------

          Comment


          • #6
            Is this still valid even though I am running two separate regressions for recycling and compost with different variables? I want to test if recycling and compost are correlated.
            The two models you show there are informative about what other factors are associated with (predictive of) recycling and composting separately. They tell you nothing about whether correlation and recycling are correlated with each other, except to the extent that some correlation might results from sharing common predictors.

            I'm a little confused how this below code/result shows us correlation between compost and recycling?
            So the coefficient of composting came out -.161 (to 3 decimal places), with a 95% CI of -.223 to -.098. So that is reasonably strong evidence that, after adjusting for seasonal (quarterly) trends, households (or whatever the unit of analysis in your data is) are less likely to recycle at those times when they are composting. The coefficient is not a correlation coefficient, because it is dependent on the scales of the variables, and it also reflects only the within-household relationships between the two behaviors, but correlation coefficients aren't typically used in longitudinal data anyway and are difficult to interpret.

            Comment


            • #7
              Thank you Clyde. The hypothesis I would like to test is whether local authorities that recycle more also compost more, compared with other worse performing local authorities. Is this something that is possible in Stata or must I run a regression?

              Comment


              • #8
                The first thing you need to do is to get clear in your own mind what your specific research question is.

                The hypothesis I would like to test is whether local authorities that recycle more also compost more, compared with other worse performing local authorities.
                What is "worse performing?" Does that mean less recycling? Or is it something else. Also, this sounds like you are interested in an analysis that looks across authorities, but not over time within authorities. Is that right? Or are you interested in both aspects of this? (The association looking across authorities could be quite different from the association within authorities over time.)

                And what do you want to adjust for in this analysis. There will always be some factors in a given authority's jurisdiction that affect both composting and recycling. Those factors will necessarily create some degree of association between composting and recycling rates across authorities. But you may want to eliminate some of those influences from your analysis. In an earlier post in this thread, you suggested that you wanted to eliminate the influence of seasonality, for example. You need to decide whether there is anything else you want to eliminate the influence of.

                Is this something that is possible in Stata or must I run a regression?
                I don't understand this question. Wouldn't you do the regression in Stata? If not, why not?

                I think that some kind of regression analysis (in Stata) is the best way to approach this question, though the specifics of what to include in the model and what kind of regression remain to be clarified. In your initial post you appeared to be hopoing to do this with a correlation coefficient--but that is unlikely to be adequate for this kind of data.

                Comment


                • #9
                  Hi Clyde, the regressions I am running take the form below.

                  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)

                  xtreg compost loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md31 md32 md33 md34 md35 md36 md37 wasteavg comavg quarter2 quarter3 quarter4, fe vce(cluster acode)


                  What I would like to test for is whether ACROSS local authorities, those that recycle more also compost more, or whether if a local authority doesn't compost a lot they also don't recycle a lot - just a correlation and I don't think I need to do a regression. The independent variables are different for recycling and compost in the regressions above. The time period is not important. When I look at the data by inspection it looks like high performing recyclers are also high performing composters but I wanted to check within Stata and am unsure what to do. The problem is that there is seasonality in both recycling and compost rates. Would you recommend finding yearly averages for each local authority to verify this correlation?


                  Comment


                  • #10
                    Correlating yearly averages of composting and recycling would be a reasonable way to look at the association between correlation and recycling across associations, yes. And it would overcome the seasonality problem. It would not tell you the extent to which that association is driven by the other variables in your model, but if you don't care about that, then go ahead.

                    Comment

                    Working...
                    X