When examining the two graphs....
metro vs income
and number of stillborns vs income
It appears that both variables have a relationship with income.
Testing for independence, we have to first realize that we are testing with a continuous variable, total monthly income. We need to generate a new categorical variable that takes on different responses depending on how much a household makes. For this response, the survey respondents were divided into five groups. The first 20% of the survey made the lowest amount, the second 20% made the second lowest amount, so that each categorical value contained roughly the same amount of respondents.
gen inc=.
replace inc=1 if totminc>=0 & totminc<=380
replace inc=2 if totminc>=380.1 & totminc<=688
replace inc=3 if totminc>=688.1 & totminc<=1200
replace inc=4 if totminc>=1200.01 & totminc<=2308
replace inc=5 if totminc>=2308.011 & totminc<=124734
Now, we are able to run tests for independence through the tabulation function. When we do this for metro and our new categorial variable for total monthly income, we find that:
tab inc metro, row col chi2
| metro - urban - rural
inc | Rural Urban Metro | Total
-----------+---------------------------------+----------
1 | 847 101 78 | 1026
| 82.55 9.84 7.60 | 100.00
| 27.47 11.56 6.76 | 20.08
-----------+---------------------------------+----------
2 | 819 137 68 | 1024
| 79.98 13.38 6.64 | 100.00
| 26.57 15.68 5.90 | 20.04
-----------+---------------------------------+----------
3 | 680 194 151 | 1025
| 66.34 18.93 14.73 | 100.00
| 22.06 22.20 13.10 | 20.06
-----------+---------------------------------+----------
4 | 523 177 311 | 1011
| 51.73 17.51 30.76 | 100.00
| 16.96 20.25 26.97 | 19.78
-----------+---------------------------------+----------
5 | 214 265 545 | 1024
| 20.90 25.88 53.22 | 100.00
| 6.94 30.32 47.27 | 20.04
-----------+---------------------------------+----------
Total | 3083 874 1153 | 5110
| 60.33 17.10 22.56 | 100.00
| 100.00 100.00 100.00 | 100.00
Pearson chi2(8) = 1221.4802 Pr = 0.000
total monthly income and what kind of area one lives in are not independent.
As for number of stillborns and total monthly income we find:
tab inc stillbor, row col chi2
| 5 :no stillborn
inc | -2 0 1 2 3 | Total
-----------+-------------------------------------------------------+----------
1 | 76 153 20 3 1 | 255
| 29.80 60.00 7.84 1.18 0.39 | 100.00
| 19.14 20.32 24.39 14.29 12.50 | 20.11
-----------+-------------------------------------------------------+----------
2 | 73 141 13 3 1 | 232
| 31.47 60.78 5.60 1.29 0.43 | 100.00
| 18.39 18.73 15.85 14.29 12.50 | 18.30
-----------+-------------------------------------------------------+----------
3 | 81 135 20 6 2 | 246
| 32.93 54.88 8.13 2.44 0.81 | 100.00
| 20.40 17.93 24.39 28.57 25.00 | 19.40
-----------+-------------------------------------------------------+----------
4 | 72 154 13 7 2 | 249
| 28.92 61.85 5.22 2.81 0.80 | 100.00
| 18.14 20.45 15.85 33.33 25.00 | 19.64
-----------+-------------------------------------------------------+----------
5 | 95 170 16 2 2 | 286
| 33.22 59.44 5.59 0.70 0.70 | 100.00
| 23.93 22.58 19.51 9.52 25.00 | 22.56
-----------+-------------------------------------------------------+----------
Total | 397 753 82 21 8 | 1268
| 31.31 59.38 6.47 1.66 0.63 | 100.00
| 100.00 100.00 100.00 100.00 100.00 | 100.00
| 5 :no stillborn
inc | 4 5 6 7 | Total
-----------+--------------------------------------------+----------
1 | 1 0 1 0 | 255
| 0.39 0.00 0.39 0.00 | 100.00
| 100.00 0.00 33.33 0.00 | 20.11
-----------+--------------------------------------------+----------
2 | 0 1 0 0 | 232
| 0.00 0.43 0.00 0.00 | 100.00
| 0.00 50.00 0.00 0.00 | 18.30
-----------+--------------------------------------------+----------
3 | 0 1 0 1 | 246
| 0.00 0.41 0.00 0.41 | 100.00
| 0.00 50.00 0.00 100.00 | 19.40
-----------+--------------------------------------------+----------
4 | 0 0 1 0 | 249
| 0.00 0.00 0.40 0.00 | 100.00
| 0.00 0.00 33.33 0.00 | 19.64
-----------+--------------------------------------------+----------
5 | 0 0 1 0 | 286
| 0.00 0.00 0.35 0.00 | 100.00
| 0.00 0.00 33.33 0.00 | 22.56
-----------+--------------------------------------------+----------
Total | 1 2 3 1 | 1268
| 0.08 0.16 0.24 0.08 | 100.00
| 100.00 100.00 100.00 100.00 | 100.00
Pearson chi2(32) = 24.3198 Pr = 0.833
We find that there is no dependence between the variables.