15
___ ____ ____ ____ ____ (R) /__ / ____/ / ____/ ___/ / /___/ / /___/ 14.1 Copyright 1985-2015 StataCorp LP Statistics/Data Analysis StataCorp 4905 Lakeway Drive MP - Parallel Edition College Station, Texas 77845 USA 800-STATA-PC http://www.stata.com 979-696-4600 [email protected] 979-696-4601 (fax) . do "C:\Users\curran\Dropbox\SRA\stata_SEM_input.do" . * read in antisocial data; . use stata_sem_data, clear . . *provide summary statistics; . summarize Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- id | 405 203 117.0577 1 405 male | 405 .5012346 .5006169 0 1 homecog | 405 3.29e-09 2.575799 -7.893827 5.106173 anti6 | 122 1.57377 1.665985 0 9 anti7 | 168 1.553571 1.554437 0 7 -------------+--------------------------------------------------------- anti8 | 146 1.965753 1.798138 0 7 anti9 | 192 1.890625 1.953254 0 9 anti10 | 151 2.139073 2.13554 0 10 anti11 | 174 1.793103 1.948101 0 10 anti12 | 135 1.837037 1.779684 0 7 -------------+--------------------------------------------------------- anti13 | 173 2.236994 2.27126 0 10 Daniel J. Bauer & Patrick J. Curran curranbauer.org 1

Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

___ ____ ____ ____ ____ (R)

/__ / ____/ / ____/

___/ / /___/ / /___/ 14.1 Copyright 1985-2015 StataCorp LP

Statistics/Data Analysis StataCorp

4905 Lakeway Drive

MP - Parallel Edition College Station, Texas 77845 USA

800-STATA-PC http://www.stata.com

979-696-4600 [email protected]

979-696-4601 (fax)

. do "C:\Users\curran\Dropbox\SRA\stata_SEM_input.do"

. * read in antisocial data;

. use stata_sem_data, clear

.

. *provide summary statistics;

. summarize

Variable | Obs Mean Std. Dev. Min Max

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

id | 405 203 117.0577 1 405

male | 405 .5012346 .5006169 0 1

homecog | 405 3.29e-09 2.575799 -7.893827 5.106173

anti6 | 122 1.57377 1.665985 0 9

anti7 | 168 1.553571 1.554437 0 7

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

anti8 | 146 1.965753 1.798138 0 7

anti9 | 192 1.890625 1.953254 0 9

anti10 | 151 2.139073 2.13554 0 10

anti11 | 174 1.793103 1.948101 0 10

anti12 | 135 1.837037 1.779684 0 7

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

anti13 | 173 2.236994 2.27126 0 10

Daniel J. Bauer & Patrick J. Curran curranbauer.org

1

Page 2: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

anti14 | 101 1.960396 2.087682 0 10

.

. * random intercept only model. Stata does not estimate

. * saturated model with empty covariance coverage cells

. * so there are no omnibus measures of fit. You can conduct

. * LRTs of nested models as is done here;

. sem (anti6-anti14 <- Int@1), ///

> noconstant mean(Int) method(mlmv) ///

> satopts(iter(0))

Endogenous variables

Measurement: anti6 anti7 anti8 anti9 anti10 anti11 anti12 anti13 anti14

Exogenous variables

Latent: Int

Fitting saturated model:

Iteration 0: log likelihood = -3678.0687 (not concave)

convergence not achieved

Fitting baseline model:

Iteration 0: log likelihood = -4226.6299

Iteration 1: log likelihood = -3208.2128

Iteration 2: log likelihood = -2827.8188

Iteration 3: log likelihood = -2804.6726

Iteration 4: log likelihood = -2803.3659

Iteration 5: log likelihood = -2803.3434

Iteration 6: log likelihood = -2803.3434

Fitting target model:

Daniel J. Bauer & Patrick J. Curran curranbauer.org

2

Page 3: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

Iteration 0: log likelihood = -3760.2415

Iteration 1: log likelihood = -3039.0489

Iteration 2: log likelihood = -2726.8212

Iteration 3: log likelihood = -2682.3825

Iteration 4: log likelihood = -2662.5225

Iteration 5: log likelihood = -2661.7934

Iteration 6: log likelihood = -2661.7821

Iteration 7: log likelihood = -2661.7821

Structural equation model Number of obs = 405

Estimation method = mlmv

Log likelihood = -2661.7821

( 1) [anti6]Int = 1

( 2) [anti7]Int = 1

( 3) [anti8]Int = 1

( 4) [anti9]Int = 1

( 5) [anti10]Int = 1

( 6) [anti11]Int = 1

( 7) [anti12]Int = 1

( 8) [anti13]Int = 1

( 9) [anti14]Int = 1

(10) [anti6]_cons = 0

(11) [anti7]_cons = 0

