
  ___  ____  ____  ____  ____ (R)
 /__    /   ____/   /   ____/
___/   /   /___/   /   /___/   12.1   Copyright 1985-2011 StataCorp LP
  Statistics/Data Analysis            StataCorp
                                      4905 Lakeway Drive
     MP - Parallel Edition            College Station, Texas 77845 USA
                                      800-STATA-PC        http://www.stata.com
                                      979-696-4600        stata@stata.com
                                      979-696-4601 (fax)

6-user 24-core Stata network perpetual license:
       Serial number:  50120578242
         Licensed to:  Wellesley College
                       Wellesley, MA

Notes:
      1.  (-v# option or -set maxvar-) 5000 maximum variables
      2.  Command line editing disabled
      3.  Stata running in batch mode

Note:  Welcome to the Multi-Core installation of Stata on stata.wellesley.edu

. do A14_simulatearsenicmeasures.do 

. clear

. set more off

. set mem 1g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are
    performed on the fly automatically.

. # delimit ;
delimiter now ;
. /****************************************************************************
> *************************************;
> **This dofile calculates the 'simulated' grid measures of arsenic contaminati
> on and generates hh_simulatedmindistance_YYYY;
> pre-generated datasets this dofile uses:
> hhXwelldata_uncontaminated_YYYY
> hhXwelldata_contaminated_YYYY
> 
> *****************************************************************************
> ************************************/;
. *****************************************************************************
> ************************************;
. *Paths;
. *****************************************************************************
> ************************************;
. *access files in subdirectory generated by data creating dofiles;
. local indatasetU "dtafiles/hhXwelldata_uncontaminated";

. local indatasetC "dtafiles/hhXwelldata_contaminated";

. *local interdataset "dtafiles/hh_simulatedmindistance_temp";
. local outdataset "dtafiles/hh_simulatedmindistance";

. local path=subinstr(c(pwd),"Documents","Dropbox\BF\data replication",.);

. cap cd "`path'";

. cap cd "C:\Users\gshastry\Dropbox\BF\data replication";

. *****************************************************************************
> ************************************;
. *Main
> *****************************************************************************
> ************************************;
. *install necessary ado files;
. ssc inst _gwtmean, replace;
checking _gwtmean consistency and verifying not already installed...
all files already exist and are up to date.

. foreach YYYY in 1999 2004 2007 {;
  2. use "`indatasetU'_`YYYY'", clear;
  3. *mathematically, only need to add wells within X+10.1 miles of the cluster
>  center;
. *where X is the distance from the cluster center to the closest uncontaminate
> d well (call it well A);
. *this way, point on other side of cluster is closer to the well A (distance X
> +5) than it is to;
. *any potential wells just outside the radius (distance X+10.1-5);
. egen mindistance=min(distance), by(dhsid);
  4. drop if distance>max(15.1,mindistance+10.1);
  5. for var lathhid-arsenic: rename X XU;
  6. bysort dhsid: gen count=_n;
  7. sum count;
  8. local maxwellU=r(max);
  9. drop distance mindistance;
 10. reshape wide wellcountU latwellU longwellU arsenicU, i(dhsid) j(count);
 11. order dhsid lathhid longhhid;
 12. count;
 13. local numU=r(N);
 14. gen clusternum=_n;
 15. sort clusternum;
 16. tempfile U;
 17. save `U', replace;
 18. use "`indatasetC'_`YYYY'", clear;
 19. *mathematically, only need to add wells within X+10.1 miles of the cluster
>  center;
. *where X is the distance from the cluster center to the closest uncontaminate
> d well (call it well A);
. *this way, point on other side of cluster is closer to the well A (distance X
> +5) than it is to;
. *any potential wells just outside the radius (distance X+10.1-5);
. egen mindistance=min(distance), by(dhsid);
 20. drop if distance>max(15.1,mindistance+10.1);
 21. for var lathhid-arsenic: rename X XC;
 22. bysort dhsid: gen count=_n;
 23. sum count;
 24. local maxwellC=r(max);
 25. drop distance mindistance;
 26. reshape wide wellcountC latwellC longwellC arsenicC, i(dhsid) j(count);
 27. order dhsid lathhid longhhid;
 28. count;
 29. local numC=r(N);
 30. gen clusternum=_n;
 31. sort clusternum;
 32. tempfile C;
 33. save `C', replace;
 34. ** code is written assuming numC = numU - need to fix if not true;
. assert `numC'==`numU';
 35. *** generate a grid of points;
. clear;
 36. local oneside=114;
 37. set obs `oneside';
 38. gen x=-1+2*(_n-1)/(sqrt(_N*_N)-1);
 39. expand `oneside';
 40. sort x;
 41. gen y=-1+2*(mod(_n,sqrt(_N))+sqrt(_N)*(mod(_n,sqrt(_N))==0)-1)/(sqrt(_N)-1
> );
 42. gen distance=sqrt((x-x[_n-1])^2+(y-y[_n-1])^2) if mod(_n,sqrt(_N))!=1;
 43. gen distance2=sqrt((x-x[_n-sqrt(_N)])^2+(y-y[_n-sqrt(_N)])^2);
 44. sum dis*;
 45. drop dis*;
 46. gen distance=sqrt(x^2+y^2);
 47. drop if distance>1;
 48. drop distance;
 49. count;
 50. local numgrid=r(N);
 51. gen point=_n;
 52. sort point;
 53. expand `numU';
 54. bysort point: gen clusternum=_n;
 55. merge m:1 clusternum using `U';
 56. assert _m==3;
 57.  drop _m;
 58. gen pointlatU=lathhidU+x*5/69.11;
 59. gen pointlongU=longhhidU+y*5/(69.11*cos(lathhidU*_pi/180));
 60. vincenty pointlat pointlong lathhid longhhid, h(distance_clusterU);
 61.  forvalues i=1(1)`maxwellU' {;
 62.         di "`i' of `maxwellU'";
 63.         vincenty pointlat pointlong latwellU`i' longwellU`i', h(distance_w
> ellU`i');
 64. };
 65. egen mindistanceU_grid=rmin(distance_wellU*);
 66. gen invdistanceU=1/distance_cluster;
 67. egen mean_mindistanceU=mean(mindistanceU_grid), by(dhsid);
 68. egen wmean_mindistanceU=wtmean(mindistanceU_grid), weight(invdistance) by(
> dhsid);
 69. gen mindistanceU_1=mindistanceU_grid<=1 if mindistanceU_grid!=.;
 70. egen fraction_mindistanceU_1m=mean(mindistanceU_1), by(dhsid);
 71. egen wfraction_mindistanceU_1m=wtmean(mindistanceU_1), weight(invdistance)
>  by(dhsid);
 72. ** do the same with contaminated;
. merge m:1 clusternum using `C';
 73. assert _m==3;
 74.  drop _m;
 75. gen pointlatC=lathhidC+x*5/69.11;
 76. gen pointlongC=longhhidC+y*5/(69.11*cos(lathhidC*_pi/180));
 77. vincenty pointlatC pointlongC lathhidC longhhidC, h(distance_clusterC);
 78.  forvalues i=1(1)`maxwellC' {;
 79.         di "`i' of `maxwellC'";
 80.         vincenty pointlatC pointlongC latwellC`i' longwellC`i', h(distance
> _wellC`i');
 81. };
 82. egen mindistanceC_grid=rmin(distance_wellC*);
 83. gen mindistanceC_1=mindistanceC_grid<=1 if mindistanceC_grid!=.;
 84. egen fraction_mindistanceC_1m=mean(mindistanceC_1), by(dhsid);
 85. egen wfraction_mindistanceC_1m=wtmean(mindistanceC_1), weight(invdistance)
>  by(dhsid);
 86. ** distance between point and cluster shouldn't depend on whether well is 
> C or U;
. assert distance_clusterU==distance_clusterC;
 87. compress;
 88. keep dhsid mean_* wmean_* fraction* wfraction*;
 89. label variable mean_mindistanceU "Average Distance to Closest Uncontaminat
> ed Well";
 90. label variable wmean_mindistanceU "Weighted Average Distance to Closest Un
> contaminated Well";
 91. label variable fraction_mindistanceU_1m "Fraction of Points within 1 m of 
> Uncontaminated Well";
 92. label variable wfraction_mindistanceU_1m "Weighted Fraction of Points with
> in 1 m of Uncontaminated Well";
 93. label variable fraction_mindistanceC_1m "Fraction of Points within 1 m of 
> Contaminated Well";
 94. label variable wfraction_mindistanceC_1m "Weighted Fraction of Points with
> in 1 m of Contaminated Well";
 95. duplicates drop;
 96. sort dhsid;
 97. save "`outdataset'_`YYYY'_grid", replace;
 98. };
(89312 observations deleted)

->  rename lathhid lathhidU

->  rename longhhid longhhidU

->  rename wellcount wellcountU

->  rename latwell latwellU

->  rename longwell longwellU

->  rename arsenic arsenicU

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |     13098    23.51451    16.14358          1         85
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 
> 78 79 80 81 82 83 84 85)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                    13098   ->     341
Number of variables                   8   ->     343
j variable (85 values)            count   ->   (dropped)
xij variables:
                             wellcountU   ->   wellcountU1 wellcountU2 ... well
