Announcement

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

  • invalid syntax using cdfplot

    Hi,

    I am using a user written command cdfplot in Stata 15 to generate normalized cdf by a categorical variable using the code
    Code:
    cdfplot x [pweight=weight], normal nocdf by(y)
    However, I am getting invalid syntax error. The code works with some categorical variables but results to an error while using other variables.

    Kind request for some help on the issue.

    Thanks in advance.

    Best,
    Stephen.

  • #2
    Syntax looks correct. I don't see how we're expected to say more as this is just "works sometimes and not others". We have the same problem with our cooker and don't expect that information to be much help to the repair person.

    Give a data example for when it doesn't work, please.

    BTW, I wouldn't describe the option normal as producing normalized cdf. The data aren't normalized in any sense; they're shown as they are. The option just superimposes a corresponding normal cdf for the same mean and SD. I would always prefer the results of qnorm myself.

    Comment


    • #3
      Thanks Nick for the reply. Much appreciated.

      Below is example of the data

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(weight x) long y
       56.48856 .z  1
         430.42 .z .z
       52.32442 .z  0
      2400.9814 .z  1
       42.92722 .z .z
      4.0646443 .z .z
       111.2805 .z  0
      412.74255 48 .z
      2.1733863 .z .z
      191.64484 .z  0
       847.1944 .z .z
       4.325087 .z .z
        23.4709  8 .z
      31.221676 72 .z
      .20838735 50 .z
       49.40934 .z .z
       817.3868 .z .z
       27.78372 .z .z
       856.5333 .z .z
       508.9236 .z .z
      124.54675 .z .z
       43.72495 .z  0
        1567.02 .z  1
       171.7089 39 .z
       55.47367 30  1
       85.28024 .z .z
      22.181936 .z .z
       60.94157 .z  0
      149.82014 .z .z
       2.512651 .z .z
      14.018277 .z .z
       42.92722 .z .z
      .55545515 .z .z
       76.89115 56  0
       24.82574 21  0
      15.335054 .z  0
       97.69048 .z .z
       357.1795 .z  1
       704.0506 .z .z
         2569.6 .z  1
       817.3868  2  0
       6.501606 .z .z
      166.73073 74 .z
      15.303948 .z .z
       634.8437 .z .z
       1814.716 .z .z
       .6323494 .z  1
       .3003667 .z .z
       46.29515 .z .z
       48.55399 .z .z
      end
      label values y births
      label def births 0 "No", modify
      label def births 1 "Yes", modify
      label def births .z "Not administered", modify

      Comment


      • #4
        That's now a reproducible example.

        The problem is the missing values on y, which tickle a bug.

        On a quick guess, the program ignores the missing values in one place but not in another and ends strangled by an inconsistency. If you don't care about the missing values, you should exclude them explicitly, If you do care about them, you could recode .z to 2, say. Or fix the program. Or write to the author, who is not usually active on Statalist.

        Comment


        • #5
          Thanks Nick for identifying the issue. Indeed when I exclude the missing values the command works.
          I really appreciate the constant assistance.

          Comment


          • #6
            Originally posted by Nick Cox View Post
            That's now a reproducible example.

            The problem is the missing values on y, which tickle a bug.

            On a quick guess, the program ignores the missing values in one place but not in another and ends strangled by an inconsistency. If you don't care about the missing values, you should exclude them explicitly, If you do care about them, you could recode .z to 2, say. Or fix the program. Or write to the author, who is not usually active on Statalist.
            I was just banging my head against this exact same bug, and this thread saved my %$$%. Thank you, Nick!

            Comment

            Working...
            X