Announcement

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

  • Calculating number of households within a distance of 1KM.

    My deep dive for a clue as to how to calculate the number of households within a radius of 1KM isn't bearing fruits. I want to generate a variable that counts the total number of households within a radius of a kilometre that received some sort of treatment. The variable treat in the MWE denotes 1 if treated and 0 if not.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(longitude latitude household_id) float treat
    34.3305675 -.3524537 2274277979 1
      34.33927   -.17747 1174139697 1
      34.43545   -.17373 1782151256 0
      34.34602   -.15345 1768914407 0
      34.32225    -.1086 1172131082 0
    34.2818112 -.2419943 1774195844 1
      34.28392   -.25333 1277311080 0
    34.3281687 -.3403831 2577843882 0
    34.3140773    -.3203 2977881337 0
    34.3990875   -.07502 1983108037 0
     34.341887  -.104738 1374211739 0
    34.2637026 -.2409713 1079917294 0
    34.3561487    -.1689 1778766110 0
    34.3263725 -.1769625 1382125291 1
      34.32047   -.16695 2782841008 0
    34.3359794 -.1816041 1170167096 0
    34.3406087 -.3190081 1372316820 1
    34.3139775 -.3488775 2369267856 1
    34.3830881 -.2683037 1574207405 1
    34.3312912  -.121985 1472800679 0
    end
    label values longitude dkrf
    label values latitude dkrf
    How can I generate this?

  • #2
    Within a radius of 1km from *what*? Do you mean "for each observation, the number of other observations in the dataset that are within 1 km of it and are treated"? If so, take a look at the -within- option of -ssc describe geonear-.

    Comment

    Working...
    X