(12) [anti8]_cons = 0

(13) [anti9]_cons = 0

(14) [anti10]_cons = 0

(15) [anti11]_cons = 0

(16) [anti12]_cons = 0

(17) [anti13]_cons = 0

(18) [anti14]_cons = 0

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

| OIM

| Coef. Std. Err. z P>|z| [95% Conf. Interval]

Daniel J. Bauer & Patrick J. Curran curranbauer.org

3

Page 4: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

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

Measurement |

anti6 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti7 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti8 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti9 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti10 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti11 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti12 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti13 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti14 <- |

Daniel J. Bauer & Patrick J. Curran curranbauer.org

4

Page 5: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

Int | 1 (constrained)

_cons | 0 (constrained)

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

mean(Int)| 1.874034 .0764558 24.51 0.000 1.724183 2.023885

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

var(e.anti6)| 2.164629 .3624114 1.559092 3.005352

var(e.anti7)| 1.457582 .2253036 1.076614 1.97336

var(e.anti8)| 1.520907 .257803 1.090985 2.120248

var(e.anti9)| 1.911044 .2658652 1.45496 2.510095

var(e.anti10)| 2.261874 .3328971 1.695082 3.018188

var(e.anti11)| 1.864701 .2585046 1.421041 2.446875

var(e.anti12)| 1.67718 .2683736 1.225674 2.29501

var(e.anti13)| 2.770616 .3545415 2.156018 3.560412

var(e.anti14)| 2.215612 .3795747 1.58368 3.099703

var(Int)| 1.719654 .169605 1.41739 2.086378

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

. estat ic

Akaike's information criterion and Bayesian information criterion

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

Model | Obs ll(null) ll(model) df AIC BIC

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

. | 405 . -2661.782 11 5345.564 5389.607

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

Note: N=Obs used in calculating BIC; see [R] BIC note.

. estimates store intercept

.

. *expand random intercept to include random slope;

. sem (anti6 <- Int@1 Slope@0) ///

> (anti7 <- Int@1 Slope@1) ///

> (anti8 <- Int@1 Slope@2) ///

Daniel J. Bauer & Patrick J. Curran curranbauer.org

5

Page 6: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

> (anti9 <- Int@1 Slope@3) ///

> (anti10 <- Int@1 Slope@4) ///

> (anti11 <- Int@1 Slope@5) ///

> (anti12 <- Int@1 Slope@6) ///

> (anti13 <- Int@1 Slope@7) ///

> (anti14 <- Int@1 Slope@8), ///

> noconstant mean(Int Slope) method(mlmv) ///

> satopts(iter(0))

Endogenous variables

Measurement: anti6 anti7 anti8 anti9 anti10 anti11 anti12 anti13 anti14

Exogenous variables

Latent: Int Slope

Fitting saturated model:

Iteration 0: log likelihood = -3678.0687 (not concave)

convergence not achieved

Fitting baseline model:

Iteration 0: log likelihood = -4226.6299

Iteration 1: log likelihood = -3208.2128

Iteration 2: log likelihood = -2827.8188

Iteration 3: log likelihood = -2804.6726

Iteration 4: log likelihood = -2803.3659

Iteration 5: log likelihood = -2803.3434

Iteration 6: log likelihood = -2803.3434

Fitting target model:

Iteration 0: log likelihood = -4211.4153

Daniel J. Bauer & Patrick J. Curran curranbauer.org

6

Page 7: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

Iteration 1: log likelihood = -3573.1643

Iteration 2: log likelihood = -2922.4508

Iteration 3: log likelihood = -2718.5364

Iteration 4: log likelihood = -2646.6955

Iteration 5: log likelihood = -2637.968

Iteration 6: log likelihood = -2637.2241

Iteration 7: log likelihood = -2637.2227

Iteration 8: log likelihood = -2637.2227

Structural equation model Number of obs = 405

Estimation method = mlmv

Log likelihood = -2637.2227

( 1) [anti6]Int = 1

( 2) [anti7]Int = 1

( 3) [anti7]Slope = 1

( 4) [anti8]Int = 1

( 5) [anti8]Slope = 2

( 6) [anti9]Int = 1

( 7) [anti9]Slope = 3

( 8) [anti10]Int = 1

( 9) [anti10]Slope = 4

(10) [anti11]Int = 1

(11) [anti11]Slope = 5

(12) [anti12]Int = 1

(13) [anti12]Slope = 6

(14) [anti13]Int = 1

(15) [anti13]Slope = 7

(16) [anti14]Int = 1

(17) [anti14]Slope = 8

(18) [anti6]_cons = 0

(19) [anti7]_cons = 0

(20) [anti8]_cons = 0

(21) [anti9]_cons = 0

(22) [anti10]_cons = 0

