GSEMModellingusingStata PDF
GSEMModellingusingStata PDF
• Sample means
• Pearson correlation coefficient
• Student’s t-test
• Linear regression
• Multivariate linear regression
• Seemingly unrelated regression
• Three-stage least squares
Continuous outcome models using SEM
. sysuse auto
storage display value
variable name type format label variable label
mpg 1.0000
weight -0.8072 1.0000
length -0.7958 0.9460 1.0000
var(mpg) 1 . . .
var(weight) 1 . . .
var(length) 1 . . .
Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
Structural
mpg <-
foreign 4.945804 1.343628 3.68 0.000 2.312341 7.579268
_cons 19.82692 .7326131 27.06 0.000 18.39103 21.26282
Structural
mpg <-
weight -.0044303 .0018872 -2.35 0.019 -.0081292 -.0007315
length -.0824511 .053508 -1.54 0.123 -.1873248 .0224226
foreign -1.692645 1.067833 -1.59 0.113 -3.785559 .400268
displacement .0005878 .0096799 0.06 0.952 -.0183845 .0195601
_cons 50.55702 6.083464 8.31 0.000 38.63365 62.48039
weight
price .0570616 .0174226 3.28 0.002 .0223132 .0918099
displacement 5.666956 .7079099 8.01 0.000 4.255074 7.078838
foreign -324.9114 122.9021 -2.64 0.010 -570.0319 -79.79076
_cons 1646.18 131.626 12.51 0.000 1383.661 1908.7
length
price .0006938 .0006547 1.06 0.293 -.0006118 .0019995
displacement .1699625 .0265999 6.39 0.000 .1169107 .2230143
foreign -6.988084 4.618077 -1.51 0.135 -16.19855 2.22238
_cons 152.1992 4.945879 30.77 0.000 142.3349 162.0634
Multivariate Regression Results
Results using sem:
OIM
Coef. Std. Err. z P>|z| [95% Conf. Interval]
Structural
weight <-
price .0570616 .0169452 3.37 0.001 .0238496 .0902736
displacement 5.666956 .6885115 8.23 0.000 4.317498 7.016413
foreign -324.9114 119.5343 -2.72 0.007 -559.1943 -90.6284
_cons 1646.18 128.0192 12.86 0.000 1395.268 1897.093
length <-
price .0006938 .0006367 1.09 0.276 -.0005541 .0019418
displacement .1699625 .025871 6.57 0.000 .1192563 .2206687
foreign -6.988084 4.49153 -1.56 0.120 -15.79132 1.815153
_cons 152.1992 4.81035 31.64 0.000 142.771 161.6273
cov(e.weight,
e.length) 3133.569 573.2375 5.47 0.000 2010.044 4257.094
Seemingly Unrelated Regression Path Diagram
Seemingly Unrelated Regression Syntax
Syntax using sureg:
sureg (price foreign mpg displacement) ///
(weight foreign length), isure
price
foreign 2940.929 691.5458 4.25 0.000 1585.525 4296.334
mpg -105.0163 57.92716 -1.81 0.070 -218.5514 8.518872
displacement 17.22083 4.244966 4.06 0.000 8.900849 25.54081
_cons 4129.866 1942.567 2.13 0.034 322.5047 7937.228
weight
foreign -153.2515 75.33472 -2.03 0.042 -300.9048 -5.598132
length 30.73507 1.528293 20.11 0.000 27.73967 33.73047
_cons -2711.096 301.6777 -8.99 0.000 -3302.374 -2119.819
Seemingly Unrelated Regression Results
Results using sem:
OIM
Coef. Std. Err. z P>|z| [95% Conf. Interval]
Structural
price <-
foreign 2940.929 724.7311 4.06 0.000 1520.482 4361.376
mpg -105.0163 57.93461 -1.81 0.070 -218.566 8.53347
displacement 17.22083 4.5941 3.75 0.000 8.216558 26.2251
_cons 4129.866 1984.253 2.08 0.037 240.8022 8018.931
weight <-
foreign -153.2515 76.21732 -2.01 0.044 -302.6347 -3.868275
length 30.73507 1.584743 19.39 0.000 27.62903 33.84111
_cons -2711.096 312.6813 -8.67 0.000 -3323.94 -2098.252
cov(e.price,
e.weight) 209268 73909.54 2.83 0.005 64407.92 354128
3-Stage Least Squares Path Diagram
3-Stage Least Squares Syntax
Syntax using reg3:
reg3 (mpg = weight length) ///
(weight = price foreign displacement) ///
, sure
mpg
weight -.0038705 .0015516 -2.49 0.013 -.0069116 -.0008295
length -.0752459 .054147 -1.39 0.165 -.181372 .0308802
_cons 47.12534 5.95489 7.91 0.000 35.45397 58.79671
weight
price .0566983 .0169217 3.35 0.001 .0235324 .0898642
foreign -331.9931 119.3554 -2.78 0.005 -565.9254 -98.0608
displacement 5.65145 .6876367 8.22 0.000 4.303707 6.999194
_cons 1653.585 127.892 12.93 0.000 1402.921 1904.248
3-Stage Least Squares Results
Results using sem:
OIM
Coef. Std. Err. z P>|z| [95% Conf. Interval]
Structural
mpg <-
weight -.0038758 .0015516 -2.50 0.012 -.0069168 -.0008347
length -.0739612 .0550842 -1.34 0.179 -.1819243 .0340019
_cons 46.89969 6.219489 7.54 0.000 34.70971 59.08967
weight <-
price .0565862 .0169311 3.34 0.001 .0234018 .0897706
foreign -334.0496 120.3622 -2.78 0.006 -569.9552 -98.14399
displacement 5.645549 .6888778 8.20 0.000 4.295374 6.995725
_cons 1656.051 129.4058 12.80 0.000 1402.421 1909.682
cov(e.mpg,
e.weight) -76.49352 141.2743 -0.54 0.588 -353.3861 200.3991
Outline
• Introduction to SEM concepts and jargon
• Continuous outcome models using SEM
• Generalized outcome models using GSEM
• Multilevel generalized models using GSEM
Generalized outcome models using GSEM
• Logistic regression
• Probit regression
• Multinomial logistic regression
• Ordered logistic regression
• Poisson regression
• Negative binomial regression
Categorical outcome models using GSEM
. use "http://www.stata-press.com/data/r13/gsem_lbw", clear
. gen ptl2 = ptl>0
. label var ptl2 "Any history of premature labor"
. recode bwt (min/2500 = 1 "VeryLow") ///
(2501/3500 = 2 "Low") ///
(3501/max = 3 "Normal") ///
, gen(bwt_cat)
. label var bwt_cat "Birthweight category"
. describe
estat eform
Logistic Regression Results
Results using logistic:
low Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
race
black 2.749483 1.356659 2.05 0.040 1.045318 7.231924
other 2.876948 1.167921 2.60 0.009 1.298314 6.375062
race
white 1 (empty)
black 2.749483 1.356659 2.05 0.040 1.045318 7.231924
other 2.876948 1.167921 2.60 0.009 1.298314 6.375062
Low
age .0383795 .0349615 1.10 0.272 -.0301437 .1069028
race
black -.5139873 .5131883 -1.00 0.317 -1.519818 .4918433
other -.6468109 .4349866 -1.49 0.137 -1.499369 .2057473
Normal
age .0133362 .0428736 0.31 0.756 -.0706946 .097367
race
black -2.587666 .8727109 -2.97 0.003 -4.298148 -.8771839
other -2.003564 .5383297 -3.72 0.000 -3.058671 -.948457
2.bwt_cat <-
age .0383795 .0349615 1.10 0.272 -.0301437 .1069028
race
black -.5139873 .5131883 -1.00 0.317 -1.519818 .4918433
other -.6468109 .4349866 -1.49 0.137 -1.499369 .2057473
3.bwt_cat <-
age .0133362 .0428736 0.31 0.756 -.0706946 .097367
race
black -2.587666 .8727109 -2.97 0.003 -4.298148 -.8771839
other -2.003564 .5383297 -3.72 0.000 -3.058671 -.948457
race
black -1.323717 .4380843 -3.02 0.003 -2.182347 -.465088
other -1.251173 .3399064 -3.68 0.000 -1.917377 -.5849683
bwt_cat <-
age .0192665 .0268696 0.72 0.473 -.033397 .07193
race
black -1.323717 .4380843 -3.02 0.003 -2.182347 -.465088
other -1.251173 .3399064 -3.68 0.000 -1.917377 -.5849683
bwt_cat
/cut1 -1.56245 .7303115 -2.14 0.032 -2.993834 -.1310659
/cut2 .6025144 .7221697 0.83 0.404 -.8129121 2.017941
Poisson Regression Path Diagram
Poisson Regression Syntax
Syntax using poisson:
poisson ftv age i.race smoke
race
black .0336452 .2488814 0.14 0.892 -.4541534 .5214438
other -.2338308 .1988733 -1.18 0.240 -.6236152 .1559537
ftv <-
age .0459009 .0144906 3.17 0.002 .0175 .0743019
race
black .0336452 .2488814 0.14 0.892 -.4541534 .5214438
other -.2338308 .1988733 -1.18 0.240 -.6236152 .1559537
q1 <-
MathAbility 1 (constrained)
_cons .0373365 .1252279 0.30 0.766 -.2081058 .2827787
q2 <-
MathAbility .381626 .116809 3.27 0.001 .1526845 .6105674
_cons -.4613391 .0989722 -4.66 0.000 -.655321 -.2673571
q3 <-
MathAbility .4993762 .134314 3.72 0.000 .2361255 .7626269
_cons .1533362 .1006072 1.52 0.127 -.0438503 .3505228
q4 <-
MathAbility .3299698 .1063034 3.10 0.002 .1216189 .5383207
_cons -.3230667 .0957983 -3.37 0.001 -.510828 -.1353054
q5 <-
MathAbility .8401762 .1995336 4.21 0.000 .4490975 1.231255
_cons -.0494684 .1163093 -0.43 0.671 -.2774304 .1784937
q6 <-
MathAbility .6453722 .1639865 3.94 0.000 .3239646 .9667798
_cons -.314723 .1083049 -2.91 0.004 -.5269968 -.1024493
q7 <-
MathAbility .8163613 .2045448 3.99 0.000 .4154609 1.217262
_cons .1053404 .1152979 0.91 0.361 -.1206393 .3313201
q8 <-
MathAbility .5769516 .1473524 3.92 0.000 .2881463 .865757
_cons -.026705 .1034396 -0.26 0.796 -.2294429 .1760328
MathAttitude 1 (constrained)
att2 <-
MathAttitude .3651316 .0947737 3.85 0.000 .1793785 .5508846
att3 <-
MathAttitude -1.325592 .3281752 -4.04 0.000 -1.968803 -.6823802
att4 <-
MathAttitude -.7319336 .1476384 -4.96 0.000 -1.0213 -.4425677
att5 <-
MathAttitude .4629576 .1117098 4.14 0.000 .2440104 .6819047
att1
/cut1 -1.14403 .1407016 -8.13 0.000 -1.4198 -.8682596
/cut2 -.2571716 .1208793 -2.13 0.033 -.4940907 -.0202526
/cut3 .3113316 .121399 2.56 0.010 .0733939 .5492693
/cut4 1.38373 .1505219 9.19 0.000 1.088713 1.678748
att2
/cut1 -1.058352 .1069425 -9.90 0.000 -1.267955 -.8487485
/cut2 -.1920422 .0946322 -2.03 0.042 -.3775179 -.0065665
/cut3 .3639243 .0957805 3.80 0.000 .1761979 .5516506
/cut4 1.139819 .1090449 10.45 0.000 .9260952 1.353543
att3
/cut1 -1.003196 .1634751 -6.14 0.000 -1.323601 -.6827905
/cut2 -.0511457 .1372565 -0.37 0.709 -.3201635 .2178721
/cut3 .5278704 .1454233 3.63 0.000 .2428459 .8128949
/cut4 1.587917 .1989801 7.98 0.000 1.197923 1.977911
att4
/cut1 -1.071316 .1214149 -8.82 0.000 -1.309285 -.8333473
/cut2 -.212007 .1074834 -1.97 0.049 -.4226707 -.0013434
/cut3 .4028505 .1092331 3.69 0.000 .1887576 .6169435
/cut4 1.393148 .1312299 10.62 0.000 1.135942 1.650354
att5
/cut1 -1.242513 .1147059 -10.83 0.000 -1.467332 -1.017693
/cut2 -.339867 .0983909 -3.45 0.001 -.5327096 -.1470243
/cut3 .2076369 .0974768 2.13 0.033 .0165858 .3986879
/cut4 .9211489 .1067054 8.63 0.000 .7120101 1.130288
school: Identity
var(_cons) 7.410363 2.697303 3.630865 15.12408
test1 <-
M1[school] 1 (constrained)
id: Unstructured
var(time) .0196198 .0031082 .0143829 .0267635
var(_cons) .5274091 .0446436 .4467824 .6225859
cov(time,_cons) -.034316 .0088848 -.0517298 -.0169022
cov(Intercept,
Slope) -.034316 .0088848 -3.86 0.000 -.0517298 -.0169022
Poisson Latent Growth Curve Data
(data in long format)
subject
var(time) .0211453 .0091765 .0090326 .0495009
var(_cons) .9545034 .2064406 .6247109 1.458397
subject
cov(_cons,time) -.0362171 .0337022 -1.07 0.283 -.1022722 .0298379
Poisson Latent Growth Curve Path Diagram
(data in long format)
seizures <-
time -.0503416 .0355162 -1.42 0.156 -.119952 .0192689
c.time#
S[subject] 1 (constrained)
I[subject] 1 (constrained)
cov(I[subject],
S[subject]) -.0362171 .0337022 -1.07 0.283 -.1022722 .0298379
Poisson Latent Growth Curve Data
(data in wide format)
seizures0 <-
Intercept 1 (constrained)
Slope 0 (omitted)
_cons 0 (omitted)
seizures1 <-
Intercept 1 (constrained)
Slope 1 (constrained)
_cons 0 (omitted)
seizures2 <-
Intercept 1 (constrained)
Slope 2 (constrained)
_cons 0 (omitted)
seizures3 <-
Intercept 1 (constrained)
Slope 3 (constrained)
_cons 0 (omitted)
cov(Slope,
Intercept) -.0362289 .0339178 -1.07 0.285 -.1027065 .0302486
Multilevel GSEM Data
. use http://www.stata-press.com/data/r13/gsem_cfa, clear
. describe