Announcement

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

  • Error message - "_b not allowed when e(b) is not present"

    Hi,

    I am trying to run the following formula for a risk prediction tool that has been developed by another author (developed in R but they have provided me with this transcribed formula to Stata language):


    gen modellab = -6.7922721 + 0.044744302*AGE + 0.32961593*(WHR*10) + 0.19860813*ALCOHOL ///

    - 0.0082096868*(max((ALCOHOL-0.1), 0))^3 + 0.010575035*(max((ALCOHOL-1), 0))^3 ///

    - 0.002004756*(max((ALCOHOL-3), 0))^3 - 0.00033998925*(max((ALCOHOL-9), 0))^3 ///

    - 2.0602882e-05*(max((ALCOHOL-33), 0))^3 + 0.011813962*GGT ///

    + 0.18721469*(SEX == 2) + 0.55249734*(DIABETES == 1) + 0.74679941*(SMOKING == 1) ///

    + 0.0054325769*GGT*(SEX == 2) - 0.64903176*(SEX == 2)*(SMOKING == 1)

    Whereby;
    AGE in years (40-70 years old only)
    WHR = waist-hip ratio
    ALCOHOL = grams per week consumed (if >500 = 500)
    GGT = gamma glutamyl transferase (if >200 = 200)
    SEX = 1 (male) / 2 (female)
    DIABETES = 1 (yes) / 0 (no)
    SMOKING = 1 (current) / 2 (never/ex-)

    However, when I try to run this the following error message returns "_b not allowed when e(b) is not present" - but I am not sure what this error refers to nor how to troubleshoot it.

    Any ideas?
    Thanks


  • #2
    If your actual code has two hard returns after each /// try using just one. I.e. instead of

    Code:
    gen modellab = -6.7922721 + 0.044744302*AGE + 0.32961593*(WHR*10) + 0.19860813*ALCOHOL ///
    
    - 0.0082096868*(max((ALCOHOL-0.1), 0))^3 + 0.010575035*(max((ALCOHOL-1), 0))^3 ///
    
    - 0.002004756*(max((ALCOHOL-3), 0))^3 - 0.00033998925*(max((ALCOHOL-9), 0))^3 ///
    
    - 2.0602882e-05*(max((ALCOHOL-33), 0))^3 + 0.011813962*GGT ///
    
    + 0.18721469*(SEX == 2) + 0.55249734*(DIABETES == 1) + 0.74679941*(SMOKING == 1) ///
    
    + 0.0054325769*GGT*(SEX == 2) - 0.64903176*(SEX == 2)*(SMOKING == 1)
    try using

    Code:
    gen modellab = -6.7922721 + 0.044744302*AGE + 0.32961593*(WHR*10) + 0.19860813*ALCOHOL ///
    - 0.0082096868*(max((ALCOHOL-0.1), 0))^3 + 0.010575035*(max((ALCOHOL-1), 0))^3 ///
    - 0.002004756*(max((ALCOHOL-3), 0))^3 - 0.00033998925*(max((ALCOHOL-9), 0))^3 ///
    - 2.0602882e-05*(max((ALCOHOL-33), 0))^3 + 0.011813962*GGT ///
    + 0.18721469*(SEX == 2) + 0.55249734*(DIABETES == 1) + 0.74679941*(SMOKING == 1) ///
    + 0.0054325769*GGT*(SEX == 2) - 0.64903176*(SEX == 2)*(SMOKING == 1)

    Comment

    Working...
    X