--------------------------------------------------------------------------------------------

log:  C:\AAA Miker Files\newer web pages\soc_388_notes\soc_388_2003\class 5.log

log type:  text

opened on:  13 Oct 2003, 11:29:07

. use "C:\AAA Miker Files\current class files\methods tabular arrays\ed intermar data, updat

> ed.dta", clear

. table hed wed, contents (sum count) row col

--------------------------------------------------

|                  wed

hed |      1       2       3       4   Total

----------+---------------------------------------

1 |  32016   33374    8407     988   74785

2 |  28370  137876   43783    8446  218475

3 |   7051   48766   61633   18195  135645

4 |    984   13794   28635   51224   94637

|

Total |  68421  233810  142458   78853  523542

--------------------------------------------------

. *Let's generate, a gender specific interaction for the most unlikely combination

. gen husb4wife1=0

. replace husb4wife1=1 if hed==4 & wed==1

(1 real change made)

. edit

- preserve

. desmat: poisson count hed wed  husb4wife1

------------------------------------------------------------------------------------------

Poisson regression

------------------------------------------------------------------------------------------

Dependent variable                                                               count

Optimization:                                                                       ml

Number of observations:                                                             16

Initial log likelihood:                                                    -221501.223

Log likelihood:                                                            -102975.137

LR chi square:                                                              237052.171

Model degrees of freedom:                                                            7

Pseudo R-squared:                                                                0.535

Prob:                                                                            0.000

------------------------------------------------------------------------------------------

nr Effect                                                               Coeff        s.e.

------------------------------------------------------------------------------------------

count

hed

1      2                                                                1.072**     0.004

2      3                                                                0.595**     0.005

3      4                                                                0.396**     0.005

wed

4      2                                                                1.013**     0.004

5      3                                                                0.517**     0.005

6      4                                                               -0.074**     0.005

husb4wife1

7      1                                                               -2.877**     0.032

8    _cons                                                              9.372**     0.005

------------------------------------------------------------------------------------------

*  p < .05

** p < .01

. display exp(-2.877)

.05630342

. *desmat can do lots of different things with comparison categories for indicator variables.

. poisgof

Goodness-of-fit chi2  =  205764.3

Prob > chi2(8)        =    0.0000

. desmat: poisson count hed=ind(3) wed=ind(2)  husb4wife1=ind(2)

------------------------------------------------------------------------------------------

Poisson regression

------------------------------------------------------------------------------------------

Dependent variable                                                               count

Optimization:                                                                       ml

Number of observations:                                                             16

Initial log likelihood:                                                    -221501.223

Log likelihood:                                                            -102975.137

LR chi square:                                                              237052.171

Model degrees of freedom:                                                            7

Pseudo R-squared:                                                                0.535

Prob:                                                                            0.000

------------------------------------------------------------------------------------------

nr Effect                                                               Coeff        s.e.

------------------------------------------------------------------------------------------

count

hed

1      1                                                               -0.595**     0.005

2      2                                                                0.477**     0.003

3      4                                                               -0.199**     0.004

wed

4      1                                                               -1.013**     0.004

5      3                                                               -0.495**     0.003

6      4                                                               -1.087**     0.004

husb4wife1

7      0                                                                2.877**     0.032

8    _cons                                                              8.104**     0.033

------------------------------------------------------------------------------------------

*  p < .05

** p < .01

. poisgof

Goodness-of-fit chi2  =  205764.3

Prob > chi2(8)        =    0.0000

. desmat: poisson count hed wed  husb4wife1

------------------------------------------------------------------------------------------

Poisson regression

------------------------------------------------------------------------------------------

Dependent variable                                                               count

Optimization:                                                                       ml

Number of observations:                                                             16

Initial log likelihood:                                                    -221501.223

Log likelihood:                                                            -102975.137

LR chi square:                                                              237052.171

Model degrees of freedom:                                                            7

Pseudo R-squared:                                                                0.535

Prob:                                                                            0.000

------------------------------------------------------------------------------------------

nr Effect                                                               Coeff        s.e.

------------------------------------------------------------------------------------------

count

hed

1      2                                                                1.072**     0.004

2      3                                                                0.595**     0.005

3      4                                                                0.396**     0.005

wed

4      2                                                                1.013**     0.004

5      3                                                                0.517**     0.005

6      4                                                               -0.074**     0.005

husb4wife1

7      1                                                               -2.877**     0.032

8    _cons                                                              9.372**     0.005

