Announcement

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

  • #16
    Clyde, the example in your #8 post just helped me solve a problem I had not been able to crack. But how did you figure out where to place the binomial(denominator) option? I.e., how did you know to do this...
    Code:
    melogit numerator independent_variables || id:, binomial(denominator)
    ...rather than this?
    Code:
    melogit numerator independent_variables, binomial(denominator) || id:
    I have just searched the -melogit- documentation for binomial( again, and I still find nothing about where to place it, and no examples. So, how did you know where to put it?

    Thanks,
    Bruce
    --
    Bruce Weaver
    Email: [email protected]
    Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
    Version: Stata/MP 18.0 (Windows)

    Comment


    • #17
      Well, I've been using this approach for a long time (it can really speed up execution by orders of magnitude), and I'm not sure how I originally found out about it--it might have been from reading somebody else's post here. But the syntax for the -binomial()- option in -melogit- is in the help file:

      Syntax

      melogit depvar fe_equation [|| re_equation] [|| re_equation ...] [, options]

      where the syntax of fe_equation is

      [indepvars] [if] [in] [weight] [, fe_options]

      and the syntax of re_equation is one of the following:

      for random coefficients and intercepts

      levelvar: [varlist] [, re_options]

      for random effects among the values of a factor variable in a crossed-effects model

      levelvar: R.varname

      levelvar is a variable identifying the group structure for the random effects at that level or is _all representing one group comprising all observations.

      fe_options Description
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Model
      noconstant suppress constant term from the fixed-effects equation
      offset(varname) include varname in model with coefficient constrained to 1
      asis retain perfect predictor variables
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

      re_options Description
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Model
      covariance(vartype) variance-covariance structure of the random effects
      noconstant suppress constant term from the random-effects equation
      fweight(varname) frequency weights at higher levels
      iweight(varname) importance weights at higher levels
      pweight(varname) sampling weights at higher levels
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

      options Description
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Model
      binomial(varname|#) set binomial trials if data are in binomial form
      ...
      Note, in particular, the distinction between options and fe_options (and re_options).

      Comment


      • #18
        Thanks Clyde. I see it now.
        --
        Bruce Weaver
        Email: [email protected]
        Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
        Version: Stata/MP 18.0 (Windows)

        Comment


        • #19
          One more thing. AFAICT, -logit- has no -binomial()- option. So if one wished to estimate a model with no random effects, presumably the code would be:

          Code:
          melogit numerator independent_variables, binomial(denominator)
          --
          Bruce Weaver
          Email: [email protected]
          Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
          Version: Stata/MP 18.0 (Windows)

          Comment


          • #20
            Yes.

            Or there is another way. -logit-, unlike -melogit- allows -fweight-s. So given a data set where the DV is a fraction and the total denominator is known, you could do something like this:

            Code:
            gen long obs_no = _n
            expand 2
            by obs_no, sort: gen new_DV = _n-1
            by obs_no: gen new_denominator = round(total_denominator* cond(new_DV, fractional_DV, 1-fractional_DV), 1)
            logit new_DV indep_variables [fweight = new_denominator]
            This approach will, except perhaps for tiny discrepancies in distant decimal places, produce the same results as the -melogit- approach. It is, evidently, more cumbersome than -melogit-, and there is also the risk that the rounding to an integer in the creation of new_denominator can go wrong in a few cases. So I don't really recommend this approach. I raise it only a a fallback position in the event that -melogit- fails to converge. The -logit- estimator is more robust in that regard.
            Last edited by Clyde Schechter; 16 Dec 2021, 13:50.

            Comment

            Working...
            X