Announcement

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

  • cluster 2 varlist not allowed

    Hi, I'm replicating a report, and this is the attached do-file
    use wintertime_final, clear

    gen snodas_weighted=snodas_max+(.25+.125*west)*(fsnoda s_max-snodas_max)

    xi i.wk i.sn

    cluster2 resort wk2 _I*, tcluster(d) fcluster(sn)
    outreg2 using table2, replace excel dec(3) keep(wk2)
    cluster2 resort wk2 _I* if snodas_max~=., tcluster(d) fcluster(sn)
    outreg2 using table2, excel dec(3) keep(wk2)

    cluster2 resort wk2 snodas_max _I*, tcluster(d) fcluster(sn)
    outreg2 using table2, excel dec(3) keep(wk2 snodas_max)
    cluster2 resort wk2 snodas_weighted _I*, tcluster(d) fcluster(sn)
    outreg2 using table2, excel dec(3) keep(wk2 snodas_weighted)
    cluster2 resort wk2 fsnodas_max snodas_max lsnodas_max _I*, tcluster(d) fcluster(sn)
    outreg2 using table2, excel dec(3) keep(wk2 fsnodas_max snodas_max lsnodas_max)

    But I cannot use cluster 2 (I installed cluster2.ado), each time I run the data, it shows "varlist not allowed",

    Can anyone help me in this one?
    Thank you!

  • #2
    I think this do-file must have been written a long time ago for an earlier version of Stata. It's also been corrupted: the very first line -gen snodas_weighted=snodas_max+(.25+.125*west)*(fsnoda s_max-snodas_max)- is a syntax error due to the blank space between fsnoda and s_max near the end. So I'm not even sure how you got to the cluster2 command(s). Also, while -xi- still works, it is an almost completely obsolete command.

    But most important, -cluster2- must refer to some user-written command that you do not have in your installation. There is no official Stata command by that name. And a search for a user-written command turns up a -cluster2- that is a program to calculate sample size or minimum detectable effect size for two-level cluster-randomized trials from SSC. If the -cluster2- that you installed comes from SSC, it is clearly not the one this do-file needs. That command, indeed, does not take a varlist, and it also doesn't return anything that -outreg2- could work with. Nor does it take options -tcluster()- or -fcluster()-. So I think the original do-file was referring to some other -cluster2- command that, maybe, does cluster analysis of some kind? Where did the cluster2.ado that you installed come from? Have you checked its help file to see what it does and what its proper syntax is?

    I did a quick Google search on cluster2.ado and quickly found references to a file of that name in an old Statalist post at https://www.stata.com/statalist/arch.../msg01974.html. From the content of that old post, it appears to be the same command you want. However, the link to cluster2.ado itself appears not to work anymore. Anyway, if you spend more time with on Google looking for it than I did you might be able to actually find what you are looking for. Alternatively, you might just go to whoever gave you this do-file you're working with and ask if they have it.

    Comment


    • #3
      You can use -vcemway regress- as an alternative to -cluster2- that your do-file refers to. Please type -ssc install vcemway- and see the help file for more information. There is also a longer documentation of the command in the Stata Journal: here.
      Last edited by Hong Il Yoo; 30 Nov 2020, 23:20.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        I think this do-file must have been written a long time ago for an earlier version of Stata. It's also been corrupted: the very first line -gen snodas_weighted=snodas_max+(.25+.125*west)*(fsnoda s_max-snodas_max)- is a syntax error due to the blank space between fsnoda and s_max near the end. So I'm not even sure how you got to the cluster2 command(s). Also, while -xi- still works, it is an almost completely obsolete command.

        But most important, -cluster2- must refer to some user-written command that you do not have in your installation. There is no official Stata command by that name. And a search for a user-written command turns up a -cluster2- that is a program to calculate sample size or minimum detectable effect size for two-level cluster-randomized trials from SSC. If the -cluster2- that you installed comes from SSC, it is clearly not the one this do-file needs. That command, indeed, does not take a varlist, and it also doesn't return anything that -outreg2- could work with. Nor does it take options -tcluster()- or -fcluster()-. So I think the original do-file was referring to some other -cluster2- command that, maybe, does cluster analysis of some kind? Where did the cluster2.ado that you installed come from? Have you checked its help file to see what it does and what its proper syntax is?

        I did a quick Google search on cluster2.ado and quickly found references to a file of that name in an old Statalist post at https://www.stata.com/statalist/arch.../msg01974.html. From the content of that old post, it appears to be the same command you want. However, the link to cluster2.ado itself appears not to work anymore. Anyway, if you spend more time with on Google looking for it than I did you might be able to actually find what you are looking for. Alternatively, you might just go to whoever gave you this do-file you're working with and ask if they have it.
        Thank you, yes it is an old paper and these commands are from its attached do-file. I have another question. Based on the original code, it seems that there have plenty of dummy variables, (the date is based on "days" of 4 years), do I really need to generate this amount of dummies or is there an easier way to estimate dummies together?

        Comment


        • #5
          You don't have to. To control for dummy variables based on variable x, you can type -regress y i.x- and the like, instead of generating the dummy variables explicitly prior to estimation. See -help fvvarlist- for further information. Alternatively, you can use commands that estimate transformed models that difference away the dummy variables in the style of within-transformation. See the -absorb()- option of Stata's -areg- or user-written command -reghdfe- (-ssc install reghdfe- to install).

          Comment


          • #6
            Thank you! reghdfe works well!

            Comment

            Working...
            X