> countU85
                               latwellU   ->   latwellU1 latwellU2 ... latwellU
> 85
                              longwellU   ->   longwellU1 longwellU2 ... longwe
> llU85
                               arsenicU   ->   arsenicU1 arsenicU2 ... arsenicU
> 85
-----------------------------------------------------------------------------
  341
(note: file /tmp/St13161.000001 not found)
file /tmp/St13161.000001 saved
(51623 observations deleted)

->  rename lathhid lathhidC

->  rename longhhid longhhidC

->  rename wellcount wellcountC

->  rename latwell latwellC

->  rename longwell longwellC

->  rename arsenic arsenicC

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |      5907    15.75233    12.68407          1         61
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                     5907   ->     341
Number of variables                   8   ->     247
j variable (61 values)            count   ->   (dropped)
xij variables:
                             wellcountC   ->   wellcountC1 wellcountC2 ... well
> countC61
                               latwellC   ->   latwellC1 latwellC2 ... latwellC
> 61
                              longwellC   ->   longwellC1 longwellC2 ... longwe
> llC61
                               arsenicC   ->   arsenicC1 arsenicC2 ... arsenicC
> 61
-----------------------------------------------------------------------------
  341
(note: file /tmp/St13161.000002 not found)
file /tmp/St13161.000002 saved
obs was 0, now 114
(12882 observations created)
(114 missing values generated)
(114 missing values generated)

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    distance |     12882    .0176991    1.49e-08   .0176991   .0176991
   distance2 |     12882    .0176991    1.49e-08   .0176991   .0176991
