Announcement

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

  • #16




    nbprob.ado and nbprob.hlp copied here from the UCLA website.

    Code:
    *! version 2.2.1    23oct08, 8dec06 -- pbe
    *! version 1.0.1 23Mar00 -- pbe
    program define nbprob
      version 8.0
      syntax  , Mean(real) Alpha(real) [ n(integer 10) SAVing(string) Graph notable *]
      preserve
      drop _all
      local n = `n' + 1 
      quietly set obs `n' 
      local t = 1/`alpha'
      generate k = _n - 1
    
      generate double term1 = exp(lngamma(k+`t')) / (exp(lngamma(`t'))*(exp(lnfact(k))))
      generate double term2 = (`t'/(`t'+`mean'))^`t'
      generate double term3 = (`mean'/(`mean'+`t'))^k
      generate double nbprob = term1 * term2 * term3
      generate nbcum = sum(nbprob)
      drop term1 term2 term3
      format nbprob nbcum %9.8f
      format k %4.0f
      if "`table'" == "" {
        display
        display "  Negative Binomial Probabilities"
        display "  with mean = `mean' & overdispersion = `alpha'"
        list
      }
      
      format nbprob %3.2g
      if "`graph'" ~= "" {
        twoway connected nbprob k, ylabel(0(.1).3)  ///
          title("Negative binomial: mean = `mean', alpha = `alpha'")  ///
          `options'
      }
      if "`saving'" ~= "" {
        sort k
        quietly save "`saving'"
      }
      restore
    end
    Code:
    .-
    help for ^nbprob^
    .-
    
    Negative binomial probabilities
    --------------------------------
    
     ^nbprob^ , ^m^ean(value) ^a^lpha(value) [ ^n^(integer) ^graph sav^ing(filename) graph_options]
     
    
    Description
    -----------
    
    ^nbprob^ generates negative binomial probabilites.
    
    Options
    -------
    
    ^mean^ the mean of the negative binomial distribution.
    
    ^alpha^ the overdispersion parameter.  Because the
          algorithm use 1/alpha, alpha cannot be zero.
          
    ^n^ the number of discrete levels to be included.
      The default value of n is 10.
    
    ^graph^ displays a graph of the probabilities.
    
    ^saving^ creates a data file with the probabilities.
    
    
    Examples
    --------
    
     . ^nbprob, mean(2) alpha(.5)^
     . ^nbprob, mean(2.3) alpha(1.2) n(10) graph^
    
    
    
    Author
    ------
    
          Philip B. Ender
          Statistical Computing and Consulting
          UCLA, Office of Academic Computing
          ender@@ucla.edu

    Comment


    • #17
      Thanks a lot. Now it works. I copied the code to a Do-File and saved it as ado/hlp in my PLUS folder.

      Comment


      • #18
        Added in edit: Did not realize that an answer was available on the following Statalist page when I followed the email link to post #15.

        Despite having gotten your problem solved, if you could still share your experience with the IDRE web site, you might benefit subsequent users. You could link them to this discussion.

        To that I will add that when I installed nbvargr/nbprob/pprob by following search nbvargr to net describe nbvargr, from(https://stats.idre.ucla.edu/stat/stata/ado/analysis) and then clicked the install link, I received a copy that identified as version 1.2.1 rather than 2.2.1 as Nick's version, although the code appears similar.
        Code:
        *! version 1.2.1    23oct08, 8dec06 -- pbe
        *! version 1.0.1 23Mar00 -- pbe
        IDRE redesigned their site some years ago at the time it was moved to a new server (I believe) and it has not been quite the same ever since.


        At the bottom of the page from which you downloaded nbvargr and pprob there is a link that reads "Click here to report an error or leave a comment." I suggest you report that in the absence of the nbprob program, nbvargr is unusable and ask for their assistance.

        That's the straightforward approach that may yield some assistance. But if not, there's a back-door approach.

        Since you use Stata 12, you have access to the functions introduced in Stata 10. This from the output of help whatsnew10to11 -
        Code:
               23.  New functions binomialp(); hypergeometric() and hypergeometricp();
                    nbinomial(), nbinomialp(), and nbinomialtail(); and poisson(), poissonp(), and
                    poissontail() provide distribution and probability mass for the binomial,
                    hypergeometric, negative binomial, and Poisson distributions.  See [FN]
                    Statistical functions.
        To the extent that you can understand what the calling sequences was for nbprob, you can write your own nbprob program that passes its arguments to the appropriate nbinomial function and the passes the returned values back to the calling program. That's pretty subtle stuff, and if you have to go this way, you should start by reading Chapter 18 of the Stata User's Guide PDF included in your installation and accessible through Stata's Help menu.
        Last edited by William Lisowski; 10 Feb 2020, 10:53.

        Comment


        • #19
          Everyone is right, but let's underline how this thread arises.

          I was able to post the code in #16 because I could download it using a recent version of Stata.

          The people reporting problems here have problems downloading using Stata because they have out-of-date versions of Stata, 11 and 12 respectively. Support for https: was only added in Stata 13.

          In essence the UCLA people updated the source readable by Stata to a modern standard, https, but in providing an alternative that can be accessed by browsers directly they forgot to include one pair of files.

          Let's just say -- without imputing blame -- that my sympathies run both ways. Stata costs money, but with the best will in the world people unable to update lose out in some ways.


          Comment


          • #20
            The version number 2.2.1 in #16 appears to arise from a false keystroke of mine when I was copying the file. Sorry about that, but the general point not to trust people when machines are more accurate will be familiar.

            Comment


            • #21
              Thank you both again for helping me. Also for the Stata manual reading recommendation on how to program my own commands. As suggested by William, I also contacted IDRE via the link that reads "Click here to report an error or leave a comment." and reported that the nbprob is not available as zip-file and asked for their assistance.

              Comment

              Working...
              X