------------------------------------------------------------------------------------------

*  p < .05

** p < .01

. *That's back to our original model.

. *Now let's add the diagonal cells and see how that effects the off-diagonal interaction.

. set linesize 79

. desmat: poisson count hed wed full_endog husb4wife1

-------------------------------------------------------------------------------

Poisson regression

-------------------------------------------------------------------------------

Dependent variable                                                    count

Optimization:                                                            ml

Number of observations:                                                  16

Initial log likelihood:                                         -221501.223

Log likelihood:                                                  -20410.686

LR chi square:                                                   402181.075

Model degrees of freedom:                                                11

Pseudo R-squared:                                                     0.908

Prob:                                                                 0.000

-------------------------------------------------------------------------------

nr Effect                                                    Coeff        s.e.

-------------------------------------------------------------------------------

count

hed

1      2                                                     1.079**     0.007

2      3                                                     0.788**     0.006

3      4                                                     0.103**     0.007

wed

4      2                                                     1.173**     0.007

5      3                                                     0.843**     0.007

6      4                                                    -0.426**     0.008

full_endog

7      1                                                     1.536**     0.010

8      2                                                     0.744**     0.007

9      3                                                     0.561**     0.007

10     4                                                     2.329**     0.009

husb4wife1

11     1                                                    -2.049**     0.033

12   _cons                                                   8.838**     0.008

-------------------------------------------------------------------------------

*  p < .05

** p < .01

. *Where does this model fit the data?

. *It should fit everywhere we have a single term fitting a single cell

. predict P_ourmodel

(option n assumed; predicted number of events)

. table hed wed, contents (sum P_ourmodel) row col

------------------------------------------------------------

|                       wed

hed |        1         2         3         4     Total

----------+-------------------------------------------------

1 |    32016  22270.84  15999.74  4498.421     74785

2 | 20273.21    137876  47087.01  13238.79    218475

3 | 15147.79  48972.41     61633  9891.794    135645

4 |      984  24690.75  17738.25     51224     94637

|

Total |    68421    233810    142458     78853    523542

------------------------------------------------------------

. table hed wed, contents (sum count) row col

--------------------------------------------------

|                  wed

hed |      1       2       3       4   Total

----------+---------------------------------------

1 |  32016   33374    8407     988   74785

2 |  28370  137876   43783    8446  218475

3 |   7051   48766   61633   18195  135645

4 |    984   13794   28635   51224   94637

|

Total |  68421  233810  142458   78853  523542

--------------------------------------------------

. *What would the coefficent for 4-1 intermarriage look like if we used only 1

> term rather than 4 terms to describe endogamy diagonal?

. desmat: poisson count hed wed  simp_endog husb4wife1

-------------------------------------------------------------------------------

Poisson regression

-------------------------------------------------------------------------------

Dependent variable                                                    count

Optimization:                                                            ml

Number of observations:                                                  16

Initial log likelihood:                                         -221501.223

Log likelihood:                                                  -32870.555

LR chi square:                                                   377261.337

Model degrees of freedom:                                                 8

Pseudo R-squared:                                                     0.852

Prob:                                                                 0.000

-------------------------------------------------------------------------------

nr Effect                                                    Coeff        s.e.

-------------------------------------------------------------------------------

count

hed

1      2                                                     0.800**     0.005

2      3                                                     0.470**     0.005

3      4                                                     0.413**     0.005

wed

4      2                                                     0.788**     0.005

5      3                                                     0.414**     0.005

6      4                                                    -0.159**     0.006

simp_endog

7      1                                                     1.087**     0.003

husb4wife1

8      1                                                    -2.725**     0.032

9    _cons                                                   9.204**     0.005

-------------------------------------------------------------------------------

*  p < .05

** p < .01

. *just to remember what the two endogamy codings do.

. tabulate hed wed, contents (mean  simp_endog)

option contents() not allowed

r(198);

. table hed wed, contents (mean  simp_endog)

----------------------------------

|          wed

hed |    1     2     3     4

----------+-----------------------

1 |    1     0     0     0

2 |    0     1     0     0

3 |    0     0     1     0

4 |    0     0     0     1

----------------------------------

. table hed wed, contents (mean  full_endog)

----------------------------------

|          wed

hed |    1     2     3     4

----------+-----------------------

1 |    1     0     0     0

2 |    0     2     0     0

3 |    0     0     3     0

4 |    0     0     0     4

----------------------------------

. display chi2tail(50,100)

.00003455

. exit, clear