Announcement

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

  • Bayesmh droppes factor variables/dummies

    This is a follow-up question to this one, but since it's a different question, and to increase searchability of the forum I'm posting it separately.

    I'm setting up an estimation of a two-equation model using bayesmh. Some of the model's parameters are ~fixed effects, i.e. call bayes mh as:
    Code:
    bayesmh (link=treatment x1 i.group) (bilink=treatment x2 i.group) ,///
      llevaluator(mylikelihoodevaluator) ///
      prior({eco_link: treatment x1 i.group} {bilink: treatment x2 i.group},flat)
    But bayesmh drops these and writes:
    Code:
    note: parameter link:1.group is omitted
    note: parameter link:2.group is omitted
    note: parameter bilink:1.group is omitted
    note: parameter bilink:2.group is omitted
    I can work around this by using dummies, but I suspect this is telling me that something about doing this is bad.


    My likelihood is:
    Code:
    program define mylikelihoodevaluator
       args lnf Xb1 Xb2
       tempvar lnfj
       qui gen `lnfj' = .
       qui replace `lnfj' = ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $MH_y1==0
       qui replace `lnfj' = ln(normal(`Xb1'))+ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $MH_y1==1 & $MH_y2==0
       qui replace `lnfj' = ln(1-(1-normal(`Xb1')*normal(`Xb1'))*(1-normal(`Xb2'))) if $MH_y1==1 & $MH_y2==1
       summarize `lnfj' if $MH_touse, meanonly
       if r(N) < $MH_n {
           scalar `lnf'=.
           exit
       }
        scalar `lnf' = r(sum)
    end
    Last edited by Simon Heß; 12 May 2016, 10:13.

  • #2
    I noticed some typos in the code above that only happened when simplifying my code to be posted here. Hence, here comes an updated version of my question:


    Bayesmh drops factor variables/dummies:

    I'm setting up an estimation of a two-equation model using bayesmh. Some of the model's parameters are ~fixed effects, meaing I call bayesmh as

    Code:
    bayesmh (link=treatment x1 i.group) (bilink=treatment x2 i.group) ,///
      llevaluator(mylikelihoodevaluator) ///
      prior({link: treatment x1 i.group} {bilink: treatment x2 i.group},normal(0,1))
    But bayesmh drops these and writes:
    Code:
    note: parameter link:1.group is omitted
    note: parameter link:2.group is omitted
    note: parameter bilink:1.group is omitted
    note: parameter bilink:2.group is omitted
    I can work around this by using dummies, but I suspect this is telling me that something about doing this is bad.

    My likelihood is:

    Code:
    program define mylikelihoodevaluator
       args lnf Xb1 Xb2
       tempvar lnfj
       qui gen `lnfj' = .
       qui replace `lnfj' = ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $MH_y1==0
       qui replace `lnfj' = ln(normal(`Xb1'))+ln(1-normal(`Xb1'))+ln(1-normal(`Xb2')) if $MH_y1==1 & $MH_y2==0
       qui replace `lnfj' = ln(1-(1-normal(`Xb1')*normal(`Xb1'))*(1-normal(`Xb2'))) if $MH_y1==1 & $MH_y2==1
       summarize `lnfj' if $MH_touse, meanonly
       if r(N) < $MH_n {
           scalar `lnf'=.
           exit
       }
        scalar `lnf' = r(sum)
    end

    Comment


    • #3
      Simon,

      I believe you misspecified the likelihood equations of your model. I see the equal sign, =, in your two equations
      Code:
      (link=treatment x1 i.group) (bilink=treatment x2 i.group)
      However, an equal sign is only used when you specify multiple outcomes with common regressors or in non-linear specifications. You should not use it in your case.

      A right specification of your model would be
      Code:
      . bayesmh (link treatment x1 i.group) (bilink treatment x2 i.group), ///
          llevaluator(mylikelihoodevaluator)                               ///
          prior({link: treatment x1 i.group _cons},   normal(0, 1))        ///
          prior({bilink: treatment x2 i.group _cons}, normal(0, 1))        ///
          block({link:}) dots
      Please let me know if you still have problems.

      Nikolay

      Comment

      Working...
      X