Announcement

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

  • hbar and detection limits

    Hi all,

    Can someone assist with plotting an hbar for detection limits of different concentrations (dataex below).

    I tried using the following code to no avail: graph hbar lod, over(expt_) over(expt)

    The experiments (a,b,c) are repeated twice (before&after) and my concentrations are (200, 20, 2, 0.5, 0.25 and 0.125). I would like the detection limits "x-axis" to be inverted and appear as is (e.g not the mean etc).


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str4 expt str2 expt_ float lod
    "Pre"  "a"   20
    "Pre"  "b"   20
    "Pre"  "c"    2
    "Post" "a" .125
    "Post" "b"   .5
    "Post" "c" .125
    end

  • #2
    To invert it, I think the easiest way is through making it a numerical variable, and then label. Just make sure that the number coding for Pre is smaller than that of Post. And to for the x-axis name, you can use ytitle() to change it. (It's actually y axis because it's a rotated bar chart.)

    Code:
    gen expt2 = (expt == "Post")
    label define exp_lab 0 "Pre" 1 "Post"
    label values expt2 exp_lab
    
    graph hbar lod, over(expt_) over(expt2) ytitle("Whatever you want")

    Comment


    • #3
      Hi Ken Chui,
      Many thanks for your response. If I can add a little - the detection limits (lod) above are the lowest detected in each experiment. For example Post "a" = 0.125 means that all concentrations were detected (200, 20, 2, 0.5, 0.25 down to -> 0.125). Is there a way to plot all these in an hbar to highlight this e.g. overall x-axis starts from 200 down to 0.125 for all these?

      Comment


      • #4
        Oh, I see what you mean now. I don't know of any legit way, but you can generate a difference by subtraction from 20, and then add text labels to conceal the actual numerical labels:

        Code:
        gen lod2 = 20 - lod
        graph hbar lod2, over(expt_) over(expt) ytitle("Whatever you want") ylabel(0 "20" 5 "15" 10 "10" 15 "5" 20 "0")
        You can change the constant and the label to the desired effect, as I am still not 100% sure what is the target graph.

        Comment

        Working...
        X