Announcement

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

  • bayes: mlogit - error

    Hello everyone,
    I have the following vector (A) with 73 observations:


    A | Freq. Percent Cum.
    -----------+-----------------------------------
    ob | 2 2.74 2.74
    lb | 57 78.08 80.82
    pb | 3 4.11 84.93
    unb | 11 15.07 100.00
    ------------+-----------------------------------
    Total | 73 100.00


    I want to estimate the predicted probability for each of the four outcomes (ob, lb, pb, unb) by running an intercept-only bayesian multinomial logistic regression. I type "bayes: mlogit A" and I get the following error:

    new vector must be 1 x 3
    r(198);


    Any idea why I get this? NB: standard "mlogit A" command works fine.

    Any help is really appreciated! Thanks a lot

  • #2
    Alberto:
    works for me in the following toy_example:
    Code:
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . g A=1 in 1/4
    (6 missing values generated)
    
    . replace A=2 in 5/6
    (2 real changes made)
    
    . replace A=3 if missing(A)
    (4 real changes made)
    
    . label define A 1 "bad" 2 "medium" 3 "good"
    
    . label val A A
    
    . bayes: mlogit A
      
    Burn-in ...
    Simulation ...
    
    Model summary
    ------------------------------------------------------------------------------
    Likelihood: 
      medium good ~ mlogit({medium:_cons},{good:_cons})
    
    Priors: 
      {medium:_cons} ~ normal(0,10000)
        {good:_cons} ~ normal(0,10000)
    ------------------------------------------------------------------------------
    
    Bayesian multinomial logistic regression         MCMC iterations  =     12,500
    Random-walk Metropolis-Hastings sampling         Burn-in          =      2,500
                                                     MCMC sample size =     10,000
    Base outcome: bad                                Number of obs    =         10
                                                     Acceptance rate  =      .4293
                                                     Efficiency:  min =      .1445
                                                                  avg =      .1504
    Log marginal likelihood = -20.177187                          max =      .1562
     
    ------------------------------------------------------------------------------
                 |                                                Equal-tailed
                 |      Mean   Std. Dev.     MCSE     Median  [95% Cred. Interval]
    -------------+----------------------------------------------------------------
    medium       |
           _cons | -.8180582   .9518794   .025037  -.7803201  -2.909695   .8691686
    -------------+----------------------------------------------------------------
    good         |
           _cons |  .0066208   .7536667   .019067   .0157107    -1.4501   1.475032
    ------------------------------------------------------------------------------
    Note: Default priors are used for model parameters.
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,
      hanks a lot for your reply. Your example works for me. But my code still doesn't. Here's what I do:

      label define Al 5 lb 9 unb 6 pb 2 ob
      label values A Al
      bayes: mlogit A


      Again, I get:

      new vector must be 1 x 3
      r(198);


      Here's the vector A that I'm using: https://www.dropbox.com/s/w31ebyunnd...ector.dta?dl=0

      I'm using Stata 15.1.

      Thank you!

      Alberto

      Comment


      • #4
        Alberto:
        what if (proposed amendments in red):
        Code:
        label define A 5 "lb" 9 "unb" 6 "pb" 2 "ob"
        label values A Al
        bayes: mlogit A
        If you want to share your data with interested listers, please use -dataex-. Thanks.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Dear Carlo,
          Sorry, I didn't know how to share files. Thank you very much for your suggestions!
          Apparently the problem was related to the values of my vector A: changing the numbers from 5,9,6,2 to 1,2,3,4 solves the problem. I still don't get the reason behind this, but it all works now.
          Thanks,
          Alberto

          Comment


          • #6
            Alberto:
            see -help dataex- (data sharing with -dataex- is easier than it would seem at a very first glance).
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X