Announcement

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

  • qreg2 'invalid cluster' error

    Hi,

    I have a question about the qreg2 command and would appreciate your feedback.

    I am using data from a large survey with a detailed drinking diary. Individuals (n = 102, 772) provide information about the number of drinking occasions (over 400,000 recorded occasions) they have in a week and what they drink at each occasion. The data is cross sectional.

    I am interested in examining trends in the total units consumed in the diary week (across all occasions at an individual level) across the consumption distribution between 2009 and 2018, e.g. do we see declines in alcohol consumption across all drinkers. I also included age and gender interaction terms in order to examine whether sex and age differences are seen across the distribution or only among lighter/heavier drinkers. There is no problem here I think, as I have used the sqreg command.

    However, I am also interested in looking at trends at an occasion based level e.g. is the prevalence of lighter drinking occasions increasing and heavier drinking occasions decreasing? However, the occasions are obviously clustered within the individual, as an individual participant can contribute multiple drinking occasions across the diary week. As such, I need to account for this in the analysis. I have done some reading around the qreg2 command and this seems to be a good solution however I cannot get my code to run.

    I initially tried the code below but had an error message stating that factor variables and interactions are not allowed
    qreg2 occ2hrunits drinkyear drinkyear.c#d_sex.i drinkyear.c#d_age3.c, quantile(5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95), cluster(newid)

    After looking on these boards I found that the xi: prefix allowed you to specify factor variables so I dropped the interaction terms and settled for controlling for the demographic variables in the analysis and tried the code below;
    xi: qreg2 occ2hrunits drinkyear i.d_sex d_age3, quantile(5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95), cluster (newid)

    But now I am getting the error message 'invalid cluster'.

    Is this a problem with my analysis plan or my code?

    Apologies if I have left out any important information - this is my first post here but I have tried to be thorough.

    Thank you,
    Melissa


  • #2
    Hi Melissa
    I think it is just a common typo in your syntax.
    this is what you write
    Code:
    xi: qreg2 occ2hrunits drinkyear i.d_sex d_age3, quantile(5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95), cluster (newid)
    but this is what it should be
    Code:
    xi: qreg2 occ2hrunits drinkyear i.d_sex d_age3, quantile(5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95) cluster(newid)
    So, there is only one "," and no space between cluster and the parenthesis.

    HTH
    Fernando
    Last edited by FernandoRios; 20 Feb 2020, 08:52.

    Comment

    Working...
    X