Announcement

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

  • Compare quantile ranges between STATA and Qgis

    I have what I assume is a fairly simple problem to solve. I am using Qgis to create maps using quantiles and would like to display the number of observations per Quantile in my legends. However, Qgis does not have an easy way to observe this, but I know that it is easy to find out using the xtile command in Stata, which I have done. What I would like to do is simply double check that the ranges Stata has calculated for the quantiles match those that Qgis is using to ensure that everything matches up.

    What I have been unable to figure out how to do is display the ranges Stata calculated for the quantiles of each of my variables. In my case I'm dividing each variable into 6 quantiles and so would like to see the 6 ranges that Stata has used to divide each variable. Is this something that I will just need to manually calculate in Stata?

    Thank you for your help.

  • #2
    Nate, the problem may be somewhat more complicated than you expect:
    https://analyse-it.com/blog/2013/2/q...calculate-them

    Perhaps you can classify the data in Stata, then just plot in in QGIS based on the assigned class.

    You may also be interested in geotools.

    Best, Sergiy

    Comment


    • #3
      Perhaps the following example will be useful.
      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      . xtile xwgt = weight, nquantiles(5) 
      
      . table xwgt, c(N weight min weight max weight)
      
      -------------------------------------------------
      5         |
      quantiles |
      of weight |   N(weight)  min(weight)  max(weight)
      ----------+--------------------------------------
              1 |          15        1,760        2,160
              2 |          15        2,200        2,730
              3 |          15        2,750        3,310
              4 |          15        3,330        3,700
              5 |          14        3,720        4,840
      -------------------------------------------------
      
      . _pctile weight, nquantiles(5)
      
      . return list
      
      scalars:
                       r(r1) =  2160
                       r(r2) =  2730
                       r(r3) =  3310
                       r(r4) =  3700
      
      .

      Comment


      • #4
        Thank you both for your responses. William, Qgis' ranges match those given by your adapted sample code, so that seems to have worked perfectly!

        Comment

        Working...
        X