. * do-file for lecture 7 of VHM 802, Winter 2025 . version 18 /* works also with versions 14-17 */ . set more off . set scheme stcolor_alt . cd "r:\" r:\ . . import delimited ch08ta6.csv, clear /* Example 8.6 */ (encoding automatically selected: UTF-8) (3 vars, 12 obs) . anova tfaa r50 r21 r50#r21 /* same with r50##r21 only */ Number of obs = 12 R-squared = 0.5459 Root MSE = .301177 Adj R-squared = 0.3756 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | .87231412 3 .29077137 3.21 0.0834 | r50 | .65613639 1 .65613639 7.23 0.0275 r21 | .21440139 1 .21440139 2.36 0.1627 r50#r21 | .00177634 1 .00177634 0.02 0.8922 | Residual | .72566253 8 .09070782 -----------+---------------------------------------------------- Total | 1.5979766 11 .1452706 . regress /* Stata parametrization; note different P-values! */ Source | SS df MS Number of obs = 12 -------------+---------------------------------- F(3, 8) = 3.21 Model | .872314116 3 .290771372 Prob > F = 0.0834 Residual | .725662525 8 .090707816 R-squared = 0.5459 -------------+---------------------------------- Adj R-squared = 0.3756 Total | 1.59797664 11 .145270604 Root MSE = .30118 ------------------------------------------------------------------------------ tfaa | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- 1.r50 | .4433333 .2459103 1.80 0.109 -.1237369 1.010403 1.r21 | .243 .2459103 0.99 0.352 -.3240702 .8100702 | r50#r21 | 1 1 | .0486668 .3477697 0.14 0.892 -.7532916 .8506251 | _cons | 1.709333 .1738848 9.83 0.000 1.308354 2.110313 ------------------------------------------------------------------------------ . * interaction plot . margins r50#r21 Adjusted predictions Number of obs = 12 Expression: Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- r50#r21 | 0 0 | 1.709333 .1738848 9.83 0.000 1.308354 2.110313 0 1 | 1.952333 .1738848 11.23 0.000 1.551354 2.353312 1 0 | 2.152667 .1738848 12.38 0.000 1.751687 2.553646 1 1 | 2.444333 .1738848 14.06 0.000 2.043354 2.845313 ------------------------------------------------------------------------------ . marginsplot, noci /* CIs often look messy */ Variables that uniquely identify margins: r50 r21 . * contrasts for SS decomposition computed manually . egen tx=group(r50 r21) /* combined tx variable */ . table tx r50 r21, nototal /* check of coding: 2 ~ r50=0, r21=1, etc. */ ----------------------- | r21 | 0 1 ---------------+------- group(r50 r21) | 1 | r50 | 0 | 3 2 | r50 | 0 | 3 3 | r50 | 1 | 3 4 | r50 | 1 | 3 ----------------------- . anova tfaa tx Number of obs = 12 R-squared = 0.5459 Root MSE = .301177 Adj R-squared = 0.3756 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | .87231412 3 .29077137 3.21 0.0834 | tx | .87231412 3 .29077137 3.21 0.0834 | Residual | .72566253 8 .09070782 -----------+---------------------------------------------------- Total | 1.5979766 11 .1452706 . lincom 1.tx+2.tx-3.tx-4.tx /* r50 */ ( 1) 1b.tx + 2.tx - 3.tx - 4.tx = 0 ------------------------------------------------------------------------------ tfaa | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | -.9353334 .3477697 -2.69 0.028 -1.737292 -.133375 ------------------------------------------------------------------------------ . lincom 1.tx-2.tx+3.tx-4.tx /* r21 */ ( 1) 1b.tx - 2.tx + 3.tx - 4.tx = 0 ------------------------------------------------------------------------------ tfaa | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | -.5346667 .3477697 -1.54 0.163 -1.336625 .2672916 ------------------------------------------------------------------------------ . lincom 1.tx-2.tx-3.tx+4.tx /* r50*r21 */ ( 1) 1b.tx - 2.tx - 3.tx + 4.tx = 0 ------------------------------------------------------------------------------ tfaa | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- (1) | .0486668 .3477697 0.14 0.892 -.7532916 .8506251 ------------------------------------------------------------------------------ . . import delimited ch08ta7.csv, clear /* Example 8.8 */ (encoding automatically selected: ISO-8859-1) (5 vars, 54 obs) . generate lnfault=ln(fault) . anova lnfault alg##seq##size##alloc /* DFE=0 */ Number of obs = 54 R-squared = 1.0000 Root MSE = 0 Adj R-squared = Source | Partial SS df MS F Prob>F -------------------+---------------------------------------------------- Model | 173.59316 53 3.2753426 | alg | 2.5018375 1 2.5018375 seq | 24.639254 2 12.319627 alg#seq | .01763693 2 .00881847 size | 41.691651 2 20.845825 alg#size | .02221451 2 .01110725 seq#size | .82895746 4 .20723936 alg#seq#size | .01456402 4 .00364101 alloc | 92.697301 2 46.34865 alg#alloc | .06003955 2 .03001977 seq#alloc | 9.5104704 4 2.3776176 alg#seq#alloc | .02600767 4 .00650192 size#alloc | .50430485 4 .12607621 alg#size#alloc | .00400155 4 .00100039 seq#size#alloc | 1.0521223 8 .13151529 alg#seq#size#alloc | .02279619 8 .00284952 | Residual | 0 0 -------------------+---------------------------------------------------- Total | 173.59316 53 3.2753426 . anova lnfault alg##seq##size alg##seq##alloc alg##size##alloc seq##size##alloc Number of obs = 54 R-squared = 0.9999 Root MSE = .053381 Adj R-squared = 0.9991 Source | Partial SS df MS F Prob>F ---------------+---------------------------------------------------- Model | 173.57036 45 3.8571192 1353.60 0.0000 | alg | 2.5018375 1 2.5018375 877.98 0.0000 seq | 24.639254 2 12.319627 4323.40 0.0000 alg#seq | .01763693 2 .00881847 3.09 0.1010 size | 41.691651 2 20.845825 7315.55 0.0000 alg#size | .02221451 2 .01110725 3.90 0.0658 seq#size | .82895746 4 .20723936 72.73 0.0000 alg#seq#size | .01456402 4 .00364101 1.28 0.3548 alloc | 92.697301 2 46.34865 16265.40 0.0000 alg#alloc | .06003955 2 .03001977 10.54 0.0057 seq#alloc | 9.5104704 4 2.3776176 834.39 0.0000 alg#seq#alloc | .02600767 4 .00650192 2.28 0.1491 size#alloc | .50430485 4 .12607621 44.24 0.0000 alg#size#alloc | .00400155 4 .00100039 0.35 0.8365 seq#size#alloc | 1.0521223 8 .13151529 46.15 0.0000 | Residual | .02279619 8 .00284952 ---------------+---------------------------------------------------- Total | 173.59316 53 3.2753426 . . import delimited ch10ta1.csv, clear /* Example 10.3 */ (encoding automatically selected: ISO-8859-1) (3 vars, 17 obs) . anova y a##b /* partial SS */ Number of obs = 17 R-squared = 0.6632 Root MSE = 10.6004 Adj R-squared = 0.5855 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | 2876.8803 3 958.9601 8.53 0.0022 | a | 499.95134 1 499.95134 4.45 0.0549 b | 265.47133 1 265.47133 2.36 0.1483 a#b | 65.244557 1 65.244557 0.58 0.4597 | Residual | 1460.789 13 112.36839 -----------+---------------------------------------------------- Total | 4337.6693 16 271.10433 . anova y a##b, sequential /* SS for b without interaction */ Number of obs = 17 R-squared = 0.6632 Root MSE = 10.6004 Adj R-squared = 0.5855 Source | Seq. SS df MS F Prob>F -----------+---------------------------------------------------- Model | 2876.8803 3 958.9601 8.53 0.0022 | a | 2557.0039 1 2557.0039 22.76 0.0004 b | 254.63187 1 254.63187 2.27 0.1561 a#b | 65.244557 1 65.244557 0.58 0.4597 | Residual | 1460.789 13 112.36839 -----------+---------------------------------------------------- Total | 4337.6693 16 271.10433 . anova y b##a, sequential /* SS for a without interaction */ Number of obs = 17 R-squared = 0.6632 Root MSE = 10.6004 Adj R-squared = 0.5855 Source | Seq. SS df MS F Prob>F -----------+---------------------------------------------------- Model | 2876.8803 3 958.9601 8.53 0.0022 | b | 2326.3487 1 2326.3487 20.70 0.0005 a | 485.28704 1 485.28704 4.32 0.0581 b#a | 65.244557 1 65.244557 0.58 0.4597 | Residual | 1460.789 13 112.36839 -----------+---------------------------------------------------- Total | 4337.6693 16 271.10433 . . import delimited ch09ta2.csv, clear /* Example 9.2 */ (encoding automatically selected: ISO-8859-1) (5 vars, 32 obs) . anova y a##b##c##d Number of obs = 32 R-squared = 0.9881 Root MSE = 1.01458 Adj R-squared = 0.9769 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | 1367.1988 15 91.146585 88.55 0.0000 | a | 120.90125 1 120.90125 117.45 0.0000 b | 204.02001 1 204.02001 198.20 0.0000 a#b | 18.000003 1 18.000003 17.49 0.0007 c | 472.78124 1 472.78124 459.29 0.0000 a#c | 24.851261 1 24.851261 24.14 0.0002 b#c | 27.380001 1 27.380001 26.60 0.0001 a#b#c | 11.519999 1 11.519999 11.19 0.0041 d | 335.40503 1 335.40503 325.83 0.0000 a#d | 15.125003 1 15.125003 14.69 0.0015 b#d | 10.81125 1 10.81125 10.50 0.0051 a#b#d | 34.031238 1 34.031238 33.06 0.0000 c#d | 6.4800031 1 6.4800031 6.30 0.0232 a#c#d | 50.000005 1 50.000005 48.57 0.0000 b#c#d | 22.111251 1 22.111251 21.48 0.0003 a#b#c#d | 13.781253 1 13.781253 13.39 0.0021 | Residual | 16.469993 16 1.0293746 -----------+---------------------------------------------------- Total | 1383.6688 31 44.634477 . egen ab=group(a b) . egen cd=group(c d) . anova y ab##cd Number of obs = 32 R-squared = 0.9881 Root MSE = 1.01458 Adj R-squared = 0.9769 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | 1367.1988 15 91.146585 88.55 0.0000 | ab | 342.92125 3 114.30708 111.05 0.0000 cd | 814.66627 3 271.55542 263.81 0.0000 ab#cd | 209.61126 9 23.29014 22.63 0.0000 | Residual | 16.469993 16 1.0293746 -----------+---------------------------------------------------- Total | 1383.6688 31 44.634477 . margins ab#cd Adjusted predictions Number of obs = 32 Expression: Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- ab#cd | 1 1 | 26.8 .7174171 37.36 0.000 25.27914 28.32086 1 2 | 22.3 .7174171 31.08 0.000 20.77914 23.82086 1 3 | 23.3 .7174171 32.48 0.000 21.77914 24.82086 1 4 | 31.55 .7174171 43.98 0.000 30.02914 33.07086 2 1 | 21.1 .7174171 29.41 0.000 19.57914 22.62086 2 2 | 29 .7174171 40.42 0.000 27.47914 30.52086 2 3 | 29.65 .7174171 41.33 0.000 28.12914 31.17086 2 4 | 38.4 .7174171 53.53 0.000 36.87914 39.92086 3 1 | 11.2 .7174171 15.61 0.000 9.679144 12.72086 3 2 | 21.2 .7174171 29.55 0.000 19.67914 22.72086 3 3 | 21.25 .7174171 29.62 0.000 19.72914 22.77086 3 4 | 28.75 .7174171 40.07 0.000 27.22914 30.27086 4 1 | 17.65 .7174171 24.60 0.000 16.12914 19.17086 4 2 | 26.55 .7174171 37.01 0.000 25.02914 28.07086 4 3 | 29.7 .7174171 41.40 0.000 28.17914 31.22086 4 4 | 34.7 .7174171 48.37 0.000 33.17914 36.22086 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: ab cd . generate cell_1111=(a==1)*(b==1)*(c==1)*(d==1) . anova y a b c d cell_1111 a##b##c##d, sequential /* note order! */ Number of obs = 32 R-squared = 0.9881 Root MSE = 1.01458 Adj R-squared = 0.9769 Source | Seq. SS df MS F Prob>F -----------+---------------------------------------------------- Model | 1367.1988 15 91.146585 88.55 0.0000 | a | 120.90125 1 120.90125 117.45 0.0000 b | 204.02001 1 204.02001 198.20 0.0000 c | 472.78124 1 472.78124 459.29 0.0000 d | 335.40503 1 335.40503 325.83 0.0000 cell_1111 | 217.35104 1 217.35104 211.15 0.0000 a#b | .04510221 1 .04510221 0.04 0.8368 a#c | .30012612 1 .30012612 0.29 0.5967 b#c | .765625 1 .765625 0.74 0.4012 a#b#c | .9472327 1 .9472327 0.92 0.3517 a#d | .34714256 1 .34714256 0.34 0.5695 b#d | 1.8375 1 1.8375 1.79 0.2002 a#b#d | 1.4062471 1 1.4062471 1.37 0.2596 c#d | 5.1337486 1 5.1337486 4.99 0.0402 a#c#d | 5.4675005 1 5.4675005 5.31 0.0349 b#c#d | .48999973 1 .48999973 0.48 0.5001 a#b#c#d | 0 0 | Residual | 16.469993 16 1.0293746 -----------+---------------------------------------------------- Total | 1383.6688 31 44.634477 . anova y a b c d cell_1111 Number of obs = 32 R-squared = 0.9760 Root MSE = 1.13018 Adj R-squared = 0.9714 Source | Partial SS df MS F Prob>F -----------+---------------------------------------------------- Model | 1350.4586 5 270.09171 211.45 0.0000 | a | 39.331851 1 39.331851 30.79 0.0000 b | 321.53343 1 321.53343 251.73 0.0000 c | 628.69227 1 628.69227 492.20 0.0000 d | 474.81596 1 474.81596 371.73 0.0000 cell_1111 | 217.35104 1 217.35104 170.16 0.0000 | Residual | 33.210218 26 1.2773161 -----------+---------------------------------------------------- Total | 1383.6688 31 44.634477 . . import delimited ch08ta9.csv, clear /* Example 8.10 */ (encoding automatically selected: ISO-8859-2) (7 vars, 96 obs) . egen tx=group(at gt v) . xi: boxcox amylase i.tx i.tx _Itx_1-32 (naturally coded; _Itx_1 omitted) Fitting comparison model Iteration 0: Log likelihood = -542.90683 Iteration 1: Log likelihood = -542.5619 Iteration 2: Log likelihood = -542.56179 Iteration 3: Log likelihood = -542.56179 Fitting full model Iteration 0: Log likelihood = -427.06096 Iteration 1: Log likelihood = -424.07141 Iteration 2: Log likelihood = -424.06421 Iteration 3: Log likelihood = -424.06421 Number of obs = 96 LR chi2(31) = 237.00 Log likelihood = -424.06421 Prob > chi2 = 0.000 ------------------------------------------------------------------------------ amylase | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- /theta | .0199989 .3958468 0.05 0.960 -.7558465 .7958443 ------------------------------------------------------------------------------ Estimates of scale-variant parameters ---------------------------- | Coefficient -------------+-------------- Notrans | _Itx_2 | -.2257092 _Itx_3 | -.1653663 _Itx_4 | -.3410324 _Itx_5 | .2061606 _Itx_6 | -.0799097 _Itx_7 | .096261 _Itx_8 | .0100406 _Itx_9 | .3149527 _Itx_10 | .0366516 _Itx_11 | .1889919 _Itx_12 | .1886505 _Itx_13 | .2654907 _Itx_14 | .0600479 _Itx_15 | .1791769 _Itx_16 | .1178467 _Itx_17 | .1514475 _Itx_18 | .0031704 _Itx_19 | .0760831 _Itx_20 | -.1154264 _Itx_21 | -.0755018 _Itx_22 | -.2582509 _Itx_23 | -.0948975 _Itx_24 | -.2019227 _Itx_25 | -.1874994 _Itx_26 | -.4267404 _Itx_27 | -.203189 _Itx_28 | -.3183826 _Itx_29 | -.2422305 _Itx_30 | -.6219556 _Itx_31 | -.3050953 _Itx_32 | -.4370663 _cons | 6.232128 -------------+-------------- /sigma | .0677822 ---------------------------- --------------------------------------------------------- Test Restricted LR statistic H0: log likelihood chi2 Prob > chi2 --------------------------------------------------------- theta = -1 -427.42898 6.73 0.009 theta = 0 -424.06549 0.00 0.960 theta = 1 -427.06096 5.99 0.014 --------------------------------------------------------- . generate lnam=ln(amylase) . anova lnam atemp##gtemp##v Number of obs = 96 R-squared = 0.9168 Root MSE = .073916 Adj R-squared = 0.8765 Source | Partial SS df MS F Prob>F --------------+---------------------------------------------------- Model | 3.8523521 31 .12426942 22.74 0.0000 | atemp | 3.0161274 7 .43087535 78.86 0.0000 gtemp | .00437953 1 .00437953 0.80 0.3740 atemp#gtemp | .08105969 7 .01157996 2.12 0.0539 v | .58956976 1 .58956976 107.91 0.0000 atemp#v | .02758221 7 .00394032 0.72 0.6544 gtemp#v | .08599279 1 .08599279 15.74 0.0002 atemp#gtemp#v | .04764068 7 .00680581 1.25 0.2916 | Residual | .34967081 64 .00546361 --------------+---------------------------------------------------- Total | 4.2020229 95 .04423182 . anova lnam atemp##gtemp gtemp##v Number of obs = 96 R-squared = 0.8989 Root MSE = .073806 Adj R-squared = 0.8768 Source | Partial SS df MS F Prob>F ------------+---------------------------------------------------- Model | 3.7771292 17 .22218407 40.79 0.0000 | atemp | 3.0161274 7 .43087535 79.10 0.0000 gtemp | .00437953 1 .00437953 0.80 0.3727 atemp#gtemp | .08105969 7 .01157996 2.13 0.0504 v | .58956976 1 .58956976 108.23 0.0000 gtemp#v | .08599279 1 .08599279 15.79 0.0002 | Residual | .4248937 78 .00544736 ------------+---------------------------------------------------- Total | 4.2020229 95 .04423182 . * atemp modelled as continuous . anova lnam c.atemp##gtemp gtemp##v Number of obs = 96 R-squared = 0.3786 Root MSE = .170336 Adj R-squared = 0.3440 Source | Partial SS df MS F Prob>F ------------+---------------------------------------------------- Model | 1.5907417 5 .31814835 10.97 0.0000 | atemp | .87537029 1 .87537029 30.17 0.0000 gtemp | .0214632 1 .0214632 0.74 0.3920 gtemp#atemp | .03542937 1 .03542937 1.22 0.2721 v | .58956976 1 .58956976 20.32 0.0000 gtemp#v | .08599279 1 .08599279 2.96 0.0886 | Residual | 2.6112812 90 .02901424 ------------+---------------------------------------------------- Total | 4.2020229 95 .04423182 . anova lnam c.atemp##c.atemp##gtemp gtemp##v Number of obs = 96 R-squared = 0.8759 Root MSE = .07698 Adj R-squared = 0.8660 Source | Partial SS df MS F Prob>F ------------------+---------------------------------------------------- Model | 3.6805469 7 .52579241 88.73 0.0000 | atemp | 2.4887306 1 2.4887306 419.98 0.0000 atemp#atemp | 2.0897161 1 2.0897161 352.64 0.0000 gtemp | .00217869 1 .00217869 0.37 0.5458 gtemp#atemp | .00044304 1 .00044304 0.07 0.7852 gtemp#atemp#atemp | .00008904 1 .00008904 0.02 0.9027 v | .58956976 1 .58956976 99.49 0.0000 gtemp#v | .08599279 1 .08599279 14.51 0.0003 | Residual | .52147602 88 .00592586 ------------------+---------------------------------------------------- Total | 4.2020229 95 .04423182 . anova lnam c.atemp##c.atemp##c.atemp##gtemp gtemp##v Number of obs = 96 R-squared = 0.8928 Root MSE = .072366 Adj R-squared = 0.8816 Source | Partial SS df MS F Prob>F ------------------------+---------------------------------------------------- Model | 3.7516521 9 .41685023 79.60 0.0000 | atemp | .02573811 1 .02573811 4.91 0.0293 atemp#atemp | .00253925 1 .00253925 0.48 0.4881 atemp#atemp#atemp | .04199339 1 .04199339 8.02 0.0058 gtemp | .03099672 1 .03099672 5.92 0.0171 gtemp#atemp | .02921493 1 .02921493 5.58 0.0204 gtemp#atemp#atemp | .02844537 1 .02844537 5.43 0.0221 gtemp#atemp#atemp#atemp | .0291118 1 .0291118 5.56 0.0207 v | .58956976 1 .58956976 112.58 0.0000 gtemp#v | .08599279 1 .08599279 16.42 0.0001 | Residual | .45037083 86 .00523687 ------------------------+---------------------------------------------------- Total | 4.2020229 95 .04423182 . margins gtemp, at(atemp=(10 13 15 20 25 30 35 40) v=1) Adjusted predictions Number of obs = 96 Expression: Linear prediction, predict() 1._at: atemp = 10 v = 1 2._at: atemp = 13 v = 1 3._at: atemp = 15 v = 1 4._at: atemp = 20 v = 1 5._at: atemp = 25 v = 1 6._at: atemp = 30 v = 1 7._at: atemp = 35 v = 1 8._at: atemp = 40 v = 1 ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- _at#gtemp | 1 13 | 5.595335 .0284702 196.53 0.000 5.538738 5.651932 1 25 | 5.573485 .0284702 195.77 0.000 5.516889 5.630082 2 13 | 5.694202 .0192363 296.01 0.000 5.655961 5.732442 2 25 | 5.74282 .0192363 298.54 0.000 5.70458 5.781061 3 13 | 5.763676 .0201874 285.51 0.000 5.723545 5.803807 3 25 | 5.839836 .0201874 289.28 0.000 5.799705 5.879968 4 13 | 5.929477 .0215916 274.62 0.000 5.886555 5.9724 4 25 | 6.024958 .0215916 279.04 0.000 5.982036 6.067881 5 13 | 6.049121 .0199476 303.25 0.000 6.009467 6.088776 5 25 | 6.124867 .0199476 307.05 0.000 6.085212 6.164521 6 13 | 6.078989 .022342 272.09 0.000 6.034575 6.123404 6 25 | 6.135579 .022342 274.62 0.000 6.091164 6.179993 7 13 | 5.975465 .0222794 268.21 0.000 5.931175 6.019755 7 25 | 6.053109 .0222794 271.69 0.000 6.008819 6.097399 8 13 | 5.69493 .0302704 188.14 0.000 5.634754 5.755105 8 25 | 5.873475 .0302704 194.03 0.000 5.8133 5.933651 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: atemp gtemp . margins gtemp, at(atemp=(10 13 15 20 25 30 35 40) v=2) Adjusted predictions Number of obs = 96 Expression: Linear prediction, predict() 1._at: atemp = 10 v = 2 2._at: atemp = 13 v = 2 3._at: atemp = 15 v = 2 4._at: atemp = 20 v = 2 5._at: atemp = 25 v = 2 6._at: atemp = 30 v = 2 7._at: atemp = 35 v = 2 8._at: atemp = 40 v = 2 ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- _at#gtemp | 1 13 | 5.498459 .0284702 193.13 0.000 5.441863 5.555056 1 25 | 5.356894 .0284702 188.16 0.000 5.300297 5.41349 2 13 | 5.597327 .0192363 290.98 0.000 5.559086 5.635567 2 25 | 5.526228 .0192363 287.28 0.000 5.487988 5.564469 3 13 | 5.666801 .0201874 280.71 0.000 5.62667 5.706932 3 25 | 5.623244 .0201874 278.55 0.000 5.583113 5.663376 4 13 | 5.832602 .0215916 270.13 0.000 5.78968 5.875525 4 25 | 5.808366 .0215916 269.01 0.000 5.765444 5.851289 5 13 | 5.952246 .0199476 298.39 0.000 5.912592 5.9919 5 25 | 5.908275 .0199476 296.19 0.000 5.86862 5.947929 6 13 | 5.982114 .022342 267.75 0.000 5.9377 6.026529 6 25 | 5.918987 .022342 264.93 0.000 5.874572 5.963401 7 13 | 5.87859 .0222794 263.86 0.000 5.8343 5.92288 7 25 | 5.836517 .0222794 261.97 0.000 5.792227 5.880807 8 13 | 5.598055 .0302704 184.94 0.000 5.537879 5.65823 8 25 | 5.656883 .0302704 186.88 0.000 5.596708 5.717059 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: atemp gtemp . margins gtemp, at(atemp=(10 13 15 20 25 30 35 40) v=2) expression(exp(predict(xb))) Adjusted predictions Number of obs = 96 Expression: exp(predict(xb)) 1._at: atemp = 10 v = 2 2._at: atemp = 13 v = 2 3._at: atemp = 15 v = 2 4._at: atemp = 20 v = 2 5._at: atemp = 25 v = 2 6._at: atemp = 30 v = 2 7._at: atemp = 35 v = 2 8._at: atemp = 40 v = 2 ------------------------------------------------------------------------------ | Delta-method | Margin std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- _at#gtemp | 1 13 | 244.3153 6.955715 35.12 0.000 230.6823 257.9482 1 25 | 212.0651 6.037546 35.12 0.000 200.2318 223.8985 2 13 | 269.7044 5.188123 51.98 0.000 259.5359 279.8729 2 25 | 251.1947 4.832065 51.98 0.000 241.7241 260.6654 3 13 | 289.1082 5.836339 49.54 0.000 277.6692 300.5472 3 25 | 276.7859 5.587586 49.54 0.000 265.8345 287.7374 4 13 | 341.2455 7.36803 46.31 0.000 326.8045 355.6866 4 25 | 333.0745 7.191605 46.31 0.000 318.9792 347.1698 5 13 | 384.6162 7.672156 50.13 0.000 369.5791 399.6534 5 25 | 368.0706 7.342112 50.13 0.000 353.6804 382.4609 6 13 | 396.2773 8.853631 44.76 0.000 378.9245 413.6301 6 25 | 372.0345 8.311998 44.76 0.000 355.7433 388.3257 7 13 | 357.305 7.960555 44.88 0.000 341.7026 372.9074 7 25 | 342.5841 7.632584 44.88 0.000 327.6246 357.5437 8 13 | 269.9008 8.170002 33.04 0.000 253.8879 285.9137 8 25 | 286.2551 8.665051 33.04 0.000 269.2719 303.2383 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: atemp gtemp . . * Example 10.1: analysis with missing value . anova lnam atemp##gtemp gtemp##v if _n>1 Number of obs = 95 R-squared = 0.9006 Root MSE = .073411 Adj R-squared = 0.8787 Source | Partial SS df MS F Prob>F ------------+---------------------------------------------------- Model | 3.7596044 17 .2211532 41.04 0.0000 | atemp | 3.0260185 7 .43228835 80.22 0.0000 gtemp | .00297517 1 .00297517 0.55 0.4597 atemp#gtemp | .06702757 7 .00957537 1.78 0.1040 v | .56512284 1 .56512284 104.86 0.0000 gtemp#v | .07849559 1 .07849559 14.57 0.0003 | Residual | .41496137 77 .00538911 ------------+---------------------------------------------------- Total | 4.1745657 94 .04441027 . margins gtemp#v, asbalanced /* least squares means */ Adjusted predictions Number of obs = 95 Expression: Linear prediction, predict() At: atemp (asbalanced) gtemp (asbalanced) v (asbalanced) ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- gtemp#v | 13 1 | 5.847649 .0149849 390.24 0.000 5.817811 5.877488 13 2 | 5.750774 .0149849 383.77 0.000 5.720936 5.780613 25 1 | 5.916409 .0153643 385.08 0.000 5.885815 5.947004 25 2 | 5.704424 .0149849 380.68 0.000 5.674586 5.734263 ------------------------------------------------------------------------------ . margins gtemp#v /* all estimates different */ Predictive margins Number of obs = 95 Expression: Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- gtemp#v | 13 1 | 5.849246 .0149878 390.27 0.000 5.819402 5.879091 13 2 | 5.752371 .0149878 383.80 0.000 5.722527 5.782216 25 1 | 5.917001 .01534 385.72 0.000 5.886455 5.947547 25 2 | 5.705016 .0149883 380.63 0.000 5.67517 5.734861 ------------------------------------------------------------------------------ .