(2996 observations deleted)
10000
(3400000 observations created)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,410,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 85
Finished in 95 iterations
2 of 85
Finished in 95 iterations
3 of 85
Finished in 95 iterations
4 of 85
Finished in 95 iterations
5 of 85
Finished in 95 iterations
6 of 85
Finished in 95 iterations
7 of 85
Finished in 95 iterations
8 of 85
Finished in 95 iterations
9 of 85
Finished in 95 iterations
10 of 85
Finished in 95 iterations
11 of 85
Finished in 95 iterations
12 of 85
Finished in 95 iterations
13 of 85
Finished in 95 iterations
14 of 85
Finished in 95 iterations
15 of 85
Finished in 95 iterations
16 of 85
Finished in 95 iterations
17 of 85
Finished in 95 iterations
18 of 85
Finished in 95 iterations
19 of 85
Finished in 95 iterations
20 of 85
Finished in 95 iterations
21 of 85
Finished in 95 iterations
22 of 85
Finished in 95 iterations
23 of 85
Finished in 95 iterations
24 of 85
Finished in 95 iterations
25 of 85
Finished in 95 iterations
26 of 85
Finished in 95 iterations
27 of 85
Finished in 95 iterations
28 of 85
Finished in 95 iterations
29 of 85
Finished in 95 iterations
30 of 85
Finished in 95 iterations
31 of 85
Finished in 95 iterations
32 of 85
Finished in 95 iterations
33 of 85
Finished in 95 iterations
34 of 85
Finished in 95 iterations
35 of 85
Finished in 95 iterations
36 of 85
Finished in 95 iterations
37 of 85
Finished in 95 iterations
38 of 85
Finished in 95 iterations
39 of 85
Finished in 95 iterations
40 of 85
Finished in 95 iterations
41 of 85
Finished in 95 iterations
42 of 85
Finished in 95 iterations
43 of 85
Finished in 95 iterations
44 of 85
Finished in 95 iterations
45 of 85
Finished in 95 iterations
46 of 85
Finished in 95 iterations
47 of 85
Finished in 95 iterations
48 of 85
Finished in 95 iterations
49 of 85
Finished in 95 iterations
50 of 85
Finished in 95 iterations
51 of 85
Finished in 95 iterations
52 of 85
Finished in 95 iterations
53 of 85
Finished in 95 iterations
54 of 85
Finished in 95 iterations
55 of 85
Finished in 95 iterations
56 of 85
Finished in 95 iterations
57 of 85
Finished in 95 iterations
58 of 85
Finished in 95 iterations
59 of 85
Finished in 95 iterations
60 of 85
Finished in 95 iterations
61 of 85
Finished in 95 iterations
62 of 85
Finished in 95 iterations
63 of 85
Finished in 95 iterations
64 of 85
Finished in 95 iterations
65 of 85
Finished in 95 iterations
66 of 85
Finished in 95 iterations
67 of 85
Finished in 96 iterations
68 of 85
Finished in 95 iterations
69 of 85
Finished in 95 iterations
70 of 85
Finished in 95 iterations
71 of 85
Finished in 95 iterations
72 of 85
Finished in 95 iterations
73 of 85
Finished in 96 iterations
74 of 85
Finished in 95 iterations
75 of 85
Finished in 95 iterations
76 of 85
Finished in 95 iterations
77 of 85
Finished in 96 iterations
78 of 85
Finished in 96 iterations
79 of 85
Finished in 95 iterations
80 of 85
Finished in 95 iterations
81 of 85
Finished in 95 iterations
82 of 85
Finished in 95 iterations
83 of 85
Finished in 95 iterations
84 of 85
Finished in 95 iterations
85 of 85
Finished in 96 iterations

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,410,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 61
Finished in 95 iterations
2 of 61
Finished in 95 iterations
3 of 61
Finished in 95 iterations
4 of 61
Finished in 95 iterations
5 of 61
Finished in 95 iterations
6 of 61
Finished in 95 iterations
7 of 61
Finished in 95 iterations
8 of 61
Finished in 95 iterations
9 of 61
Finished in 95 iterations
10 of 61
Finished in 95 iterations
11 of 61
Finished in 95 iterations
12 of 61
Finished in 95 iterations
13 of 61
Finished in 95 iterations
14 of 61
Finished in 95 iterations
15 of 61
Finished in 95 iterations
16 of 61
Finished in 95 iterations
17 of 61
Finished in 95 iterations
18 of 61
Finished in 95 iterations
19 of 61
Finished in 95 iterations
20 of 61
Finished in 95 iterations
21 of 61
Finished in 95 iterations
22 of 61
Finished in 95 iterations
23 of 61
Finished in 95 iterations
24 of 61
Finished in 95 iterations
25 of 61
Finished in 95 iterations
26 of 61
Finished in 95 iterations
27 of 61
Finished in 95 iterations
28 of 61
Finished in 95 iterations
29 of 61
Finished in 95 iterations
30 of 61
Finished in 95 iterations
31 of 61
Finished in 95 iterations
32 of 61
Finished in 95 iterations
33 of 61
Finished in 95 iterations
34 of 61
Finished in 95 iterations
35 of 61
Finished in 95 iterations
36 of 61
Finished in 95 iterations
37 of 61
Finished in 95 iterations
38 of 61
Finished in 95 iterations
39 of 61
Finished in 95 iterations
40 of 61
Finished in 95 iterations
41 of 61
Finished in 95 iterations
42 of 61
Finished in 95 iterations
43 of 61
Finished in 95 iterations
44 of 61
Finished in 95 iterations
45 of 61
Finished in 95 iterations
46 of 61
Finished in 95 iterations
47 of 61
Finished in 95 iterations
48 of 61
Finished in 95 iterations
49 of 61
Finished in 95 iterations
50 of 61
Finished in 96 iterations
51 of 61
Finished in 96 iterations
52 of 61
Finished in 95 iterations
53 of 61
Finished in 95 iterations
54 of 61
Finished in 96 iterations
55 of 61
Finished in 95 iterations
56 of 61
Finished in 96 iterations
57 of 61
Finished in 95 iterations
58 of 61
Finished in 96 iterations
59 of 61
Finished in 96 iterations
60 of 61
Finished in 95 iterations
61 of 61
Finished in 96 iterations
point was float now int
clusternum was float now int
arsenicU79 was float now byte
arsenicU83 was float now byte
mindistanceU_1 was float now byte
arsenicC51 was float now int
arsenicC53 was float now int
arsenicC55 was float now int
arsenicC56 was float now int
arsenicC57 was float now int
arsenicC58 was float now int
arsenicC59 was float now int
arsenicC60 was float now int
arsenicC61 was float now int
mindistanceC_1 was float now byte

