Announcement

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

  • Invalid line argument, . in twoway graph

    Dear All:

    I'm trying to draw a twoway function graph, but the code always returned "invalid line argument, .r(198);"

    Here's my code

    Code:
    local b0 = _b[_cons]
    local b1 = _b[w_qacem_aff]
    local b2 = _b[w_qacem_aff2]
    sum w_qacem_aff,d
    local min:  dis %3.1f r(min)
    local max:  dis %3.1f r(max)
    local med:  dis %3.1f r(median)
    local 75:  dis %3.1f r(p75)
    local 25:  dis %3.1f r(p25)
    
    
    twoway ( function y = `b2'*x^2 + `b1'*x + `b0',range(`min' `max') ), ///
           ytitle("cpcis") xtitle("qacem_aff") ///
           xline(`min',lc(red) lw(thin)) ///
           xline($tp ,  lp(dash) lc(green)) ///
           xline(`max',lc(red) lw(thin)) ///
           xline(`med',lc(red) lw(thin)) ///
           xline(`75',lc(red) lw(thin))    ///
           xlabel(`min' "Min (`min')"  ///
                  `max' "Max (`max')", angle(50))
                  
     graph export "C:\Users\zzc\Desktop\cpcis-qacem_aff.png", replace
    And the reture message is

    HTML Code:
    . do "C:\Users\zzc\AppData\Local\Temp\STD40f8_000000.tmp"
    
    . local b0 = _b[_cons]
    
    . local b1 = _b[w_qacem_aff]
    
    . local b2 = _b[w_qacem_aff2]
    
    . sum w_qacem_aff,d
    
                 qacem_aff, Winsorized fraction .025
    -------------------------------------------------------------
          Percentiles      Smallest
     1%           20             20
     5%           21             20
    10%           23             20       Obs              21,183
    25%           26             20       Sum of Wgt.      21,183
    
    50%           30                      Mean           29.22329
                            Largest       Std. Dev.      4.275726
    75%           32             38
    90%           35             38       Variance       18.28183
    95%           37             38       Skewness      -.1288896
    99%           38             38       Kurtosis       2.696192
    
    . local min:  dis %3.1f r(min)
    
    . local max:  dis %3.1f r(max)
    
    . local med:  dis %3.1f r(median)
    
    . local 75:  dis %3.1f r(p75)
    
    . local 25:  dis %3.1f r(p25)
    
    . 
    . 
    . twoway ( function y = `b2'*x^2 + `b1'*x + `b0',range(`min' `max') ), ///
    >        ytitle("cpcis") xtitle("qacem_aff") ///
    >        xline(`min',lc(red) lw(thin)) ///
    >        xline($tp ,  lp(dash) lc(green)) ///
    >        xline(`max',lc(red) lw(thin)) ///
    >            xline(`med',lc(red) lw(thin)) ///
    >        xline(`75',lc(red) lw(thin))     ///
    >        xlabel(`min' "Min (`min')"  ///
    >               `max' "Max (`max')", angle(50))
    invalid line argument, .
    r(198);
    
    end of do-file
    
    r(198);
    I couldn't figour out any mistyping
    Where is the error line?

    Thanks in advance for your help.

  • #2
    The problem is that sum does not store r(median) as a result, so that local is empty, and the -xline(`med',lc(red) lw(thin))- substitutes to -xline(.,lc(red) lw(thin))-, where . (missing) is an invalid argument for xline. Replacing:

    Code:
    local med: dis %3.1f r(median)
    with:

    Code:
    local med:  dis %3.1f r(p50)
    should work.

    Comment


    • #3
      Originally posted by Ali Atia View Post
      The problem is that sum does not store r(median) as a result, so that local is empty, and the -xline(`med',lc(red) lw(thin))- substitutes to -xline(.,lc(red) lw(thin))-, where . (missing) is an invalid argument for xline. Replacing:

      Code:
      local med: dis %3.1f r(median)
      with:

      Code:
      local med: dis %3.1f r(p50)
      should work.
      Oh! It does work!
      Thank you very much!

      Comment

      Working...
      X