use "E:/alda/opposites_pp", clear/* Table 7.2, pg. 246 Conventional multilevel model for change: Opposite naming data, Restricted ML */
xtmixed opp c.time##c.ccog || id: time, reml var cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -630.14238 Iteration 1: log restricted-likelihood = -630.14238
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 191.85 Log restricted-likelihood = -630.14238 Prob > chi2 = 0.0000
------------------------------------------------------------------------------- opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------+---------------------------------------------------------------- time | 26.95998 1.993881 13.52 0.000 23.05205 30.86792 ccog | -.1135527 .5040122 -0.23 0.822 -1.101398 .874293 | c.time#c.ccog | .4328577 .1619279 2.67 0.008 .1154849 .7502306 | _cons | 164.3743 6.206099 26.49 0.000 152.2106 176.538 -------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Unstructured | var(time) | 107.2493 34.67673 56.90847 202.1212 var(_cons) | 1236.414 332.4029 730.0008 2094.135 cov(time,_cons) | -178.2335 85.42989 -345.673 -10.79396 -----------------------------+------------------------------------------------ var(Residual) | 159.477 26.95653 114.5035 222.1147 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(3) = 120.72 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
*Get fit indices. Deviance is 2*ll(model). estat ic
Note: LR test is conservative and provided only for reference.
----------------------------------------------------------------------------- Model | Obs ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 140 . -630.1424 8 1276.285 1299.818 ----------------------------------------------------------------------------- Note: N=Obs used in calculating BIC; see [R] BIC note
/* Table 7.3, pg 258-259 Conventional multilevel model for change: Opposite naming data, Comparing alternative error structures at level-1, with none at level-2 (REML). */
*unstructured xtmixed opp c.time##c.ccog || id: , reml var residuals(un, t(wave)) noconstant
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 (not concave) Iteration 1: log restricted-likelihood = -649.639 (not concave) Iteration 2: log restricted-likelihood = -635.78943 Iteration 3: log restricted-likelihood = -629.54193 Iteration 4: log restricted-likelihood = -627.9217 Iteration 5: log restricted-likelihood = -627.89445 Iteration 6: log restricted-likelihood = -627.89441
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 201.54 Log restricted-likelihood = -627.89441 Prob > chi2 = 0.0000
------------------------------------------------------------------------------- opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------+---------------------------------------------------------------- time | 26.58438 1.925883 13.80 0.000 22.80972 30.35904 ccog | -.0740851 .48346 -0.15 0.878 -1.021649 .873479 | c.time#c.ccog | .4582926 .1564056 2.93 0.003 .1517433 .7648419 | _cons | 165.8321 5.953031 27.86 0.000 154.1644 177.4998 -------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: Unstructured | var(e1) | 1345.128 330.2935 831.2906 2176.579 var(e2) | 1150.476 282.2061 711.3478 1860.686 var(e3) | 1235.77 301.8874 765.5909 1994.704 var(e4) | 1205.957 296.7286 744.5459 1953.313 cov(e1,e2) | 1005.783 277.9786 460.9548 1550.611 cov(e1,e3) | 946.2 276.9843 403.3208 1489.079 cov(e1,e4) | 583.2038 243.6238 105.71 1060.698 cov(e2,e3) | 1028.539 272.8 493.8612 1563.217 cov(e2,e4) | 846.5672 252.12 352.4211 1340.713 cov(e3,e4) | 969.2869 270.7987 438.5313 1500.043 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(9) = 125.22 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative.
*compound symmetry(exchangeable) xtmixed opp c.time##c.ccog || id: , reml var residuals(ex, t(wave)) noconstant
Note: t() not required for this residual structure; ignored
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 Iteration 1: log restricted-likelihood = -643.55637 Iteration 2: log restricted-likelihood = -643.52386 Iteration 3: log restricted-likelihood = -643.52383
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 400.51 Log restricted-likelihood = -643.52383 Prob > chi2 = 0.0000
------------------------------------------------------------------------------- opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------+---------------------------------------------------------------- time | 26.95998 1.375882 19.59 0.000 24.2633 29.65666 ccog | -.1135527 .4618551 -0.25 0.806 -1.018772 .7916667 | c.time#c.ccog | .4328577 .1117387 3.87 0.000 .2138539 .6518616 | _cons | 164.3743 5.687003 28.90 0.000 153.228 175.5206 -------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: Exchangeable | var(e) | 1231.355 244.4357 834.4721 1817 cov(e) | 900.0711 242.2463 425.2771 1374.865 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(1) = 93.96 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative.
*Get level 1 residual variance di 1231.355-900.0711 331.2839
*NOTE: Cannot specify heterogeneous compound symmetry in Stata
*autoregressive xtmixed opp c.time##c.ccog || id: , reml var residuals(ar, t(wave)) noconstant
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 Iteration 1: log restricted-likelihood = -657.30842 (backed up) Iteration 2: log restricted-likelihood = -633.87019 Iteration 3: log restricted-likelihood = -632.93827 Iteration 4: log restricted-likelihood = -632.93822
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 221.36 Log restricted-likelihood = -632.93822 Prob > chi2 = 0.0000
------------------------------------------------------------------------------ opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- time | 27.19789 1.868923 14.55 0.000 23.53487 30.86091 ccog | -.03324 .4856215 -0.07 0.945 -.9850406 .9185605 | c.time#| c.ccog | .4196712 .1517797 2.77 0.006 .1221885 .717154 | _cons | 164.3386 5.979647 27.48 0.000 152.6187 176.0585 ------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: AR(1) | rho | .8253419 .039481 .7308862 .8887751 var(e) | 1256.684 248.2345 853.2712 1850.824 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(1) = 115.13 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative.
*NOTE: Cannot specify heterogeneous autoregressive in Stata
*toeplitz xtmixed opp c.time##c.ccog || id: , reml var residuals(to, t(wave)) noconstant
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 (not concave) Iteration 1: log restricted-likelihood = -666.52768 (not concave) Iteration 2: log restricted-likelihood = -650.58312 (not concave) Iteration 3: log restricted-likelihood = -641.78596 Iteration 4: log restricted-likelihood = -635.6877 Iteration 5: log restricted-likelihood = -629.61415 Iteration 6: log restricted-likelihood = -629.07806 Iteration 7: log restricted-likelihood = -629.0404 Iteration 8: log restricted-likelihood = -629.04035
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 201.71 Log restricted-likelihood = -629.04035 Prob > chi2 = 0.0000
------------------------------------------------------------------------------ opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- time | 26.89541 1.942932 13.84 0.000 23.08734 30.70349 ccog | -.0007047 .4809755 -0.00 0.999 -.9433993 .9419899 | c.time#| c.ccog | .4364364 .1577901 2.77 0.006 .1271735 .7456994 | _cons | 165.0984 5.922439 27.88 0.000 153.4906 176.7062 ------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: Toeplitz(3) | cov1 | 1029.315 239.573 559.7602 1498.869 cov2 | 896.5813 232.7545 440.3909 1352.772 cov3 | 624.0504 234.8921 163.6703 1084.43 var(e) | 1246.887 242.6679 851.4651 1825.942 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(3) = 122.93 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative.
/* Table 7.4, pg 265 Comparing fixed effects in models with alternative error structures */ *Note Stata calculates AIC and BIC differently from SAS (which was used for the book) *Standard error covariance structure
xtmixed opp c.time##c.ccog || id: time, reml var cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -630.14238 Iteration 1: log restricted-likelihood = -630.14238
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 191.85 Log restricted-likelihood = -630.14238 Prob > chi2 = 0.0000
------------------------------------------------------------------------------- opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------+---------------------------------------------------------------- time | 26.95998 1.993881 13.52 0.000 23.05205 30.86792 ccog | -.1135527 .5040122 -0.23 0.822 -1.101398 .874293 | c.time#c.ccog | .4328577 .1619279 2.67 0.008 .1154849 .7502306 | _cons | 164.3743 6.206099 26.49 0.000 152.2106 176.538 -------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Unstructured | var(time) | 107.2493 34.67673 56.90847 202.1212 var(_cons) | 1236.414 332.4029 730.0008 2094.135 cov(time,_cons) | -178.2335 85.42989 -345.673 -10.79396 -----------------------------+------------------------------------------------ var(Residual) | 159.477 26.95653 114.5035 222.1147 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(3) = 120.72 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
* Get fit indices. Deviance is 2*ll(model). estat ic
Note: LR test is conservative and provided only for reference.
----------------------------------------------------------------------------- Model | Obs ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 140 . -630.1424 8 1276.285 1299.818 ----------------------------------------------------------------------------- Note: N=Obs used in calculating BIC; see [R] BIC note
*toeplitz xtmixed opp c.time##c.ccog || id: , reml var residuals(to, t(wave)) noconstant
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 (not concave) Iteration 1: log restricted-likelihood = -666.52768 (not concave) Iteration 2: log restricted-likelihood = -650.58312 (not concave) Iteration 3: log restricted-likelihood = -641.78596 Iteration 4: log restricted-likelihood = -635.6877 Iteration 5: log restricted-likelihood = -629.61415 Iteration 6: log restricted-likelihood = -629.07806 Iteration 7: log restricted-likelihood = -629.0404 Iteration 8: log restricted-likelihood = -629.04035
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 201.71 Log restricted-likelihood = -629.04035 Prob > chi2 = 0.0000
------------------------------------------------------------------------------ opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- time | 26.89541 1.942932 13.84 0.000 23.08734 30.70349 ccog | -.0007047 .4809755 -0.00 0.999 -.9433993 .9419899 | c.time#| c.ccog | .4364364 .1577901 2.77 0.006 .1271735 .7456994 | _cons | 165.0984 5.922439 27.88 0.000 153.4906 176.7062 ------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: Toeplitz(3) | cov1 | 1029.315 239.573 559.7602 1498.869 cov2 | 896.5813 232.7545 440.3909 1352.772 cov3 | 624.0504 234.8921 163.6703 1084.43 var(e) | 1246.887 242.6679 851.4651 1825.942 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(3) = 122.93 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative. * Get fit indices. Deviance is 2*ll(model). estat ic ----------------------------------------------------------------------------- Model | Obs ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 140 . -629.0404 8 1274.081 1297.614 ----------------------------------------------------------------------------- Note: N=Obs used in calculating BIC; see [R] BIC note
* Unstructured xtmixed opp c.time##c.ccog || id: , reml var residuals(un, t(wave)) noconstant
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -690.50483 (not concave) Iteration 1: log restricted-likelihood = -649.639 (not concave) Iteration 2: log restricted-likelihood = -635.78943 Iteration 3: log restricted-likelihood = -629.54193 Iteration 4: log restricted-likelihood = -627.9217 Iteration 5: log restricted-likelihood = -627.89445 Iteration 6: log restricted-likelihood = -627.89441
Computing standard errors:
Mixed-effects REML regression Number of obs = 140 Group variable: id Number of groups = 35
Obs per group: min = 4 avg = 4.0 max = 4
Wald chi2(3) = 201.54 Log restricted-likelihood = -627.89441 Prob > chi2 = 0.0000
------------------------------------------------------------------------------- opp | Coef. Std. Err. z P>|z| [95% Conf. Interval] --------------+---------------------------------------------------------------- time | 26.58438 1.925883 13.80 0.000 22.80972 30.35904 ccog | -.0740851 .48346 -0.15 0.878 -1.021649 .873479 | c.time#c.ccog | .4582926 .1564056 2.93 0.003 .1517433 .7648419 | _cons | 165.8321 5.953031 27.86 0.000 154.1644 177.4998 -------------------------------------------------------------------------------
------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: (empty) | -----------------------------+------------------------------------------------ Residual: Unstructured | var(e1) | 1345.128 330.2935 831.2906 2176.579 var(e2) | 1150.476 282.2061 711.3478 1860.686 var(e3) | 1235.77 301.8874 765.5909 1994.704 var(e4) | 1205.957 296.7286 744.5459 1953.313 cov(e1,e2) | 1005.783 277.9786 460.9548 1550.611 cov(e1,e3) | 946.2 276.9843 403.3208 1489.079 cov(e1,e4) | 583.2038 243.6238 105.71 1060.698 cov(e2,e3) | 1028.539 272.8 493.8612 1563.217 cov(e2,e4) | 846.5672 252.12 352.4211 1340.713 cov(e3,e4) | 969.2869 270.7987 438.5313 1500.043 ------------------------------------------------------------------------------ LR test vs. linear regression: chi2(9) = 125.22 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space. If this is not true, then the reported test is conservative.
* Get fit indices. Deviance is 2*ll(model). estat ic
----------------------------------------------------------------------------- Model | Obs ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 140 . -627.8944 14 1283.789 1324.972 ----------------------------------------------------------------------------- Note: N=Obs used in calculating BIC; see [R] BIC note