Duplicates in terms of all variables

(3409659 observations deleted)
file dtafiles/hh_simulatedmindistance_1999_grid.dta saved
(94225 observations deleted)

->  rename lathhid lathhidU

->  rename longhhid longhhidU

->  rename wellcount wellcountU

->  rename latwell latwellU

->  rename longwell longwellU

->  rename arsenic arsenicU

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |     14265    24.10025    16.31145          1         87
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 
> 78 79 80 81 82 83 84 85 86 87)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                    14265   ->     359
Number of variables                   8   ->     351
j variable (87 values)            count   ->   (dropped)
xij variables:
                             wellcountU   ->   wellcountU1 wellcountU2 ... well
> countU87
                               latwellU   ->   latwellU1 latwellU2 ... latwellU
> 87
                              longwellU   ->   longwellU1 longwellU2 ... longwe
> llU87
                               arsenicU   ->   arsenicU1 arsenicU2 ... arsenicU
> 87
-----------------------------------------------------------------------------
  359
(note: file /tmp/St13161.000003 not found)
file /tmp/St13161.000003 saved
(48293 observations deleted)

->  rename lathhid lathhidC

->  rename longhhid longhhidC

->  rename wellcount wellcountC

->  rename latwell latwellC

->  rename longwell longwellC

->  rename arsenic arsenicC

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |      5756    15.34833    12.87709          1         65
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61 62 63 64 65)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                     5756   ->     359
Number of variables                   8   ->     263
j variable (65 values)            count   ->   (dropped)
xij variables:
                             wellcountC   ->   wellcountC1 wellcountC2 ... well
