Announcement

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

  • kernel density

    I am trying to make a kernel density graph with two as below. But I get the y axis from 0 to 33 instead of 0 to 0.33.

    Code:
    twoway (kdensity txmort if d_cor==1) (kdensity txmort if d_cor==0) if ano_obit==2005, ytitle("Densidade de Kernel") ///
    xtitle(tx mortalidade) legend(order(1 "corrup" 2 "nao corrup"))
    I tried to force the y axis into 0 to 1 as below, but I still get the same graph. Is it being considered in %? Who can I have it in decimals (0 up to 1)?
    Code:
    twoway (kdensity txmort if d_cor==1) (kdensity txmort if d_cor==0) if ano_obit==2005, ytitle("Densidade de Kernel") ///
    xtitle(tx mortalidade) legend(order(1 "corrup" 2 "nao corrup")) yscale(range(0 1))

  • #2
    please show us something about txmort (summarize or codebook or ...)

    Comment


    • #3
      The presumption here seems to be that a density must be between 0 and 1. Not so. This is explained in the manual entry for kdensity.

      For those who want a self-contained example: imagine a uniform distribution on [0, 0.1]. The total probability, the area under the density function, must be 1, so the density must be a constant 10. Geometrically, area of rectangle 1 = height of rectangle 10 x length of rectangle 0.1.

      Otherwise put, a probability density for a continuous variable is not a probability, but a quantity with dimensions and units that are the reciprocal and units of those of the variable in question, probability per metre, probability per mm Hg, or whatever. That's indeed why we need to talk about density in the first place. The analogy with density in physics (mass per unit volume) or in demography (population per unit area) holds good. Probability density is probability per unit of the measurement space concerned.

      (Density meaning density relative to counting measure I imagine to be irrelevant here.)

      Comment


      • #4
        ... a quantity with dimensions and units that are the reciprocal of those of the variable in question ....

        Comment


        • #5
          Thank you. Once I have the graphs, how can I know the average for each distribution? I saw that kdensity just stores:
          Code:
          r(bwidth) kernel bandwidth
          r(n) number of points at which the estimate was evaluated
          r(scale) density bin width
          r(kernel) name of kernel
          but not the average.

          Comment


          • #6
            Code:
             
            help summarize

            Comment

            Working...
            X