Daniel J. Bauer & Patrick J. Curran curranbauer.org

7

Page 8: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

(23) [anti11]_cons = 0

(24) [anti12]_cons = 0

(25) [anti13]_cons = 0

(26) [anti14]_cons = 0

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

| OIM

| Coef. Std. Err. z P>|z| [95% Conf. Interval]

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

Measurement |

anti6 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti7 <- |

Int | 1 (constrained)

Slope | 1 (constrained)

_cons | 0 (constrained)

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

anti8 <- |

Int | 1 (constrained)

Slope | 2 (constrained)

_cons | 0 (constrained)

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

anti9 <- |

Int | 1 (constrained)

Slope | 3 (constrained)

_cons | 0 (constrained)

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

anti10 <- |

Int | 1 (constrained)

Slope | 4 (constrained)

_cons | 0 (constrained)

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

anti11 <- |

Int | 1 (constrained)

Daniel J. Bauer & Patrick J. Curran curranbauer.org

8

Page 9: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

Slope | 5 (constrained)

_cons | 0 (constrained)

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

anti12 <- |

Int | 1 (constrained)

Slope | 6 (constrained)

_cons | 0 (constrained)

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

anti13 <- |

Int | 1 (constrained)

Slope | 7 (constrained)

_cons | 0 (constrained)

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

anti14 <- |

Int | 1 (constrained)

Slope | 8 (constrained)

_cons | 0 (constrained)

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

mean(Int)| 1.620927 .0858989 18.87 0.000 1.452568 1.789286

mean(Slope)| .0741684 .0179686 4.13 0.000 .0389507 .1093861

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

var(e.anti6)| 1.880947 .374604 1.273074 2.779069

var(e.anti7)| 1.345478 .2644997 .9152584 1.977923

var(e.anti8)| 1.685919 .2897722 1.203744 2.361236

var(e.anti9)| 1.867414 .2513349 1.434424 2.431104

var(e.anti10)| 2.181441 .3232814 1.631543 2.916677

var(e.anti11)| 1.663634 .2486255 1.241218 2.229808

var(e.anti12)| 1.458327 .2736743 1.009521 2.106658

var(e.anti13)| 1.798967 .3372064 1.245862 2.597623

var(e.anti14)| 1.726381 .4135783 1.079492 2.760919

var(Int)| 1.092526 .2919211 .6471307 1.844469

var(Slope)| .026507 .0122341 .0107274 .0654978

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

cov(Int,Slope)| .0504048 .0523689 0.96 0.336 -.0522363 .153046

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

Daniel J. Bauer & Patrick J. Curran curranbauer.org

9

Page 10: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

. estat ic

Akaike's information criterion and Bayesian information criterion

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

Model | Obs ll(null) ll(model) df AIC BIC

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

. | 405 . -2637.223 14 5302.445 5358.5

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

Note: N=Obs used in calculating BIC; see [R] BIC note.

. estimates store slope

.

. *compare intercept to slope model;

. lrtest intercept slope

Likelihood-ratio test LR chi2(3) = 49.12

(Assumption: intercept nested in slope) Prob > chi2 = 0.0000

.

. *regress intercept and slope on gender;

. sem (anti6 <- Int@1 Slope@0) ///

> (anti7 <- Int@1 Slope@1) ///

> (anti8 <- Int@1 Slope@2) ///

> (anti9 <- Int@1 Slope@3) ///

> (anti10 <- Int@1 Slope@4) ///

> (anti11 <- Int@1 Slope@5) ///

> (anti12 <- Int@1 Slope@6) ///

> (anti13 <- Int@1 Slope@7) ///

> (anti14 <- Int@1 Slope@8) ///

> (Int Slope <- male _cons), ///

> noconstant method(mlmv) ///

> cov(e.Int*e.Slope) ///

Daniel J. Bauer & Patrick J. Curran curranbauer.org

10

Page 11: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

> satopts(iter(0))

Endogenous variables

Measurement: anti6 anti7 anti8 anti9 anti10 anti11 anti12 anti13 anti14

Latent: Int Slope

Exogenous variables

Observed: male

Fitting saturated model:

Iteration 0: log likelihood = -3970.7862 (not concave)

convergence not achieved

Fitting baseline model:

Iteration 0: log likelihood = -4522.9248

Iteration 1: log likelihood = -3502.1603

Iteration 2: log likelihood = -3121.7752

Iteration 3: log likelihood = -3098.6183

Iteration 4: log likelihood = -3097.3101

Iteration 5: log likelihood = -3097.2877

Iteration 6: log likelihood = -3097.2877

Fitting target model:

Iteration 0: log likelihood = -3469.2818 (not concave)

Iteration 1: log likelihood = -3276.5351 (not concave)

Iteration 2: log likelihood = -3193.0957