> countC65
                               latwellC   ->   latwellC1 latwellC2 ... latwellC
> 65
                              longwellC   ->   longwellC1 longwellC2 ... longwe
> llC65
                               arsenicC   ->   arsenicC1 arsenicC2 ... arsenicC
> 65
-----------------------------------------------------------------------------
  359
(note: file /tmp/St13161.000004 not found)
file /tmp/St13161.000004 saved
obs was 0, now 114
(12882 observations created)
(114 missing values generated)
(114 missing values generated)

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    distance |     12882    .0176991    1.49e-08   .0176991   .0176991
   distance2 |     12882    .0176991    1.49e-08   .0176991   .0176991
(2996 observations deleted)
10000
(3580000 observations created)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,590,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 87
Finished in 95 iterations
2 of 87
Finished in 95 iterations
3 of 87
Finished in 95 iterations
4 of 87
Finished in 95 iterations
5 of 87
Finished in 95 iterations
6 of 87
Finished in 95 iterations
7 of 87
Finished in 95 iterations
8 of 87
Finished in 95 iterations
9 of 87
Finished in 95 iterations
10 of 87
Finished in 95 iterations
11 of 87
Finished in 95 iterations
12 of 87
Finished in 95 iterations
13 of 87
Finished in 95 iterations
14 of 87
Finished in 95 iterations
15 of 87
Finished in 95 iterations
16 of 87
Finished in 95 iterations
17 of 87
Finished in 95 iterations
18 of 87
Finished in 95 iterations
19 of 87
Finished in 95 iterations
20 of 87
Finished in 95 iterations
21 of 87
Finished in 95 iterations
22 of 87
Finished in 95 iterations
23 of 87
Finished in 95 iterations
24 of 87
Finished in 95 iterations
25 of 87
Finished in 95 iterations
26 of 87
Finished in 95 iterations
27 of 87
Finished in 95 iterations
28 of 87
Finished in 95 iterations
29 of 87
Finished in 95 iterations
30 of 87
Finished in 95 iterations
31 of 87
Finished in 95 iterations
32 of 87
Finished in 95 iterations
33 of 87
Finished in 95 iterations
34 of 87
Finished in 95 iterations
35 of 87
Finished in 95 iterations
36 of 87
Finished in 95 iterations
37 of 87
Finished in 95 iterations
38 of 87
Finished in 95 iterations
39 of 87
Finished in 95 iterations
40 of 87
Finished in 95 iterations
41 of 87
Finished in 95 iterations
42 of 87
Finished in 95 iterations
43 of 87
Finished in 95 iterations
44 of 87
Finished in 95 iterations
45 of 87
Finished in 95 iterations
46 of 87
Finished in 95 iterations
47 of 87
Finished in 95 iterations
48 of 87
Finished in 95 iterations
49 of 87
Finished in 95 iterations
50 of 87
Finished in 95 iterations
51 of 87
Finished in 95 iterations
52 of 87
Finished in 95 iterations
53 of 87
Finished in 95 iterations
54 of 87
Finished in 95 iterations
55 of 87
Finished in 95 iterations
56 of 87
Finished in 95 iterations
57 of 87
Finished in 95 iterations
58 of 87
Finished in 95 iterations
59 of 87
Finished in 95 iterations
60 of 87
Finished in 95 iterations
61 of 87
Finished in 95 iterations
62 of 87
Finished in 95 iterations
63 of 87
Finished in 95 iterations
64 of 87
Finished in 95 iterations
65 of 87
Finished in 95 iterations
66 of 87
Finished in 95 iterations
67 of 87
Finished in 95 iterations
68 of 87
Finished in 95 iterations
69 of 87
Finished in 96 iterations
70 of 87
Finished in 95 iterations
71 of 87
Finished in 95 iterations
72 of 87
Finished in 95 iterations
73 of 87
Finished in 96 iterations
74 of 87
Finished in 95 iterations
75 of 87
Finished in 96 iterations
76 of 87
Finished in 96 iterations
77 of 87
Finished in 96 iterations
78 of 87
Finished in 96 iterations
79 of 87
Finished in 96 iterations
80 of 87
Finished in 96 iterations
81 of 87
Finished in 96 iterations
82 of 87
Finished in 96 iterations
83 of 87
Finished in 95 iterations
84 of 87
Finished in 96 iterations
85 of 87
Finished in 96 iterations
86 of 87
Finished in 96 iterations
87 of 87
Finished in 96 iterations

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,590,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 65
Finished in 95 iterations
2 of 65
Finished in 95 iterations
3 of 65
Finished in 95 iterations
4 of 65
Finished in 95 iterations
5 of 65
Finished in 95 iterations
6 of 65
Finished in 95 iterations
7 of 65
Finished in 95 iterations
8 of 65
Finished in 95 iterations
9 of 65
Finished in 95 iterations
10 of 65
Finished in 95 iterations
11 of 65
Finished in 95 iterations
12 of 65
Finished in 95 iterations
13 of 65
Finished in 95 iterations
14 of 65
Finished in 95 iterations
15 of 65
Finished in 95 iterations
16 of 65
Finished in 95 iterations
17 of 65
Finished in 95 iterations
18 of 65
Finished in 95 iterations
19 of 65
Finished in 95 iterations
20 of 65
Finished in 95 iterations
21 of 65
Finished in 95 iterations
22 of 65
Finished in 95 iterations
23 of 65
Finished in 95 iterations
24 of 65
Finished in 95 iterations
25 of 65
Finished in 95 iterations
26 of 65
Finished in 95 iterations
27 of 65
Finished in 95 iterations
28 of 65
Finished in 95 iterations
29 of 65
Finished in 95 iterations
30 of 65
Finished in 95 iterations
31 of 65
Finished in 95 iterations
32 of 65
Finished in 95 iterations
33 of 65
Finished in 95 iterations
34 of 65
Finished in 95 iterations
35 of 65
Finished in 95 iterations
36 of 65
Finished in 95 iterations
37 of 65
Finished in 95 iterations
38 of 65
Finished in 95 iterations
39 of 65
Finished in 95 iterations
40 of 65
Finished in 95 iterations
41 of 65
Finished in 95 iterations
42 of 65
Finished in 95 iterations
43 of 65
Finished in 95 iterations
44 of 65
Finished in 95 iterations
45 of 65
Finished in 95 iterations
46 of 65
Finished in 95 iterations
47 of 65
Finished in 95 iterations
48 of 65
Finished in 95 iterations
49 of 65
Finished in 95 iterations
50 of 65
Finished in 95 iterations
51 of 65
Finished in 95 iterations
52 of 65
Finished in 95 iterations
53 of 65
Finished in 95 iterations
54 of 65
Finished in 95 iterations
55 of 65
Finished in 95 iterations
56 of 65
Finished in 95 iterations
57 of 65
Finished in 95 iterations
58 of 65
Finished in 96 iterations
59 of 65
Finished in 96 iterations
60 of 65
Finished in 96 iterations
61 of 65
Finished in 96 iterations
62 of 65
Finished in 96 iterations
63 of 65
Finished in 96 iterations
64 of 65
Finished in 96 iterations
65 of 65
Finished in 96 iterations
point was float now int
clusternum was float now int
longwellU83 was float now byte
mindistanceU_1 was float now byte
arsenicC53 was float now int
arsenicC54 was float now int
arsenicC55 was float now int
arsenicC56 was float now int
arsenicC57 was float now int
arsenicC58 was float now int
arsenicC59 was float now int
arsenicC60 was float now int
arsenicC61 was float now int
arsenicC64 was float now int
arsenicC65 was float now int
mindistanceC_1 was float now byte

