Announcement

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

  • observed and predicted plot of count data

    Any help please?

    I am after a stata code to help plot the observed and predicted count of data following comparison with Poisson and negative binomial.

    After some search, I found this stata user written command -prcounts- . However, it does generate the predicted estimates but does not plot the graph. I am not sure if my Stata/IC 15 is supported as it seems the code was written since the year 2000 http://www.indiana.edu/~jslsoc/files...TBprcounts.pdf .

    Sample of my code is:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int pre float(counts disease)
     3  1 2
     3  2 2
     3  3 2
     3  4 2
    11  1 2
     3  1 2
     3  2 4
    11  1 2
    11  2 4
    32  1 2
     3  1 2
     3  2 2
     0  0 2
     3  1 2
     3  1 2
     3  2 2
     3  3 2
     3  1 2
     3  2 2
     0  0 2
     3  1 2
     3  2 2
     3  3 2
     3  1 2
     3  2 4
     3  3 2
     3  1 2
     0  0 1
     3  1 2
     7  1 2
     3  1 2
     3  2 2
     3  1 2
     3  2 2
     3  3 2
    11  1 2
    11  2 2
     0  0 2
     1  1 2
     3  1 4
     3  2 2
     3  3 2
     3  4 2
     3  5 2
     3  6 1
     3  7 2
     3  8 2
     3  9 2
     3 10 2
     3 11 1
     3 12 2
     3 13 2
     3 14 2
     3 15 2
     3 16 2
     3 17 1
     5  1 2
    11  1 2
    11  2 4
    11  3 4
    11  4 2
    18  1 2
    32  1 2
     0  0 1
     3  1 2
     3  2 2
     3  3 2
     3  4 2
     3  5 2
     3  6 2
     3  7 2
     3  8 2
    11  1 2
     0  0 1
     3  1 2
     3  2 2
     3  3 2
     3  4 2
     3  5 2
     3  6 2
     3  7 2
     3  8 2
     3  9 2
     3 10 2
     3 11 2
     3 12 2
     3 13 2
    11  1 4
    11  2 4
    11  3 2
     3  1 2
     3  2 2
     3  3 2
     3  4 2
     3  5 2
     3  6 2
    11  1 2
     2  1 2
     2  2 2
     3  1 2
    end

    Code:
    poisson counts i.disease
    prcounts pois, max(16) plot
    
    nbreg counts i.disease
    prcounts nbreg, max(16) plot
    Code:
    graph poisrate poisval nbregrate nbregval ziprate
    I get the following message if I try to graph:

    Code:
    poisrategraph_g.new poisval nbregrate nbregval ziprate: class member function not found
    r(4023);
    All I want is a graph like the one attached:

    Thanks
    Attached Files

  • #2
    ziprate is not in your example data. Aother problem is that your graph syntax was superseded by Stata 8

    Code:
     
     version 7: graph poisrate poisval nbregrate nbregval ziprate
    may work (i.e. be a legal command) with your data, but it's not the graph you ask for. Further, you are fitting with a categorical predictor, so your set-up is one distribution for each category and each model, so you need something more complicated.

    Comment


    • #3
      Hi Nick,

      Thanks, I have used the version control command as suggested
      Code:
       
       version 7: graph poisrate poisval nbregrate nbregval
      But that is not what I am expecting. Is there any command you are aware of that I can use to get the graph I'm expecting.

      Thanks

      Comment


      • #4
        I don't know what graph you are expecting, so you should explain. I count 3 diseases in your example data. Perhaps there are even more in your full data.

        Comment


        • #5
          My aim is to compare Poisson and negative binomial regression in this example count data. My predictor variable (disease) in full data is 0 to 4. I want to know which of the method fits my data better than each other graphically. In my full data I'm extending to include zero-inflated Poisson and zero inflated negative binomial

          Comment


          • #6
            Sure, I understand that but I am not clearer on what graphs you expect.

            Comment


            • #7
              Something like this
              Attached Files

              Comment


              • #8
                Hi Madu, I am wondering if you found a solution to your problem above. I have the same. Many thanks!

                Comment


                • #9
                  Previous posts got nowhere because each model fitted in #1 implies a set of distribution curves, not one.

                  Comment


                  • #10
                    thanks, nick, for your reply. but there is any way in Stata to plot (together with the histogram graph of the observed distribution) a line depicting with a binomial distribution with a p (the average probability of the observed distribution) and an n? and maybe a test that says how much the two look like the same? sorry for silly questions. many thanks

                    Comment


                    • #11
                      So you don't have the same problem; you have a different problem. In any case please do read https://www.statalist.org/forums/help#stata and give some example data. How many trials?

                      Comment

                      Working...
                      X