Iteration 3: log likelihood = -2995.8125

Iteration 4: log likelihood = -2922.6702

Iteration 5: log likelihood = -2917.4888

Iteration 6: log likelihood = -2917.267

Daniel J. Bauer & Patrick J. Curran curranbauer.org

11

Page 12: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

Iteration 7: log likelihood = -2917.2666

Iteration 8: log likelihood = -2917.2666

Structural equation model Number of obs = 405

Estimation method = mlmv

Log likelihood = -2917.2666

( 1) [anti6]Int = 1

( 2) [anti7]Int = 1

( 3) [anti7]Slope = 1

( 4) [anti8]Int = 1

( 5) [anti8]Slope = 2

( 6) [anti9]Int = 1

( 7) [anti9]Slope = 3

( 8) [anti10]Int = 1

( 9) [anti10]Slope = 4

(10) [anti11]Int = 1

(11) [anti11]Slope = 5

(12) [anti12]Int = 1

(13) [anti12]Slope = 6

(14) [anti13]Int = 1

(15) [anti13]Slope = 7

(16) [anti14]Int = 1

(17) [anti14]Slope = 8

(18) [anti6]_cons = 0

(19) [anti7]_cons = 0

(20) [anti8]_cons = 0

(21) [anti9]_cons = 0

(22) [anti10]_cons = 0

(23) [anti11]_cons = 0

(24) [anti12]_cons = 0

(25) [anti13]_cons = 0

(26) [anti14]_cons = 0

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

| OIM

Daniel J. Bauer & Patrick J. Curran curranbauer.org

12

Page 13: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

| Coef. Std. Err. z P>|z| [95% Conf. Interval]

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

Structural |

Int <- |

male | .7893683 .1659844 4.76 0.000 .464045 1.114692

_cons | 1.224086 .118655 10.32 0.000 .9915264 1.456646

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

Slope <- |

male | .0138418 .0353927 0.39 0.696 -.0555266 .0832101

_cons | .0664796 .02573 2.58 0.010 .0160496 .1169095

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

Measurement |

anti6 <- |

Int | 1 (constrained)

_cons | 0 (constrained)

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

anti7 <- |

Int | 1 (constrained)

Slope | 1 (constrained)

_cons | 0 (constrained)

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

anti8 <- |

Int | 1 (constrained)

Slope | 2 (constrained)

_cons | 0 (constrained)

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

anti9 <- |

Int | 1 (constrained)

Slope | 3 (constrained)

_cons | 0 (constrained)

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

anti10 <- |

Int | 1 (constrained)

Slope | 4 (constrained)

_cons | 0 (constrained)

Daniel J. Bauer & Patrick J. Curran curranbauer.org

13

Page 14: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

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

anti11 <- |

Int | 1 (constrained)

Slope | 5 (constrained)

_cons | 0 (constrained)

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

anti12 <- |

Int | 1 (constrained)

Slope | 6 (constrained)

_cons | 0 (constrained)

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

anti13 <- |

Int | 1 (constrained)

Slope | 7 (constrained)

_cons | 0 (constrained)

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

anti14 <- |

Int | 1 (constrained)

Slope | 8 (constrained)

_cons | 0 (constrained)

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

var(e.anti6)| 1.900404 .3679826 1.300243 2.777585

var(e.anti7)| 1.376084 .2618432 .9477136 1.99808

var(e.anti8)| 1.706497 .2873164 1.226852 2.373664

var(e.anti9)| 1.859213 .2479688 1.431535 2.414663

var(e.anti10)| 2.18155 .3214478 1.634338 2.911979

var(e.anti11)| 1.637243 .2449502 1.221135 2.195142

var(e.anti12)| 1.466752 .2741375 1.016872 2.115667

var(e.anti13)| 1.836875 .3382532 1.280366 2.635269

var(e.anti14)| 1.740096 .4130059 1.092807 2.770786

var(e.Int)| .9098677 .2831264 .4944327 1.674362

var(e.Slope)| .0250108 .0121018 .0096887 .0645643

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

cov(e.Int,e.Slope)| .0536093 .0513187 1.04 0.296 -.0469735 .1541922

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

Daniel J. Bauer & Patrick J. Curran curranbauer.org

14

Page 15: Daniel J. Bauer & Patrick J. Curran curranbauer€¦ · Note: N=Obs used in calculating BIC; see [R] BIC note. . estimates store slope . . *compare intercept to slope model; . lrtest

. estat ic

Akaike's information criterion and Bayesian information criterion

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

Model | Obs ll(null) ll(model) df AIC BIC

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

. | 405 . -2917.267 16 5866.533 5930.595

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

Note: N=Obs used in calculating BIC; see [R] BIC note.

.

end of do-file

.

Daniel J. Bauer & Patrick J. Curran curranbauer.org

15