Duplicates in terms of all variables

(3589641 observations deleted)
file dtafiles/hh_simulatedmindistance_2004_grid.dta saved
(37049 observations deleted)

->  rename lathhid lathhidU

->  rename longhhid longhhidU

->  rename wellcount wellcountU

->  rename latwell latwellU

->  rename longwell longwellU

->  rename arsenic arsenicU

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |     14176    23.73321       16.16          1         75
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                    14176   ->     361
Number of variables                   8   ->     303
j variable (75 values)            count   ->   (dropped)
xij variables:
                             wellcountU   ->   wellcountU1 wellcountU2 ... well
> countU75
                               latwellU   ->   latwellU1 latwellU2 ... latwellU
> 75
                              longwellU   ->   longwellU1 longwellU2 ... longwe
> llU75
                               arsenicU   ->   arsenicU1 arsenicU2 ... arsenicU
> 75
-----------------------------------------------------------------------------
  361
(note: file /tmp/St13161.000005 not found)
file /tmp/St13161.000005 saved
(29560 observations deleted)

->  rename lathhid lathhidC

->  rename longhhid longhhidC

->  rename wellcount wellcountC

->  rename latwell latwellC

->  rename longwell longwellC

->  rename arsenic arsenicC

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       count |      5768    15.07576    12.33753          1         66
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
>  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5
> 2 53 54 55 56 57 58 59 60 61 62 63 64 65 66)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                     5768   ->     361
Number of variables                   8   ->     267
j variable (66 values)            count   ->   (dropped)
xij variables:
                             wellcountC   ->   wellcountC1 wellcountC2 ... well
