--------------------------------------------------------------------------------------------------- log: :acomp hd (2001-02):save stuff here (temporary):class 5.log log type: text opened on: 9 Oct 2002, 13:20:35 . *Just a brief moment to look at the two similar intermarriage datasets, so that you're used to de > aling with numeric or string variables. . use ":AComp HD (2001-02):Desktop Folder:LA_intermar.dta" . describe Contains data from :AComp HD (2001-02):Desktop Folder:LA_intermar.dta obs: 25 vars: 3 6 Oct 2001 16:50 size: 500 (99.9% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- husb str7 %9s wife str7 %9s count int %8.0g ------------------------------------------------------------------------------- Sorted by: . table husb wife, contents (sum count) ------------------------------------------------------- | wife husb | AllOth Black Mex OthHisp White ----------+-------------------------------------------- AllOth | 1022 19 78 18 360 Black | 42 4074 63 32 215 Mex | 95 25 3947 143 1009 OthHisp | 18 16 132 239 304 White | 492 103 1156 373 28453 ------------------------------------------------------- . *in order to create a dummy variable for interaction between Mex and Oth Hisp, for instance, you > need to use the string values . gen Moh=0 . replace Moh=1 if husb=="Mex" & wife=="OthHisp" (1 real change made) . *Note that there are double == after the if, and that 'and' is the ampersand character. 'or' is > the | . *See my intro to Stata notes under class Soc 180. . replace Moh=1 if husb=="OthHisp" & wife=="Mex" (1 real change made) . table husb wife, contents (sum Moh ) ------------------------------------------------------- | wife husb | AllOth Black Mex OthHisp White ----------+-------------------------------------------- AllOth | 0 0 0 0 0 Black | 0 0 0 0 0 Mex | 0 0 0 1 0 OthHisp | 0 0 1 0 0 White | 0 0 0 0 0 ------------------------------------------------------- . *This is the gender symmetric interaction between Mexicans and Other Hispanics. It's one term t > o cover two cells, alternatively we could add a second term, that would specify just one of the > two cells and ask whether the interaction between the two groups is gender symmetric or not . clear all . use ":AComp HD (2001-02):Desktop Folder:HW2.dta" file :AComp HD (2001-02):Desktop Folder:HW2.dta not Stata format r(610); . use ":AComp HD (2001-02):Desktop Folder:HW2.dta" file :AComp HD (2001-02):Desktop Folder:HW2.dta not Stata format r(610); . use ":AComp HD (2001-02):Save Stuff Here (Temporary):HW2.dta" file :AComp HD (2001-02):Save Stuff Here (Temporary):HW2.dta not Stata format r(610); . edit . edit (1 var, 17 obs pasted into editor) . exit, clear /* NOTE: up to here was my first log from class*/ /* This next section is stuff I repeated on my own, to replicate more or less what we had done in class*/ -------------------------------------------------------------------------------------- log: C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\class 5 o > ther stuff.log log type: text opened on: 9 Oct 2002, 16:59:14 . use "C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\HW2.dta", clear . describe Contains data from C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\HW2 > .dta obs: 25 vars: 3 size: 200 (100.0% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- count int %8.0g wife byte %8.0g wife husb byte %8.0g husb ------------------------------------------------------------------------------- Sorted by: . *Okay. This dataset has husb and wife as numerica variables (byte, to be specific > ). . table husb wife, contents (sum count) ----------------------------------------------------------------------- | wife husb | black mexican oth hisp all others white -----------+----------------------------------------------------------- black | 4074 63 32 42 215 mexican | 25 3947 143 95 1009 oth hisp | 16 132 239 18 304 all others | 19 78 18 1022 360 white | 103 1156 373 492 28453 ----------------------------------------------------------------------- . *If you table you get the same data as before. But . gen Moh=0 . replace Moh=1 if husb=="mexican" & wife=="oth hisp" type mismatch r(109); . *Won't work. You need to use the numbers . replace Moh=1 if (husb==2 & wife==3) |(wife==3 & husb==2) (1 real change made) . replace Moh=1 if (husb==2 & wife==3) |(wife==2 & husb==3) (1 real change made) . *oops- first time I ran that command I had the same situation listed twice.. . *Every time you make a dummy variable, it's always good to table it to see what it > looks like, to make sure you've done it right . table husb wife, contents (mean Moh) ----------------------------------------------------------------------- | wife husb | black mexican oth hisp all others white -----------+----------------------------------------------------------- black | 0 0 0 0 0 mexican | 0 0 1 0 0 oth hisp | 0 1 0 0 0 all others | 0 0 0 0 0 white | 0 0 0 0 0 ----------------------------------------------------------------------- . *That's right. . desmat: poisson count wife husb Moh ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 25 Initial log likelihood: -80138.505 Log likelihood: -22044.845 LR chi square: 116187.321 Model degrees of freedom: 9 Pseudo R-squared: 0.725 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count wife 1 mexican 0.229** 0.021 2 oth hisp -1.728** 0.040 3 all others -0.932** 0.029 4 white 1.969** 0.016 husb 5 mexican 0.155** 0.021 6 oth hisp -1.901** 0.042 7 all others -1.084** 0.030 8 white 1.933** 0.016 Moh 9 1 0.451** 0.067 10 _cons 6.094** 0.021 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . poisgof Goodness-of-fit chi2 = 43911.88 Prob > chi2(15) = 0.0000 . *Okay, this is the independence model plus one term for Mexican- Other Hispanic in > termarriage. The term is positive and significant, but the model doesn't fit well > , and there's a bunch of stuff we might reasonably want to add to this model. . *Now let's take a quick look to see about a gender specific Moh interaction . gen MhusOhwife=0 . replace MhusOhwife=1 if husb==2 & wife==3 (1 real change made) . table husb wife, contents (mean MhusOhwife) ----------------------------------------------------------------------- | wife husb | black mexican oth hisp all others white -----------+----------------------------------------------------------- black | 0 0 0 0 0 mexican | 0 0 1 0 0 oth hisp | 0 0 0 0 0 all others | 0 0 0 0 0 white | 0 0 0 0 0 ----------------------------------------------------------------------- . *Our gender specific interaction points to only 1 of the two combinations of Mexic > an and Other Hispanic. . *Now let's add this second term into the model, and see if it makes a difference. . desmat: poisson count wife husb Moh MhusOhwife ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 25 Initial log likelihood: -80138.505 Log likelihood: -22044.830 LR chi square: 116187.349 Model degrees of freedom: 10 Pseudo R-squared: 0.725 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count wife 1 mexican 0.229** 0.021 2 oth hisp -1.726** 0.042 3 all others -0.932** 0.029 4 white 1.969** 0.016 husb 5 mexican 0.155** 0.021 6 oth hisp -1.903** 0.044 7 all others -1.084** 0.030 8 white 1.933** 0.016 Moh 9 1 0.463** 0.098 MhusOhwife 10 1 -0.023 0.135 11 _cons 6.094** 0.021 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . *The gender specific interaction term is NOT significant. . poisgof Goodness-of-fit chi2 = 43911.85 Prob > chi2(14) = 0.0000 . *And the goodness of fit chisquare is improved only by 0.03 on one additional degr > ee of freedom- that's not significant progress at all. . *Now I'm gonna drop this dataset, and go back to my educational intermarriage data > set. . clear all . use "C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\husb ed by wi > fe ed.dta", clear . table hed wed, contents (mean edendogamy) -------------------------------------------------- | wed hed | inter has different levels for each different kind . desmat: poisson count hed wed edendogamy ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 16 Initial log likelihood: -221501.223 Log likelihood: -41944.565 LR chi square: 359113.316 Model degrees of freedom: 7 Pseudo R-squared: 0.811 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count hed 1 HS 0.740** 0.005 2 some col 0.414** 0.005 3 BA+ 0.216** 0.005 wed 4 HS 0.979** 0.005 5 some col 0.608** 0.005 6 BA+ 0.081** 0.005 edendogamy 7 1 1.115** 0.003 8 _cons 9.067** 0.005 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . poisgof Goodness-of-fit chi2 = 83703.13 Prob > chi2(8) = 0.0000 . desmat: poisson count hed wed fulledendog ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 16 Initial log likelihood: -221501.223 Log likelihood: -92.984 LR chi square: 442816.478 Model degrees of freedom: 15 Pseudo R-squared: 1.000 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count hed 1 HS -0.121** 0.008 2 some col 5.211** 0.034 3 BA+ 3.948** 0.032 wed 4 HS -4.790** 0.034 5 some col 0.434** 0.008 6 BA+ -3.478** 0.032 fulledendog 7 5626.91259765625 -7.431** 0.046 8 9830.73046875 -2.298** 0.013 9 12987.8017578125 -6.724** 0.036 10 13465.8271484375 2.267** 0.035 11 15606.7255859375 -4.494** 0.034 12 15875.3876953125 -1.771** 0.014 13 22561.169921875 4.832** 0.034 14 61633 -4.990** 0.035 15 137876 6.371** 0.034 16 _cons 10.374** 0.006 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . *Oops- I used the predicted values in this model, That's a Goof up on my part. . desmat: poisson count hed wed edinter ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 16 Initial log likelihood: -221501.223 Log likelihood: -24059.274 LR chi square: 394883.898 Model degrees of freedom: 10 Pseudo R-squared: 0.891 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count hed 1 HS 1.134** 0.007 2 some col 0.819** 0.006 3 BA+ -0.017* 0.007 wed 4 HS 1.372** 0.007 5 some col 1.020** 0.007 6 BA+ -0.278** 0.008 edinter 7 1 1.722** 0.009 8 2 0.676** 0.007 9 3 0.537** 0.008 10 4 2.487** 0.009 11 _cons 8.652** 0.008 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . poisgof Goodness-of-fit chi2 = 47932.55 Prob > chi2(5) = 0.0000 . *OK- if you compare to the previous model, or if you check the Excel file you'll s > ee that allowing the educational endogamy to vary by educational class improves th > e goodness of fit by 35,000 on 3 degrees of freedom, which is a huge improvement. > We can definitely say, without any doubt, that educational intermarriage varies b > y educational class. . . *Now- are we sure that all the educational groups are significantly different from > each other? . *let's test them . *If you look at the variable and expand the window, you'll see that each of desmat > 's created _x variables has a more meaningful description. First we want to compa > re the two most different ed levels, that for group 4 and for group 3. . . test _x_10- _x_9=0 ( 1) - [count]_x_9 + [count]_x_10 = 0.0 chi2( 1) =25423.04 Prob > chi2 = 0.0000 . *This tests the hypothesis that educational intermarriage is the same for those in > group 4 as in group 3, and rejects the hypothesis. . . *Now a more interesting test: What about groups 2 and 3? These groups differ onl > y a bit- 0.676 compared to 0.537. Is the difference significant? . test _x_8- _x_9=0 ( 1) [count]_x_8 - [count]_x_9 = 0.0 chi2( 1) = 129.03 Prob > chi2 = 0.0000 . *yeah, the difference is significant. We have to reject the null hypothesis that > these two categories have the same educational endogamy. . log close log: C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\class 5 > other stuff.log log type: text closed on: 9 Oct 2002, 17:19:54 ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ log: C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\class 5 > other stuff.log log type: text opened on: 9 Oct 2002, 17:21:41 . *One last illustration, on the importance of a comparison class. . . gen level3=0 . replace level3=1 if hed-wed==3 | wed-hed==3 (2 real changes made) . table hed wed, contents (mean level3) -------------------------------------------------- | wed hed | ies. . desmat: poisson count hed wed level3 ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 16 Initial log likelihood: -221501.223 Log likelihood: -93859.587 LR chi square: 255283.273 Model degrees of freedom: 7 Pseudo R-squared: 0.576 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count hed 1 HS 0.901** 0.004 2 some col 0.424** 0.005 3 BA+ 0.218** 0.005 wed 4 HS 1.022** 0.004 5 some col 0.526** 0.005 6 BA+ 0.098** 0.005 level3 7 1 -2.777** 0.023 8 _cons 9.511** 0.005 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . *As we pointed out in class, this interaction of the highest and lowest ed categor > ies is very negative- the odds of marrying someone with a college degree are much > lower for people with less than HS themselves. . *Now, let's add full educational endogamy into the mix. . desmat: poisson count hed wed edinter level3 ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count Number of observations: 16 Initial log likelihood: -221501.223 Log likelihood: -17940.195 LR chi square: 407122.056 Model degrees of freedom: 11 Pseudo R-squared: 0.919 Prob: 0.000 ------------------------------------------------------------------------------- nr Effect Coeff s.e. ------------------------------------------------------------------------------- count hed 1 HS 0.942** 0.007 2 some col 0.667** 0.007 3 BA+ 0.009 0.007 wed 4 HS 1.132** 0.007 5 some col 0.815** 0.007 6 BA+ -0.276** 0.008 edinter 7 1 1.410** 0.010 8 2 0.796** 0.007 9 3 0.583** 0.007 10 4 2.147** 0.010 level3 11 1 -1.947** 0.023 12 _cons 8.964** 0.008 ------------------------------------------------------------------------------- * p < .05 ** p < .01 . poisgof Goodness-of-fit chi2 = 35694.39 Prob > chi2(4) = 0.0000 . *The point here is that with the full educational interaction accounted for, the c > omparison class for level3 is not all others, but all others who don't marry withi > n their own group. In other words, the coefficient for level3 is smaller here bec > ause it's comparison group is people intermarrying across one or two categories. > Intermarriage across 3 categories is still the most uncommon, but it's a less dram > atic contrast if we account for the tendency of educational endogamy separately. . log close log: C:\AAA Rosie's files\newer web pages\soc_388_notes\soc_388_2002\class 5 > other stuff.log log type: text closed on: 9 Oct 2002, 17:27:05 ------------------------------------------------------------------------------------ /*NOTE: And here below is the last piece of STATA log from Class 5*/ -------------------------------------------------------------------------------------------------- log: :acomp hd (2001-02):save stuff here (temporary):class 5 second try.log log type: text opened on: 9 Oct 2002, 14:20:36 . edit (1 var, 16 obs pasted into editor) (1 var, 16 obs pasted into editor) (1 var, 16 obs pasted into editor) - preserve . gen endogfull=0 . replace endogfull=hed if hed==wed (4 real changes made) . xi: poisson count i.hed i.wed i.endogfull i.hed _Ihed_1-4 (naturally coded; _Ihed_1 omitted) i.wed _Iwed_1-4 (naturally coded; _Iwed_1 omitted) i.endogfull _Iendogfull_0-4 (naturally coded; _Iendogfull_0 omitted) Iteration 0: log likelihood = -79532.519 Iteration 1: log likelihood = -24565.287 Iteration 2: log likelihood = -24059.649 Iteration 3: log likelihood = -24059.274 Iteration 4: log likelihood = -24059.274 Poisson regression Number of obs = 16 LR chi2(10) = 394883.90 Prob > chi2 = 0.0000 Log likelihood = -24059.274 Pseudo R2 = 0.8914 ------------------------------------------------------------------------------ count | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Ihed_2 | 1.134024 .0065936 171.99 0.000 1.1211 1.146947 _Ihed_3 | .8193817 .0063747 128.54 0.000 .8068876 .8318758 _Ihed_4 | -.017068 .0068754 -2.48 0.013 -.0305435 -.0035926 _Iwed_2 | 1.371601 .0067088 204.45 0.000 1.358452 1.38475 _Iwed_3 | 1.020141 .0065921 154.75 0.000 1.007221 1.033061 _Iwed_4 | -.2784974 .0080504 -34.59 0.000 -.2942759 -.2627189 _Iendogful~1 | 1.721607 .0094363 182.45 0.000 1.703112 1.740102 _Iendogful~2 | .6761008 .0068863 98.18 0.000 .6626038 .6895978 _Iendogful~3 | .5370458 .0076002 70.66 0.000 .5221497 .5519419 _Iendogful~4 | 2.487145 .0092388 269.21 0.000 2.469037 2.505252 _cons | 8.652384 .0076032 1137.99 0.000 8.637482 8.667286 ------------------------------------------------------------------------------ . test _Iendogfull_4 -_Iendogfull_3 - not found r(111); . test _Iendogfull_4 -_Iendogfull_3 =0 ( 1) - [count]_Iendogfull_3 + [count]_Iendogfull_4 = 0.0 chi2( 1) =25423.04 Prob > chi2 = 0.0000 . *This test rejects the hypothesis that educational endogamy is the same in group 4 and group 3, > which is consistent with the finding that educational endogamy varies significantly across group > s. . test _Iendogfull_3 -_Iendogfull_2 =0 ( 1) - [count]_Iendogfull_2 + [count]_Iendogfull_3 = 0.0 chi2( 1) = 129.03 Prob > chi2 = 0.0000 . *This one is also significant. . *Even the most similar categories of educational endogamy are significantly different from each > other. . exit, clear