Announcement

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

  • Problem with zanthro package

    I am trying to use the zanthro package to compute Z-scores for BMI on my data. I keep getting missing values, no matter what I do. I even tried to run the command by creating randomly generated observations, but continue to get missing values for the Z-scores. See below for my code and output. Any help would be appreciated.

    Code:
    set obs 100
    gen age = float((18-8)*runiform()+5)
    gen sex = runiform()>.5
    gen bmi = float((30-18)*runiform()+18)
    egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
    (Z values can be missing because xvar is nonpositive or otherwise
     out of range for the chart code, or the gender variable is missing)
    (100 missing values generated)
    
    list in 1/10, noobs clean
    
             age   sex        bmi   zbmius  
        10.79541     1   23.27344        .  
        6.556831     0   27.80624        .  
        7.794309     0   26.47512        .  
        10.63324     0   23.09287        .  
        8.573705     1   29.12665        .  
        6.488252     1   22.14978        .  
        14.19374     0   24.28196        .  
        6.270454     0   21.03813        .  
        6.600626     0   24.17842        .  
         12.7402     0   27.19227        .
    Last edited by Koju Kumar; 17 Nov 2017, 05:52.

  • #2
    Which version of zanthro are you using? I am using

    Code:
    SJ-13-2 dm0004_1  . . . . . . .  Standardizing anthropometric measures: Update
            . . . . . . . . . . . . . . . . . S. I. Vidmar, T. J. Cole, and H. Pan
            (help zanthro, zbmicat if installed)
            Q2/13   SJ 13(2):366--378
            discusses the updated extension to the egen functions zanthro()
            and zbmicat()
    and this code works fine:

    Code:
    clear 
    set obs 100
    set seed 2803
    gen age = float((18-8)*runiform()+5)
    gen sex = runiform()>.5
    gen bmi = float((30-18)*runiform()+18)
    summarize 
    
    egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff

    Comment


    • #3
      Hmm, I am using the same version of -zanthro- as Nick is, but when I run his code, I get the same result as Koju (all missing values), including the message about xvar being nonpositive or otherwise out of range for the chart, or the gender variable being missing, though neither of those is actually true.

      Code:
      . about
      
      Stata/MP 15.1 for Windows (64-bit x86-64)
      Revision 06 Nov 2017
      Copyright 1985-2017 StataCorp LLC
      
      Total physical memory:     8269900 KB
      Available physical memory: 3400452 KB
      
      Single-user 2-core Stata perpetual license:
             Serial number:  REDACTED
               Licensed to:  Clyde Schechter
                             Albert Einstein College of Medicine
      
      . which _gzanthro
      c:\ado\plus\_\_gzanthro.ado
      *! version 1.0.2 dec2011 (SJxx-x: dmxxxx)

      Comment


      • #4
        I am using the same version of -zanthro- as Nick. Is it possible that updating to Stata 15.1 could have corrupted the -zanthro- package? Nick, what version of Stata are you using?

        Comment


        • #5

          Same here in Mac, generating missing values but runs perfect in Stata-14.2:

          Code:
          Program version: SJ-13-2 dm0004_1: Standardizing ..... for egen: Update
          
          about
          
          Stata/SE 15.1 for Mac (64-bit Intel)
          
          gen age = float((18-8)*runiform()+5)
          gen sex = runiform()>.5
          gen bmi = float((30-18)*runiform()+18)
          egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
          
          egen zbmiuk = zanthro(bmi,ba,UK), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
          
          li in 1/5, noobs
          
                 age   sex        bmi   zbmius   zbmiuk  
              8.488717     1   21.27193        .        .  
              7.668857     1   26.68737        .        .  
              6.366463     1   27.54656        .        .  
              5.285569     1   28.71009        .        .  
              13.68933     1   26.49455        .        .  
          
          
          about
          
          Stata/SE 14.2 for Mac (64-bit Intel)
          
          set obs 100
          gen age = float((18-8)*runiform()+5)
          gen sex = runiform()>.5
          gen bmi = float((30-18)*runiform()+18)
          egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
          
          egen zbmiuk = zanthro(bmi,ba,UK), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
          
          li in 1/5, clean noobs
          
                  age   sex        bmi     zbmius     zbmiuk  
              8.488717     1   21.27193   1.792401   2.245131  
              7.668857     1   26.68737   2.573981    3.60029  
              6.366463     1   27.54656    3.01705   4.300012  
              5.285569     1   28.71009   3.796029   5.007081  
              13.68933     1   26.49455   1.746595   2.301392
          Last edited by Roman Mostazir; 17 Nov 2017, 16:30. Reason: added program version
          Roman

          Comment


          • #6
            Interesting. How do we go about getting this fixed. Do the authors of the package have to take care of this?

            Comment


            • #7
              Yes, it is up to the authors to explain or resolve this. The output of
              Code:
              net describe dm0004_1
              gives an email address for support; I suggest you call this to their attention.

              Comment


              • #8
                #2 #3 #4 I should have mentioned in #2 that I was using 15.0. Now I confirm that 15.1 does appear to break this program. I had a look at the code but could not quickly see a likely specific problem.

                Comment


                • #9
                  Hello,

                  I wrote zanthro and received an email last week from a user who was unable to generate z-scores for weight-for-length and weight-for-height charts in version 15. There are also problems with *-for-age charts where age is in years. I contacted Stata Technical Support and the problem lies with the -levelsof- command used by zanthro. It uses scientific notation and does not work under version control. This behavior is a bug with -levelsof-. Stata developers are working on fixing this.The fix will probably go out in the next update, which will hopefully be in the next month or two. In the meantime, you can run zanthro in V14.2 or earlier. For anyone who doesn't have access to earlier versions of Stata, I've attached levelsof.ado from V14, which you can use when running zanthro. If copying to Stata 15's official ado directory, do this with care so that you don't overwrite the corresponding V15 ado file.

                  Thank-you Rasool, for altering me to the problem and also for your help and enthusiasm in finding a simple solution for people who don't have access to V14.

                  levelsof.ado

                  Comment


                  • #10
                    Hello,

                    As to the 13feb2018 update to Stata 15.1, this problem continues and we cannot estimate z-scores using zanthro.
                    Do you all continue to have this problem with the latest update?

                    Comment


                    • #11
                      An issue here is that the underlying data (variable __SVJCKHxmrg from "zbmiageus.dta") is stored as a float but the stored values exceeds the available precision of that storage type. For example, the before last value for __SVJCKHxmrg is listed as 72897816 but could also be 72897815:
                      Code:
                      . use "/Users/robert/Library/Application Support/Stata/ado/plus/z/zbmiageus.dta", clear
                      
                      . format %21.0g __SVJCKHxmrg
                      
                      . list __SVJCKHxmrg in 435
                      
                           +----------+
                           | __SVJC~g |
                           |----------|
                      435. | 72897816 |
                           +----------+
                      
                      . assert float(72897816) == float(72897815)
                      
                      .
                      I don't know if this matter or not in terms of the task at hand here.

                      In terms of getting this to work with Stata 15, you can also fix the program and replace the levelsof call with equivalent code. First, you must locate where the program was installed. Since this is an egen extension program, you have to look for the name with a "_g" prefix. Here's the location on my computer:
                      Code:
                      . which _gzanthro.ado
                      /Users/robert/Library/Application Support/Stata/ado/plus/_/_gzanthro.ado
                      *! version 1.0.2 dec2011 (SJxx-x: dmxxxx)
                      Copy (not just move) "_gzanthro.ado" to your PERSONAL directory or to Stata's current directory so that you can modify the code and have Stata use the fixed copy instead of the one that was installed. Here's the adopath on my computer:
                      Code:
                      . adopath
                        [1]  (BASE)      "/Applications/Stata/ado/base/"
                        [2]  (SITE)      "/Applications/Stata/ado/site/"
                        [3]              "."
                        [4]  (PERSONAL)  "/Users/robert/Library/Application Support/Stata/ado/personal/"
                        [5]  (PLUS)      "/Users/robert/Library/Application Support/Stata/ado/plus/"
                        [6]  (OLDPLACE)  "~/ado/"
                      
                      .
                      As you can see, the current directory (".") and the PERSONAL directory are searched before the PLUS directory which means that Stata will use programs found in those before those in the PLUS directory.

                      To modify the code, open the cloned version of _gzanthro.ado in Stata's editor and look for "levelsof". You will need to comment the command (using //) and add the equivalent code:
                      Code:
                          // qui levelsof __SVJCKHxmrg, local(levels)
                          bysort __SVJCKHxmrg: keep if _n == 1
                          forvalues i=1/`=_N' {
                              local s__SVJCKHxmrg = string(__SVJCKHxmrg[`i'],"%21.0g")
                              local levels `levels' `s__SVJCKHxmrg'
                          }
                      You can also add a note at the top of the file to indicate that the original has been modified. I inserted:
                      Code:
                      *! 20180215 RP: modified to replace a levelsof call with equivalent code
                      If you run the following code in Stata 15:
                      Code:
                      clear all
                      set obs 100
                      set seed 2803
                      gen age = float((18-8)*runiform()+5)
                      gen sex = runiform()>.5
                      gen bmi = float((30-18)*runiform()+18)
                      
                      dis c(stata_version)
                      which _gzanthro.ado
                      egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
                      
                      list in 1/10
                      list in 44
                      you will get
                      Code:
                      . dis c(stata_version)
                      15.1
                      
                      . which _gzanthro.ado
                      ./_gzanthro.ado
                      *! 20180215 RP: modified to replace a levelsof call with equivalent code
                      *! version 1.0.2 dec2011 (SJxx-x: dmxxxx)
                      
                      . egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
                      /Users/robert/Library/Application Support/Stata/ado/plus/z/zbmiageus.dta
                      (218 observations deleted)
                      (Z values generated for 100 cases) 
                      (gender was assumed to be coded male=1, female=0)
                      (age was assumed to be in years)
                      
                      . 
                      . list in 1/10
                      
                           +--------------------------------------+
                           |      age   sex        bmi     zbmius |
                           |--------------------------------------|
                        1. | 14.24379     1   26.45193   1.678709 |
                        2. | 8.326341     1   28.84146   2.577449 |
                        3. | 12.73969     1   24.12504   1.526559 |
                        4. | 6.040797     1   22.62419   2.663293 |
                        5. | 8.383934     1    29.0434   2.578485 |
                           |--------------------------------------|
                        6. | 5.200225     0   28.35896   3.058778 |
                        7. | 6.795591     0   23.87964   2.383226 |
                        8. | 11.26451     1   27.56687   2.123831 |
                        9. | 8.980427     1   19.09901   1.190196 |
                       10. | 8.870576     0   24.08791   2.022915 |
                           +--------------------------------------+
                      
                      . list in 44
                      
                           +---------------------------------------+
                           |      age   sex        bmi      zbmius |
                           |---------------------------------------|
                       44. | 12.30737     0   18.02794   -.0909101 |
                           +---------------------------------------+
                      
                      .
                      which matches the results you get if you run the same example under Stata 14.2:
                      Code:
                      . dis c(stata_version)
                      14.2
                      
                      . which _gzanthro.ado
                      /Users/robert/Library/Application Support/Stata/ado/plus/_/_gzanthro.ado
                      *! version 1.0.2 dec2011 (SJxx-x: dmxxxx)
                      
                      . egen zbmius = zanthro(bmi,ba,US), xvar(age) gender(sex) gencode(male=1, female=0) ageunit(year) nocutoff
                      (Z values generated for 100 cases) 
                      (gender was assumed to be coded male=1, female=0)
                      (age was assumed to be in years)
                      
                      . 
                      . list in 1/10
                      
                           +--------------------------------------+
                           |      age   sex        bmi     zbmius |
                           |--------------------------------------|
                        1. | 14.24379     1   26.45193   1.678709 |
                        2. | 8.326341     1   28.84146   2.577449 |
                        3. | 12.73969     1   24.12504   1.526559 |
                        4. | 6.040797     1   22.62419   2.663293 |
                        5. | 8.383934     1    29.0434   2.578485 |
                           |--------------------------------------|
                        6. | 5.200225     0   28.35896   3.058778 |
                        7. | 6.795591     0   23.87964   2.383226 |
                        8. | 11.26451     1   27.56687   2.123831 |
                        9. | 8.980427     1   19.09901   1.190196 |
                       10. | 8.870576     0   24.08791   2.022915 |
                           +--------------------------------------+
                      
                      . list in 44
                      
                           +---------------------------------------+
                           |      age   sex        bmi      zbmius |
                           |---------------------------------------|
                       44. | 12.30737     0   18.02794   -.0909101 |
                           +---------------------------------------+
                      
                      .

                      Comment


                      • #12
                        Thank you Robert.
                        It worked perfectly

                        Comment


                        • #13
                          An update
                          The 08mar2018 Stata 15.1 update seemed to have solved the problem for me.
                          Could others confirm this is also true for you.
                          Many thanks

                          Comment


                          • #14
                            It now works for me. Stata 15.1 MP2 Windows 7.

                            Comment


                            • #15
                              Hi,

                              It works as follow with the message:
                              //egen WLZ_WHO=zanthro(weight,wl,WHO), xvar(height) gender(gender) gencode(male=1, fem
                              > //ale=2) nocutoff
                              //(Z values generated for 3927 cases)
                              //(gender was assumed to be coded male=1, female=2)
                              //(Z values can be missing because xvar is nonpositive or otherwise
                              //out of range for the chart code, or the gender variable is missing)
                              //(9257 missing values generated)//


                              Is there away how I can further define the variable height, for children 24months as length between 45-100cm and 65-200cm as said by WHO.
                              How can I modify the code with [if] and [in] as suggested in stata journal?

                              Comment

                              Working...
                              X