> countC66
                               latwellC   ->   latwellC1 latwellC2 ... latwellC
> 66
                              longwellC   ->   longwellC1 longwellC2 ... longwe
> llC66
                               arsenicC   ->   arsenicC1 arsenicC2 ... arsenicC
> 66
-----------------------------------------------------------------------------
  361
(note: file /tmp/St13161.000006 not found)
file /tmp/St13161.000006 saved
obs was 0, now 114
(12882 observations created)
(114 missing values generated)
(114 missing values generated)

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    distance |     12882    .0176991    1.49e-08   .0176991   .0176991
   distance2 |     12882    .0176991    1.49e-08   .0176991   .0176991
(2996 observations deleted)
10000
(3600000 observations created)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,610,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 75
Finished in 95 iterations
2 of 75
Finished in 95 iterations
3 of 75
Finished in 95 iterations
4 of 75
Finished in 95 iterations
5 of 75
Finished in 95 iterations
6 of 75
Finished in 95 iterations
7 of 75
Finished in 95 iterations
8 of 75
Finished in 95 iterations
9 of 75
Finished in 95 iterations
10 of 75
Finished in 95 iterations
11 of 75
Finished in 95 iterations
12 of 75
Finished in 95 iterations
13 of 75
Finished in 95 iterations
14 of 75
Finished in 95 iterations
15 of 75
Finished in 95 iterations
16 of 75
Finished in 95 iterations
17 of 75
Finished in 95 iterations
18 of 75
Finished in 95 iterations
19 of 75
Finished in 95 iterations
20 of 75
Finished in 95 iterations
21 of 75
Finished in 95 iterations
22 of 75
Finished in 95 iterations
23 of 75
Finished in 95 iterations
24 of 75
Finished in 95 iterations
25 of 75
Finished in 95 iterations
26 of 75
Finished in 95 iterations
27 of 75
Finished in 95 iterations
28 of 75
Finished in 95 iterations
29 of 75
Finished in 95 iterations
30 of 75
Finished in 95 iterations
31 of 75
Finished in 95 iterations
32 of 75
Finished in 95 iterations
33 of 75
Finished in 95 iterations
34 of 75
Finished in 95 iterations
35 of 75
Finished in 95 iterations
36 of 75
Finished in 95 iterations
37 of 75
Finished in 95 iterations
38 of 75
Finished in 95 iterations
39 of 75
Finished in 95 iterations
40 of 75
Finished in 95 iterations
41 of 75
Finished in 95 iterations
42 of 75
Finished in 95 iterations
43 of 75
Finished in 95 iterations
44 of 75
Finished in 95 iterations
45 of 75
Finished in 95 iterations
46 of 75
Finished in 95 iterations
47 of 75
Finished in 95 iterations
48 of 75
Finished in 95 iterations
49 of 75
Finished in 95 iterations
50 of 75
Finished in 95 iterations
51 of 75
Finished in 95 iterations
52 of 75
Finished in 95 iterations
53 of 75
Finished in 95 iterations
54 of 75
Finished in 95 iterations
55 of 75
Finished in 95 iterations
56 of 75
Finished in 95 iterations
57 of 75
Finished in 95 iterations
58 of 75
Finished in 95 iterations
59 of 75
Finished in 95 iterations
60 of 75
Finished in 95 iterations
61 of 75
Finished in 95 iterations
62 of 75
Finished in 95 iterations
63 of 75
Finished in 95 iterations
64 of 75
Finished in 95 iterations
65 of 75
Finished in 95 iterations
66 of 75
Finished in 95 iterations
67 of 75
Finished in 95 iterations
68 of 75
Finished in 95 iterations
69 of 75
Finished in 96 iterations
70 of 75
Finished in 95 iterations
71 of 75
Finished in 95 iterations
72 of 75
Finished in 96 iterations
73 of 75
Finished in 96 iterations
74 of 75
Finished in 96 iterations
75 of 75
Finished in 96 iterations

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         3,610,000  (_merge==3)
    -----------------------------------------
