Announcement

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

  • Multivariate Probit Set-up using mvprobit

    Dear Users,

    I have been doing some research through past literature into how a multivariate probit model could be applied to my investigation to analyse the adoption of multiple adaptation strategies by farmers. I have binary variables for my the uptake of my three key dependent variables, as well as some other relevant independent variables to include in the model. I was trying to look through this forum to understand how to set-up a model like this in stata. Also my data is weighted (pweight) data which could also complicate matters further.

    When attempting to use the mvprobit command in stata I received the following error message:

    unknown function *normprob()
    r(133);


    Any help with structuring the set-up of this model or troubleshooting the above error would be greatly appreciated!

    Thanks in advance.

  • #2
    Samuel, it would be helpful if you could provide your estimation command and indicate what version of Stata you are running. Also tagging Stephen Jenkins who is likely to have definitive insights.

    Comment


    • #3
      Thank you for the response John!

      As recommended I will tag Stephen Jenkins to potentially assist with my issue.

      I am relatively new to stata but have been trying to use information on this forum and the wider internet to guide my work.

      The estimation command which gave the above error was as follows:

      Code:
      mvprobit (DepVar1 = IndepVar1 IndepVar2 ...) (DepVar2 = IndepVar1 IndepVar2 ...) (DepVar3 = IndepVar1 IndepVar2 ...)

      I am running Stata version 17.

      I am also interested as to whether I could include weights in the mvprobit command, however I wanted to understand how to format the estimation command prior to addressing this.

      Thanks in advance for any help!

      Comment


      • #4
        I don't why there is a problem, to be honest. (Note too that the help-file tells you which weights are allowed.) The program works for me:
        Code:
        . ssc d mvprobit
        
        ----------------------------------------------------------------------------------------------------------------------------------------------------------
        package mvprobit from http://fmwww.bc.edu/repec/bocode/m
        ----------------------------------------------------------------------------------------------------------------------------------------------------------
        
        TITLE
              'MVPROBIT': module to calculate multivariate probit regression using simulated maximum likelihood
        
        DESCRIPTION/AUTHOR(S)
              
               mvprobit estimates M-equation probit models, by the method of
              simulated maximum likelihood (SML). (Cf. probit and biprobit
              which estimate 1-equation and 2-equation probit models by maximum
              likelihood.) The variance-covariance matrix of the
              cross-equation error terms has values of  1 on the leading
              diagonal, and the off-diagonal elements are correlations  to be
              estimated. mvprobit uses the Geweke-Hajivassiliou-Keane (GHK)
              simulator  to evaluate the M-dimensional Normal integrals in the
              likelihood  function. For each observation, a likelihood
              contribution is calculated  for each replication, and the
              simulated likelihood contribution is the  average of the values
              derived from all the replications. The simulated  likelihood
              function for the sample as a whole is then maximized using
              standard methods (ml in this case).
              
              KW: multivariate probit
              KW: simulated maximum likelihood
              
              Requires: Stata version 7.0
              
              Distribution-Date: 20240306
              
              Author: Lorenzo Cappellari, Université del Piemonte Orientale and University of Essex
              Support: email [email protected]
              
              Author: Stephen P. Jenkins, London School of Economics and Political Science
              Support: email
              
        
        INSTALLATION FILES                             (type net install mvprobit)
              mvprobit.ado
              mvprob_ll.ado
              mvprobit.hlp
              mvppred.ado
              mvppred.hlp
        ----------------------------------------------------------------------------------------------------------------------------------------------------------
        (type ssc install mvprobit to install)
        
        . which mvprobit
        d:\home\stephenj\ado\stbplus\m\mvprobit.ado
        *! version 3.0.1  05may2024 Cappellari & Jenkins   
        *!  fix rarely-biting bug in Replay (thanks to Jeff Pitblado for suggested fix)
        *! version 3.0.0  12april2006 Cappellari & Jenkins            
        *!      revised: aa algorithm, draw vble naming scheme
        *! version 2.1.0  19may2005  Cappellari & Jenkins            
        *!      update to version 8.2
        *! version 1.0.0  15jan2003  Cappellari & Jenkins            (SJ3-3:st0045)
        *! Multivariate probit by method of MSL.  
        
        . use http://www.stata-press.com/data/r7/school.dta, clear
        
        . mvprobit (private = years logptax loginc) (vote = years logptax loginc) (pub12 = years loginc), draws(53)
        
        Iteration 0:  Log likelihood = -155.61255  
        Iteration 1:  Log likelihood = -153.95274  
        Iteration 2:  Log likelihood = -153.82632  
        Iteration 3:  Log likelihood = -153.82562  
        Iteration 4:  Log likelihood = -153.82562  
        
        Multivariate probit (MSL, # draws = 53)           Number of obs   =         95
                                                          Wald chi2(8)    =      10.02
        Log likelihood = -153.82562                       Prob > chi2     =     0.2636
        
        ------------------------------------------------------------------------------
                     | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        private      |
               years |  -.0137918   .0261964    -0.53   0.599    -.0651359    .0375523
             logptax |  -.1699739   .6602698    -0.26   0.797    -1.464079    1.124131
              loginc |   .3723182   .5128901     0.73   0.468     -.632928    1.377564
               _cons |  -3.690357   4.837828    -0.76   0.446    -13.17233    5.791611
        -------------+----------------------------------------------------------------
        vote         |
               years |  -.0165344   .0147786    -1.12   0.263       -.0455    .0124312
             logptax |  -1.281263   .5680567    -2.26   0.024    -2.394633    -.167892
              loginc |   1.006309   .4406539     2.28   0.022     .1426436    1.869975
               _cons |  -.6689479   4.042113    -0.17   0.869    -8.591345    7.253449
        -------------+----------------------------------------------------------------
        pub12        |
               years |   .0046203   .0144897     0.32   0.750    -.0237789    .0330195
              loginc |   .1668134   .3437143     0.49   0.627    -.5068542    .8404809
               _cons |  -1.740017   3.475208    -0.50   0.617    -8.551299    5.071264
        -------------+----------------------------------------------------------------
            /atrho21 |  -.2282406   .2386533    -0.96   0.339    -.6959924    .2395113
        -------------+----------------------------------------------------------------
            /atrho31 |  -.2959931   .2197236    -1.35   0.178    -.7266435    .1346573
        -------------+----------------------------------------------------------------
            /atrho32 |    -.08106   .1694425    -0.48   0.632    -.4131612    .2510412
        -------------+----------------------------------------------------------------
               rho21 |  -.2243581   .2266403    -0.99   0.322    -.6018178    .2350341
        -------------+----------------------------------------------------------------
               rho31 |  -.2876415   .2015442    -1.43   0.154    -.6210076    .1338493
        -------------+----------------------------------------------------------------
               rho32 |  -.0808829    .168334    -0.48   0.631    -.3911535    .2458971
        ------------------------------------------------------------------------------
        Likelihood ratio test of  rho21 = rho31 = rho32 = 0:  
                     chi2(3) =  3.57387   Prob > chi2 = 0.3113
        
        . version 17: mvprobit (private = years logptax loginc) (vote = years logptax loginc) (pub12 = years loginc), draws(53)
        
        Iteration 0:  Log likelihood = -155.61255  
        Iteration 1:  Log likelihood = -153.95274  
        Iteration 2:  Log likelihood = -153.82632  
        Iteration 3:  Log likelihood = -153.82562  
        Iteration 4:  Log likelihood = -153.82562  
        
        Multivariate probit (MSL, # draws = 53)           Number of obs   =         95
                                                          Wald chi2(8)    =      10.02
        Log likelihood = -153.82562                       Prob > chi2     =     0.2636
        
        ------------------------------------------------------------------------------
                     | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        private      |
               years |  -.0137918   .0261964    -0.53   0.599    -.0651359    .0375523
             logptax |  -.1699739   .6602698    -0.26   0.797    -1.464079    1.124131
              loginc |   .3723182   .5128901     0.73   0.468     -.632928    1.377564
               _cons |  -3.690357   4.837828    -0.76   0.446    -13.17233    5.791611
        -------------+----------------------------------------------------------------
        vote         |
               years |  -.0165344   .0147786    -1.12   0.263       -.0455    .0124312
             logptax |  -1.281263   .5680567    -2.26   0.024    -2.394633    -.167892
              loginc |   1.006309   .4406539     2.28   0.022     .1426436    1.869975
               _cons |  -.6689479   4.042113    -0.17   0.869    -8.591345    7.253449
        -------------+----------------------------------------------------------------
        pub12        |
               years |   .0046203   .0144897     0.32   0.750    -.0237789    .0330195
              loginc |   .1668134   .3437143     0.49   0.627    -.5068542    .8404809
               _cons |  -1.740017   3.475208    -0.50   0.617    -8.551299    5.071264
        -------------+----------------------------------------------------------------
            /atrho21 |  -.2282406   .2386533    -0.96   0.339    -.6959924    .2395113
        -------------+----------------------------------------------------------------
            /atrho31 |  -.2959931   .2197236    -1.35   0.178    -.7266435    .1346573
        -------------+----------------------------------------------------------------
            /atrho32 |    -.08106   .1694425    -0.48   0.632    -.4131612    .2510412
        -------------+----------------------------------------------------------------
               rho21 |  -.2243581   .2266403    -0.99   0.322    -.6018178    .2350341
        -------------+----------------------------------------------------------------
               rho31 |  -.2876415   .2015442    -1.43   0.154    -.6210076    .1338493
        -------------+----------------------------------------------------------------
               rho32 |  -.0808829    .168334    -0.48   0.631    -.3911535    .2458971
        ------------------------------------------------------------------------------
        Likelihood ratio test of  rho21 = rho31 = rho32 = 0:  
                     chi2(3) =  3.57387   Prob > chi2 = 0.3113

        Comment


        • #5
          Dear Stephen Jenkins,

          Thank you very much for the response Professor.

          Even using your above code I still receive the same issue:

          Code:
          ssc install mvprobit
          which mvprobit
          /Users/samuelwelch/Library/Application Support/Stata/ado/plus/m/mvprobit.ado
          *! version 3.0.1 05may2024 Cappellari & Jenkins
          *! fix rarely-biting bug in Replay (thanks to Jeff Pitblado for suggested fix)
          *! version 3.0.0 12april2006 Cappellari & Jenkins
          *! revised: aa algorithm, draw vble naming scheme
          *! version 2.1.0 19may2005 Cappellari & Jenkins
          *! update to version 8.2
          *! version 1.0.0 15jan2003 Cappellari & Jenkins (SJ3-3:st0045)
          *! Multivariate probit by method of MSL.

          . d:\home\stephenj\ado\stbplus\m\mvprobit.ado
          : invalid name
          r(198);

          . *! version 3.0.1 05may2024 Cappellari & Jenkins

          . *! fix rarely-biting bug in Replay (thanks to Jeff Pitblado for suggested fix)

          . *! version 3.0.0 12april2006 Cappellari & Jenkins

          . *! revised: aa algorithm, draw vble naming scheme

          . *! version 2.1.0 19may2005 Cappellari & Jenkins

          . *! update to version 8.2

          . *! version 1.0.0 15jan2003 Cappellari & Jenkins (SJ3-3:st0045)

          . *! Multivariate probit by method of MSL.

          .
          . . use http://www.stata-press.com/data/r7/school.dta, clear

          . mvprobit (private = years logptax loginc) (vote = years logptax loginc) (pub12 = years loginc), draws(53)

          unknown function *normprob()
          r(133);

          Hence I believe it may not be an issue with my data or code but something else.

          Comment


          • #6
            I can replicate this error.

            Using set trace on the error arises in the program mvprob_ll when a global macro (in bold font below) evaluates to an empty string.
            Code:
                              - replace `d`i'' = invnorm(${S_MLE_z`i'`d'}*normprob((`arg`i'')/`c`i'`i''))
                              = replace __00009T = invnorm(*normprob((__00009V)/__0000AH))
            unknown function *normprob()
            Do-file and log file are attached for reference. The log file is ca. 360 kilobytes (contains the output from trace), the forum software apparently cannot accommodate a file that large as an attachment and so I zipped it before attaching it. The forum software won't permit attaching a filename with a .zip extension and so I changed it to .txt. (You can rename its file extension back to .zip after downloading it.)

            I didn't install the package using ssc install, but rather copied the files to the present working directory (see do-file). I don't know whether that has anything to with causing the error to happen.
            Attached Files

            Comment


            • #7
              Dear Joseph,

              Thank you for your response.

              However, I am a bit confused about what you are trying to say I should do when faced with this error?

              Thanks in advance!

              Comment


              • #8
                Thanks for the further investigations, Samuel Welch and Joseph Coveney I cannot reproduce this problem. Relatedly, I can't see how/why the global macro that Joseph cites is empty. The code block in mvprobit.ado in which it/they are created is:


                Code:
                        forval i = 1/$S_MLE_M {
                                forval d = 1/`D' {
                                        tempvar z a
                                        draws `z' `touse'
                                        global S_MLE_z`i'_`d' "`z'" 
                                        if "`aa'" != "" {
                                                ge double `a'`z' = 1 - `z'
                                                global S_MLE_z`i'_`=`D'+`d'' "`a'`z'" 
                                        }
                                }
                The other global macros that are required (like S_MLE_M, the number of equations) are created earlier on. The error CODE extract that Joseph shows is from a call to mvprob_ll.ado. That's a version 8.2 program (if that matters).

                So, I am stumped. (Also puzzled because other users have been using -mvprobit- without problems within the last year or so.)

                Comment


                • #9
                  Originally posted by Stephen Jenkins View Post
                  So, I am stumped. (Also puzzled because other users have been using -mvprobit- without problems within the last year or so.)
                  Is that when this last revision was made, May of last year? (The revision date is accidentally recorded as May of this year.)

                  Anyway, I can see a problem in that the underscore is missing when that global macro is called in the line that I show above: the code that you post (that creates the macro) shows its having an underscore
                  Code:
                  global S_MLE_z`i'_`d' "`z'"
                  and
                  Code:
                  global S_MLE_z`i'_`=`D'+`d'' "`a'`z'"
                  but what's called (in the snippet of trace output shown in my post) lacks that underscore.
                  Code:
                  replace `d`i'' = invnorm(${S_MLE_z`i'`d'}*normprob((`arg`i'')/`c`i'`i''))
                  and so no such global macro exists.

                  Comment


                  • #10
                    Joseph Coveney Thanks very much again. Well spotted. Strange, nonetheless, that the line you refer to (line 90 in mvprob_ll.ado) is the following in my (master) copy, and I note the underscore present!

                    Code:
                                    replace `d`i'' = invnorm(${S_MLE_z`i'_`d'}*normprob((`arg`i'')/`c`i'`i''))
                    [The very minor update to -mvprobit- recently was to deal with a rare problem arising with replay-ing the command and I changed mvprobit.ado.]

                    Whatever, it seems that the version of mvprob_ll.ado on SSC has a problem. I don't know how it arose, but I'll ask Kit Baum to replace the version there with what I have here.

                    thanks again for your help with this.

                    Comment


                    • #11
                      Thank you very much for all your help in investigating this and trouble shooting the issue Joseph Coveney and Stephen Jenkins, it is much appreciated.

                      Will it just be a case of re installing the updated version of mvprobit when it is replaced by the new version?

                      Thanks again for your help with this!

                      Comment


                      • #12
                        -ssc install mvprobit, replace- should do it. If you're in a hurry, you could edit line 90 in mvprob_ll.ado to fix the apparent problem with the SSC version of that file, noting the commentary above. (I've sent my version of that file to Kit/SSC.)

                        Comment


                        • #13
                          Dear Stephen Jenkins,

                          Thank you again for all your help, I have implemented the recommended changes into line 90 of the mvprob_ll.ado and run the command and it now works.

                          Also thank you very much Joseph Coveney for you help with finding the issue with the command!

                          Comment


                          • #14
                            with thanks as ever to Kit Baum, the "mvprob_ll.ado" file in the "mvprobit" package on SSC has been replaced. (See #12)

                            Comment


                            • #15
                              Dear Stephen Jenkins

                              I am trying to apply mvprobit to my current research, but I need a little clarification on the factor variable operators with mvprobit (it's completely new to me). I tried to incorporate the operator (e.g. i.sex) as is usually the case with probit/logit but it is not working. However, when I removed the operator, I was able to estimate the model. Thus, how do I interpret such a categorical variable, especially when the categories are more than 2?

                              The second question is, aside from mvpred, are there any other postestimation tests I need to do? The third question is can I have the same exact variables in all four equations (I have four equations and I want to use the same covariates)? And finally, what is the command to create the correlation table after the estimation? I would also appreciate it if you could suggest more reading materials on mvprobit aside from Cappellari and Jenkins (2003, 2004, 2006) and Greene (2003). Thank you in advance.
                              Last edited by Adama Touray; 16 Apr 2024, 05:34.

                              Comment

                              Working...
                              X