---------------------------------------------------------------------------------------------------------
log: C:\AAA Miker Files\newer web pages\soc_388_notes\soc_388_2007\class_ten_log.log
log type: text
opened on: 25 Oct 2007, 11:04:36
. *Today we will talk a little about stepwise regression.
. *demonstrating some stepwise regressions on a small and familiar dataset, LA racial intermarriage
. table husb wife, contents (sum count) row col
-----------------------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white Total
-----------+-----------------------------------------------------------------------
black | 4074 63 32 42 215 4426
Mexican | 25 3947 143 95 1009 5219
Oth Hisp | 16 132 239 18 304 709
All Others | 19 78 18 1022 360 1497
white | 103 1156 373 492 28453 30577
|
Total | 4237 5376 805 1669 30341 42428
-----------------------------------------------------------------------------------
. *Fitting models to the data...
. set linesize 79
. table husb wife, contents(mean intermar mean intermar_full)
-----------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white
-----------+-----------------------------------------------------------
black | 1 0 0 0 0
| 1 0 0 0 0
|
Mexican | 0 1 0 0 0
| 0 2 0 0 0
|
Oth Hisp | 0 0 1 0 0
| 0 0 3 0 0
|
All Others | 0 0 0 1 0
| 0 0 0 4 0
|
white | 0 0 0 0 1
| 0 0 0 0 5
-----------------------------------------------------------------------
. desmat: poisson count husb wife intermar
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -1405.264
LR chi square: 157466.482
Model degrees of freedom: 9
Pseudo R-squared: 0.982
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican -0.026 0.031
2 Oth Hisp -1.288** 0.048
3 All Others -0.822** 0.039
4 white 1.026** 0.025
wife
5 Mexican 0.258** 0.031
6 Oth Hisp -0.880** 0.046
7 All Others -0.388** 0.038
8 white 1.119** 0.026
intermar
9 1 2.850** 0.017
10 _cons 5.271** 0.021
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 2632.715
Prob > chi2(15) = 0.0000
. *Needs more...
. desmat: poisson count husb wife intermar_full
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -132.836
LR chi square: 160011.338
Model degrees of freedom: 13
Pseudo R-squared: 0.998
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.485** 0.061
2 Oth Hisp 0.340** 0.071
3 All Others 0.361** 0.070
4 white 2.791** 0.065
wife
5 Mexican 2.328** 0.083
6 Oth Hisp 1.262** 0.089
7 All Others 1.397** 0.088
8 white 3.498** 0.087
intermar_full
9 1 6.378** 0.099
10 2 2.533** 0.055
11 3 1.940** 0.094
12 4 3.237** 0.073
13 5 2.032** 0.051
14 _cons 1.934** 0.098
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 87.85888
Prob > chi2(11) = 0.0000
. *This is much better, but still leaves something to be desired. But what?
. *We are going to look at a set of off-diagonal relationships, and see which o
> nes Stata would put in...
. table husb wife, contents (mean QS)
-----------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white
-----------+-----------------------------------------------------------
black | 0 21 31 41 51
Mexican | 21 0 32 42 52
Oth Hisp | 31 32 0 43 53
All Others | 41 42 43 0 54
white | 51 52 53 54 0
-----------------------------------------------------------------------
. *10 interaction terms for the 10 symmetric pairs of off diagonal cells.
. *It turns out that this is the greatest number of symmetric interactions you can have in a square table.
. *An alternative version of the Quasi-symmetry terms might have main diagonal plus several off-diagonal symmetries, such as QS2 below
. table husb wife, contents (mean QS2)
-----------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white
-----------+-----------------------------------------------------------
black | 1 0 0 41 51
Mexican | 0 2 0 42 52
Oth Hisp | 0 0 3 0 53
All Others | 41 42 0 4 0
white | 51 52 53 0 5
-----------------------------------------------------------------------
. desmat: poisson count husb wife QS
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -89.596
LR chi square: 160097.818
Model degrees of freedom: 18
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican -0.431** 0.051
2 Oth Hisp -1.866** 0.065
3 All Others -1.190** 0.057
4 white 0.625** 0.049
wife
5 Mexican 0.399** 0.051
6 Oth Hisp -0.970** 0.065
7 All Others -0.193** 0.057
8 white 1.319** 0.049
QS
9 21 -4.596** 0.109
10 31 -3.814** 0.150
11 32 -1.956** 0.069
12 41 -4.323** 0.132
13 42 -3.148** 0.078
14 43 -3.314** 0.171
15 51 -4.274** 0.059
16 52 -2.284** 0.023
17 53 -2.047** 0.050
18 54 -2.550** 0.038
19 _cons 8.312** 0.016
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 1.379208
Prob > chi2(6) = 0.9671
. *Quasi-Symmetry fits very well....
. desmat: poisson count husb wife QS2
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -89.596
LR chi square: 160097.818
Model degrees of freedom: 18
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.428** 0.160
2 Oth Hisp 0.774** 0.130
3 All Others -0.690** 0.225
4 white 4.029** 0.212
wife
5 Mexican 2.257** 0.171
6 Oth Hisp 1.671** 0.142
7 All Others 0.307 0.232
8 white 4.724** 0.220
QS2
9 1 6.454** 0.194
10 2 2.738** 0.190
11 3 1.173** 0.201
12 4 5.454** 0.385
13 5 -0.355 0.390
14 41 1.632** 0.244
15 42 0.948** 0.257
16 51 -1.225** 0.231
17 52 -1.092** 0.182
18 53 -1.638** 0.258
19 _cons 1.858** 0.194
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 1.379208
Prob > chi2(6) = 0.9671
. *It's the same model, you can tell bc goodness of fit is exactly the same.
. *What is left after putting all the symmetrical terms into the model, is asymmetrical terms.
. table husb wife, contents(mean Asym)
-----------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white
-----------+-----------------------------------------------------------
black | 0 0 0 0 0
Mexican | 21 0 0 0 0
Oth Hisp | 31 32 0 0 0
All Others | 41 42 43 0 0
white | 51 52 53 54 0
-----------------------------------------------------------------------
. *To do stepwise, we have to use desmat to generate the dummies first.
. desmat husb wife QS2 Asym
Desmat generated the following design matrix:
nr Variables Term Parameterization
First Last
1 _x_1 _x_4 husb ind(1)
2 _x_5 _x_8 wife ind(1)
3 _x_9 _x_17 QS2 ind(0)
4 _x_18 _x_24 Asym ind(0)
. *Notice, that several of the Asym terms were dropped from desmat, because they would have been colinear. You can't put more than 25 terms (in this case, 1 constant plus 24 terms) into a model to predict a 5x5 table.
. sw poisson count (_x_1-_x_8) _x_9-_x_24, forward pe(.001) pr(.01)
begin with empty model
p = 0.0000 < 0.0010 adding _x_1 _x_2 _x_3 _x_4 _x_5 _x_6 _x_7 _x_8
p = 0.0000 < 0.0010 adding _x_9
p = 0.0000 < 0.0010 adding _x_10
p = 0.0000 < 0.0010 adding _x_12
p = 0.0000 < 0.0010 adding _x_17
p = 0.0000 < 0.0010 adding _x_14
p = 0.0000 < 0.0010 adding _x_13
p = 0.0000 < 0.0010 adding _x_15
p = 0.0000 < 0.0010 adding _x_16
p = 0.0000 < 0.0010 adding _x_11
Poisson regression Number of obs = 25
LR chi2(17) = 160096.96
Prob > chi2 = 0.0000
Log likelihood = -90.022867 Pseudo R2 = 0.9989
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | 1.471544 .1558986 9.44 0.000 1.165988 1.7771
_x_2 | .73637 .1218848 6.04 0.000 .4974801 .9752598
_x_3 | -.5103945 .1108274 -4.61 0.000 -.7276122 -.2931768
_x_4 | 3.859923 .0999757 38.61 0.000 3.663975 4.055872
_x_5 | 2.300677 .1676349 13.72 0.000 1.972118 2.629235
_x_6 | 1.635904 .1357068 12.05 0.000 1.369923 1.901884
_x_7 | .4869843 .1235324 3.94 0.000 .2448652 .7291033
_x_8 | 4.554325 .1164357 39.11 0.000 4.326115 4.782535
_x_9 | 6.470534 .195383 33.12 0.000 6.087591 6.853478
_x_10 | 2.666644 .1756067 15.19 0.000 2.322461 3.010827
_x_12 | 5.111081 .0751948 67.97 0.000 4.963702 5.25846
_x_17 | -1.415834 .0908697 -15.58 0.000 -1.593935 -1.237733
_x_14 | .7403587 .1228662 6.03 0.000 .4995454 .9811719
_x_13 | 1.468076 .1632134 8.99 0.000 1.148184 1.787968
_x_15 | -1.039167 .110891 -9.37 0.000 -1.256509 -.8218247
_x_16 | -.9503197 .0900525 -10.55 0.000 -1.126819 -.77382
_x_11 | 1.262343 .1769777 7.13 0.000 .9154734 1.609213
_cons | 1.841846 .1947538 9.46 0.000 1.460136 2.223557
------------------------------------------------------------------------------
. desrep
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -90.023
LR chi square: 160096.964
Model degrees of freedom: 17
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.472** 0.156
2 Oth Hisp 0.736** 0.122
3 All Others -0.510** 0.111
4 white 3.860** 0.100
wife
5 Mexican 2.301** 0.168
6 Oth Hisp 1.636** 0.136
7 All Others 0.487** 0.124
8 white 4.554** 0.116
QS2
9 1 6.471** 0.195
10 2 2.667** 0.176
11 4 5.111** 0.075
12 53 -1.416** 0.091
13 42 0.740** 0.123
14 41 1.468** 0.163
15 51 -1.039** 0.111
16 52 -0.950** 0.090
17 3 1.262** 0.177
18 _cons 1.842** 0.195
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 2.233234
Prob > chi2(7) = 0.9458
. *What we got here, is only symmetrical terms from QS2, including 4 of the 5 diagonal terms and 5 of the symmetrical off-diagonal terms. None of the asymetrical terms got added.
. *Which tells us something: looking at the data this way, there do not appear to be important gender asymetries.
. *Now let's do a backward stepwise
. sw poisson count (_x_1-_x_8) _x_9-_x_24, pe(.001) pr(.01)
begin with full model
p = 0.9720 >= 0.0100 removing _x_22
p = 0.7010 >= 0.0100 removing _x_21
p = 0.5047 >= 0.0100 removing _x_19
p = 0.4576 >= 0.0100 removing _x_20
p = 0.5321 >= 0.0100 removing _x_23
p = 0.5793 >= 0.0100 removing _x_18
p = 0.5194 >= 0.0100 removing _x_24
Poisson regression Number of obs = 25
LR chi2(17) = 160096.96
Prob > chi2 = 0.0000
Log likelihood = -90.022867 Pseudo R2 = 0.9989
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | 1.471544 .1558986 9.44 0.000 1.165988 1.7771
_x_2 | .73637 .1218848 6.04 0.000 .4974801 .9752598
_x_3 | -.5103945 .1108274 -4.61 0.000 -.7276122 -.2931768
_x_4 | 3.859923 .0999757 38.61 0.000 3.663975 4.055872
_x_5 | 2.300677 .1676349 13.72 0.000 1.972118 2.629235
_x_6 | 1.635904 .1357068 12.05 0.000 1.369923 1.901884
_x_7 | .4869843 .1235324 3.94 0.000 .2448652 .7291033
_x_8 | 4.554325 .1164357 39.11 0.000 4.326115 4.782535
_x_9 | 6.470534 .195383 33.12 0.000 6.087591 6.853478
_x_10 | 2.666644 .1756067 15.19 0.000 2.322461 3.010827
_x_11 | 1.262343 .1769777 7.13 0.000 .9154734 1.609213
_x_12 | 5.111081 .0751948 67.97 0.000 4.963702 5.25846
_x_13 | 1.468076 .1632134 8.99 0.000 1.148184 1.787968
_x_14 | .7403587 .1228662 6.03 0.000 .4995454 .9811719
_x_15 | -1.039167 .110891 -9.37 0.000 -1.256509 -.8218247
_x_16 | -.9503197 .0900525 -10.55 0.000 -1.126819 -.77382
_x_17 | -1.415834 .0908697 -15.58 0.000 -1.593935 -1.237733
_cons | 1.841846 .1947538 9.46 0.000 1.460136 2.223557
------------------------------------------------------------------------------
. poisgof
Goodness-of-fit chi2 = 2.233234
Prob > chi2(7) = 0.9458
. desrep
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -90.023
LR chi square: 160096.964
Model degrees of freedom: 17
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.472** 0.156
2 Oth Hisp 0.736** 0.122
3 All Others -0.510** 0.111
4 white 3.860** 0.100
wife
5 Mexican 2.301** 0.168
6 Oth Hisp 1.636** 0.136
7 All Others 0.487** 0.124
8 white 4.554** 0.116
QS2
9 1 6.471** 0.195
10 2 2.667** 0.176
11 3 1.262** 0.177
12 4 5.111** 0.075
13 41 1.468** 0.163
14 42 0.740** 0.123
15 51 -1.039** 0.111
16 52 -0.950** 0.090
17 53 -1.416** 0.091
18 _cons 1.842** 0.195
-------------------------------------------------------------------------------
* p < .05
** p < .01
. *In this case, both forward and backward yielded the same model, but it doesn't have to be so.
. sw poisson count (_x_1-_x_8) _x_9-_x_24, forward pe(.05) pr(.1)
begin with empty model
p = 0.0000 < 0.0500 adding _x_1 _x_2 _x_3 _x_4 _x_5 _x_6 _x_7 _x_8
p = 0.0000 < 0.0500 adding _x_9
p = 0.0000 < 0.0500 adding _x_10
p = 0.0000 < 0.0500 adding _x_12
p = 0.0000 < 0.0500 adding _x_17
p = 0.0000 < 0.0500 adding _x_14
p = 0.0000 < 0.0500 adding _x_13
p = 0.0000 < 0.0500 adding _x_15
p = 0.0000 < 0.0500 adding _x_16
p = 0.0000 < 0.0500 adding _x_11
Poisson regression Number of obs = 25
LR chi2(17) = 160096.96
Prob > chi2 = 0.0000
Log likelihood = -90.022867 Pseudo R2 = 0.9989
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | 1.471544 .1558986 9.44 0.000 1.165988 1.7771
_x_2 | .73637 .1218848 6.04 0.000 .4974801 .9752598
_x_3 | -.5103945 .1108274 -4.61 0.000 -.7276122 -.2931768
_x_4 | 3.859923 .0999757 38.61 0.000 3.663975 4.055872
_x_5 | 2.300677 .1676349 13.72 0.000 1.972118 2.629235
_x_6 | 1.635904 .1357068 12.05 0.000 1.369923 1.901884
_x_7 | .4869843 .1235324 3.94 0.000 .2448652 .7291033
_x_8 | 4.554325 .1164357 39.11 0.000 4.326115 4.782535
_x_9 | 6.470534 .195383 33.12 0.000 6.087591 6.853478
_x_10 | 2.666644 .1756067 15.19 0.000 2.322461 3.010827
_x_12 | 5.111081 .0751948 67.97 0.000 4.963702 5.25846
_x_17 | -1.415834 .0908697 -15.58 0.000 -1.593935 -1.237733
_x_14 | .7403587 .1228662 6.03 0.000 .4995454 .9811719
_x_13 | 1.468076 .1632134 8.99 0.000 1.148184 1.787968
_x_15 | -1.039167 .110891 -9.37 0.000 -1.256509 -.8218247
_x_16 | -.9503197 .0900525 -10.55 0.000 -1.126819 -.77382
_x_11 | 1.262343 .1769777 7.13 0.000 .9154734 1.609213
_cons | 1.841846 .1947538 9.46 0.000 1.460136 2.223557
------------------------------------------------------------------------------
. poisgof
Goodness-of-fit chi2 = 2.233234
Prob > chi2(7) = 0.9458
. desrep
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -90.023
LR chi square: 160096.964
Model degrees of freedom: 17
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.472** 0.156
2 Oth Hisp 0.736** 0.122
3 All Others -0.510** 0.111
4 white 3.860** 0.100
wife
5 Mexican 2.301** 0.168
6 Oth Hisp 1.636** 0.136
7 All Others 0.487** 0.124
8 white 4.554** 0.116
QS2
9 1 6.471** 0.195
10 2 2.667** 0.176
11 4 5.111** 0.075
12 53 -1.416** 0.091
13 42 0.740** 0.123
14 41 1.468** 0.163
15 51 -1.039** 0.111
16 52 -0.950** 0.090
17 3 1.262** 0.177
18 _cons 1.842** 0.195
-------------------------------------------------------------------------------
* p < .05
** p < .01
. *We ended up with the same QS only model, no asymetries added, even though we put the bar for entry at an easier .05
. sw poisson count (_x_1-_x_8) _x_9-_x_24, pe(.05) pr(.1)
begin with full model
p = 0.9720 >= 0.1000 removing _x_22
p = 0.7010 >= 0.1000 removing _x_21
p = 0.5047 >= 0.1000 removing _x_19
p = 0.4576 >= 0.1000 removing _x_20
p = 0.5321 >= 0.1000 removing _x_23
p = 0.5793 >= 0.1000 removing _x_18
p = 0.5194 >= 0.1000 removing _x_24
Poisson regression Number of obs = 25
LR chi2(17) = 160096.96
Prob > chi2 = 0.0000
Log likelihood = -90.022867 Pseudo R2 = 0.9989
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | 1.471544 .1558986 9.44 0.000 1.165988 1.7771
_x_2 | .73637 .1218848 6.04 0.000 .4974801 .9752598
_x_3 | -.5103945 .1108274 -4.61 0.000 -.7276122 -.2931768
_x_4 | 3.859923 .0999757 38.61 0.000 3.663975 4.055872
_x_5 | 2.300677 .1676349 13.72 0.000 1.972118 2.629235
_x_6 | 1.635904 .1357068 12.05 0.000 1.369923 1.901884
_x_7 | .4869843 .1235324 3.94 0.000 .2448652 .7291033
_x_8 | 4.554325 .1164357 39.11 0.000 4.326115 4.782535
_x_9 | 6.470534 .195383 33.12 0.000 6.087591 6.853478
_x_10 | 2.666644 .1756067 15.19 0.000 2.322461 3.010827
_x_11 | 1.262343 .1769777 7.13 0.000 .9154734 1.609213
_x_12 | 5.111081 .0751948 67.97 0.000 4.963702 5.25846
_x_13 | 1.468076 .1632134 8.99 0.000 1.148184 1.787968
_x_14 | .7403587 .1228662 6.03 0.000 .4995454 .9811719
_x_15 | -1.039167 .110891 -9.37 0.000 -1.256509 -.8218247
_x_16 | -.9503197 .0900525 -10.55 0.000 -1.126819 -.77382
_x_17 | -1.415834 .0908697 -15.58 0.000 -1.593935 -1.237733
_cons | 1.841846 .1947538 9.46 0.000 1.460136 2.223557
------------------------------------------------------------------------------
. poisgof
Goodness-of-fit chi2 = 2.233234
Prob > chi2(7) = 0.9458
. desrep
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 25
Initial log likelihood: -80138.505
Log likelihood: -90.023
LR chi square: 160096.964
Model degrees of freedom: 17
Pseudo R-squared: 0.999
Prob: 0.000
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
husb
1 Mexican 1.472** 0.156
2 Oth Hisp 0.736** 0.122
3 All Others -0.510** 0.111
4 white 3.860** 0.100
wife
5 Mexican 2.301** 0.168
6 Oth Hisp 1.636** 0.136
7 All Others 0.487** 0.124
8 white 4.554** 0.116
QS2
9 1 6.471** 0.195
10 2 2.667** 0.176
11 3 1.262** 0.177
12 4 5.111** 0.075
13 41 1.468** 0.163
14 42 0.740** 0.123
15 51 -1.039** 0.111
16 52 -0.950** 0.090
17 53 -1.416** 0.091
18 _cons 1.842** 0.195
-------------------------------------------------------------------------------
* p < .05
** p < .01
. *This particular trial with stepwise seems to be giving us very consistent results regardless of forward or backward, and regardless of the entry and removal criteria, but it does not always work out so consistently.
. *Okay, that's enough of stepwise for now.
.
. clear
. * A quick note about about how to create QS:
. *I am using a numeric version of the data
. use "C:\AAA Miker Files\newer web pages\soc_388_notes\LA_interar_numeric.dta", clear
. describe
Contains data from C:\AAA Miker Files\newer web pages\soc_388_notes\LA_interar_
> numeric.dta
obs: 25
vars: 8 24 Oct 2007 15:54
size: 325 (99.9% of memory free)
-------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
count int %8.0g
wife byte %10.0g race_label
husb byte %10.0g race_label
intermar byte %8.0g
intermar_full byte %8.0g
QS byte %8.0g
Asym byte %8.0g
QS2 byte %8.0g
-------------------------------------------------------------------------------
Sorted by:
. tabulate husb wife [fweight=count]
| wife
husb | black Mexican Oth Hisp All Other white | Total
-----------+-------------------------------------------------------+----------
black | 4,074 63 32 42 215 | 4,426
Mexican | 25 3,947 143 95 1,009 | 5,219
Oth Hisp | 16 132 239 18 304 | 709
All Others | 19 78 18 1,022 360 | 1,497
white | 103 1,156 373 492 28,453 | 30,577
-----------+-------------------------------------------------------+----------
Total | 4,237 5,376 805 1,669 30,341 | 42,428
. tabulate husb wife [fweight=count], nolab
| wife
husb | 1 2 3 4 5 | Total
-----------+-------------------------------------------------------+----------
1 | 4,074 63 32 42 215 | 4,426
2 | 25 3,947 143 95 1,009 | 5,219
3 | 16 132 239 18 304 | 709
4 | 19 78 18 1,022 360 | 1,497
5 | 103 1,156 373 492 28,453 | 30,577
-----------+-------------------------------------------------------+----------
Total | 4,237 5,376 805 1,669 30,341 | 42,428
. gen new_qs=0
. replace new_qs=(10*husb)+wife if husb>wife
(10 real changes made)
. replace new_qs=(10*wife)+husb if husb<wife
(10 real changes made)
. *I am just using the row and column numbers here to create a separate variable for each off diagonal cell, it doesn't matter what the values are as long as they are all different.
. table husb wife, contents(mean new_qs)
-----------------------------------------------------------------------
| wife
husb | black Mexican Oth Hisp All Others white
-----------+-----------------------------------------------------------
black | 0 21 31 41 51
Mexican | 21 0 32 42 52
Oth Hisp | 31 32 0 43 53
All Others | 41 42 43 0 54
white | 51 52 53 54 0
-----------------------------------------------------------------------
. *This is quasi-symmetry, the largest number of symmetric interactions on a square table, which in this case has r+c=5+5=10 distinct values.
. exit, clear