Finished in 96 iterations
1 of 66
Finished in 95 iterations
2 of 66
Finished in 95 iterations
3 of 66
Finished in 95 iterations
4 of 66
Finished in 95 iterations
5 of 66
Finished in 95 iterations
6 of 66
Finished in 95 iterations
7 of 66
Finished in 95 iterations
8 of 66
Finished in 95 iterations
9 of 66
Finished in 95 iterations
10 of 66
Finished in 95 iterations
11 of 66
Finished in 95 iterations
12 of 66
Finished in 95 iterations
13 of 66
Finished in 95 iterations
14 of 66
Finished in 95 iterations
15 of 66
Finished in 95 iterations
16 of 66
Finished in 95 iterations
17 of 66
Finished in 95 iterations
18 of 66
Finished in 95 iterations
19 of 66
Finished in 95 iterations
20 of 66
Finished in 95 iterations
21 of 66
Finished in 95 iterations
22 of 66
Finished in 95 iterations
23 of 66
Finished in 95 iterations
24 of 66
Finished in 95 iterations
25 of 66
Finished in 95 iterations
26 of 66
Finished in 95 iterations
27 of 66
Finished in 95 iterations
28 of 66
Finished in 95 iterations
29 of 66
Finished in 95 iterations
30 of 66
Finished in 95 iterations
31 of 66
Finished in 95 iterations
32 of 66
Finished in 95 iterations
33 of 66
Finished in 95 iterations
34 of 66
Finished in 95 iterations
35 of 66
Finished in 95 iterations
36 of 66
Finished in 95 iterations
37 of 66
Finished in 95 iterations
38 of 66
Finished in 95 iterations
39 of 66
Finished in 95 iterations
40 of 66
Finished in 95 iterations
41 of 66
Finished in 95 iterations
42 of 66
Finished in 95 iterations
43 of 66
Finished in 95 iterations
44 of 66
Finished in 95 iterations
45 of 66
Finished in 95 iterations
46 of 66
Finished in 95 iterations
47 of 66
Finished in 95 iterations
48 of 66
Finished in 95 iterations
49 of 66
Finished in 95 iterations
50 of 66
Finished in 96 iterations
51 of 66
Finished in 95 iterations
52 of 66
Finished in 95 iterations
53 of 66
Finished in 95 iterations
54 of 66
Finished in 95 iterations
55 of 66
Finished in 95 iterations
56 of 66
Finished in 96 iterations
57 of 66
Finished in 96 iterations
58 of 66
Finished in 96 iterations
59 of 66
Finished in 96 iterations
60 of 66
Finished in 96 iterations
61 of 66
Finished in 96 iterations
62 of 66
Finished in 96 iterations
63 of 66
Finished in 96 iterations
64 of 66
Finished in 96 iterations
65 of 66
Finished in 96 iterations
66 of 66
Finished in 96 iterations
point was float now int
clusternum was float now int
mindistanceU_1 was float now byte
arsenicC48 was float now int
arsenicC50 was float now int
arsenicC52 was float now int
arsenicC54 was float now int
arsenicC55 was float now int
arsenicC56 was float now int
arsenicC57 was float now int
arsenicC58 was float now int
arsenicC59 was float now int
arsenicC60 was float now int
arsenicC61 was float now int
arsenicC62 was float now int
arsenicC63 was float now int
arsenicC64 was float now int
arsenicC65 was float now int
arsenicC66 was float now int
mindistanceC_1 was float now byte

Duplicates in terms of all variables

(3609639 observations deleted)
file dtafiles/hh_simulatedmindistance_2007_grid.dta saved

. /*
> (uniform()*2-1)*5/69.11;
> 
> 1° of latitude = about 69.11 miles 
> 
> 1° of longitude = about 69.11 miles along the equator. But all of the longitu
> des 
> come together at the poles, so the farther you are from the equator, the fewe
> r 
> miles there are in one degree. 
> 
> Number of miles in 1° of longitude = (69.11) x (cosine of the latitude)
> 
> */;
. 
end of do-file
