webuse nhanes2l, clear
(Second National Health and Nutrition Examination Survey)
describe bpsystol agegrp
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
bpsystol int %9.0g Systolic blood pressure
agegrp byte %8.0g agegrp Age group
summarize bpsystol agegrp
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
bpsystol | 10,351 130.8817 23.33265 65 300
agegrp | 10,351 3.35813 1.735657 1 6
label list agegrp
agegrp:
1 20–29
2 30–39
3 40–49
4 50–59
5 60–69
6 70+
regress bpsystol i.agegrp
Source | SS df MS Number of obs = 10,351
-------------+---------------------------------- F(5, 10345) = 606.28
Model | 1276952.17 5 255390.434 Prob > F = 0.0000
Residual | 4357717.85 10,345 421.239039 R-squared = 0.2266
-------------+---------------------------------- Adj R-squared = 0.2263
Total | 5634670.03 10,350 544.412563 Root MSE = 20.524
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
agegrp |
30–39 | 2.89081 .6642831 4.35 0.000 1.588686 4.192933
40–49 | 9.597631 .7160526 13.40 0.000 8.194029 11.00123
50–59 | 18.32889 .7126412 25.72 0.000 16.93198 19.72581
60–69 | 24.17618 .5734587 42.16 0.000 23.05209 25.30027
70+ | 30.82992 .7802491 39.51 0.000 29.30048 32.35936
|
_cons | 117.3466 .4261086 275.39 0.000 116.5113 118.1818
------------------------------------------------------------------------------
testparm i.agegrp
( 1) 2.agegrp = 0
( 2) 3.agegrp = 0
( 3) 4.agegrp = 0
( 4) 5.agegrp = 0
( 5) 6.agegrp = 0
F( 5, 10345) = 606.28
Prob > F = 0.0000
test 2.agegrp = 6.agegrp
( 1) 2.agegrp - 6.agegrp = 0
F( 1, 10345) = 1136.36
Prob > F = 0.0000
margins agegrp
Adjusted predictions Number of obs = 10,351
Model VCE: OLS
Expression: Linear prediction, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
agegrp |
20–29 | 117.3466 .4261086 275.39 0.000 116.5113 118.1818
30–39 | 120.2374 .5096111 235.94 0.000 119.2384 121.2363
40–49 | 126.9442 .5754674 220.59 0.000 125.8162 128.0722
50–59 | 135.6754 .5712171 237.52 0.000 134.5557 136.7951
60–69 | 141.5227 .3837791 368.76 0.000 140.7704 142.275
70+ | 148.1765 .6536208 226.70 0.000 146.8952 149.4577
------------------------------------------------------------------------------
marginsplot, xdimension (agegrp)
Variables that uniquely identify margins: agegrp
marginsplot, xdimension (agegrp) recast (bar)
Variables that uniquely identify margins: agegrp
marginsplot, xdimension (agegrp) recast (bar) plotopts (barwidth(.9))
>
Variables that uniquely identify margins: agegrp
marginsplot, xdimension (agegrp) horizontal recast (bar) plotopts (barwidth(.9))
Variables that uniquely identify margins: agegrp
marginsplot, xdimension (agegrp) horizontal recast (scatter)
Variables that uniquely identify margins: agegrp
marginsplot, xdimension (agegrp) horizontal recast (scatter) plotregion(margin(large))
Variables that uniquely identify margins: agegrp
webuse nhanes2l, clear
(Second National Health and Nutrition Examination Survey)
describe bpsystol bmi
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
bpsystol int %9.0g Systolic blood pressure
bmi float %9.0g Body mass index (BMI)
summarize bpsystol bmi
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
bpsystol | 10,351 130.8817 23.33265 65 300
bmi | 10,351 25.5376 4.914969 12.3856 61.1297
regress bpsystol bmi
Source | SS df MS Number of obs = 10,351
-------------+---------------------------------- F(1, 10349) = 1435.54
Model | 686390.93 1 686390.93 Prob > F = 0.0000
Residual | 4948279.1 10,349 478.140796 R-squared = 0.1218
-------------+---------------------------------- Adj R-squared = 0.1217
Total | 5634670.03 10,350 544.412563 Root MSE = 21.866
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
bmi | 1.656894 .0437307 37.89 0.000 1.571173 1.742615
_cons | 88.56855 1.137272 77.88 0.000 86.33928 90.79783
------------------------------------------------------------------------------
regress bpsystol c.bmi##c.bmi
Source | SS df MS Number of obs = 10,351
-------------+---------------------------------- F(2, 10348) = 734.82
Model | 700727.69 2 350363.845 Prob > F = 0.0000
Residual | 4933942.34 10,348 476.80154 R-squared = 0.1244
-------------+---------------------------------- Adj R-squared = 0.1242
Total | 5634670.03 10,350 544.412563 Root MSE = 21.836
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
bmi | 3.166705 .2787794 11.36 0.000 2.620244 3.713166
|
c.bmi#c.bmi | -.0265269 .0048376 -5.48 0.000 -.0360096 -.0170443
|
_cons | 67.9524 3.927462 17.30 0.000 60.25382 75.65099
------------------------------------------------------------------------------
test bmi bmi#bmi
( 1) bmi = 0
( 2) c.bmi#c.bmi = 0
F( 2, 10348) = 734.82
Prob > F = 0.0000
margins, at(bmi=(20(10)60))
Adjusted predictions Number of obs = 10,351
Model VCE: OLS
Expression: Linear prediction, predict()
1._at: bmi = 20
2._at: bmi = 30
3._at: bmi = 40
4._at: bmi = 50
5._at: bmi = 60
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_at |
1 | 120.6757 .3739965 322.67 0.000 119.9426 121.4088
2 | 139.0793 .3248572 428.12 0.000 138.4425 139.7161
3 | 152.1775 .8255066 184.34 0.000 150.5594 153.7957
4 | 159.9703 2.354143 67.95 0.000 155.3557 164.5849
5 | 162.4577 4.896737 33.18 0.000 152.8592 172.0563
------------------------------------------------------------------------------
marginsplot, xdimension (at(bmi))
Variables that uniquely identify margins: bmi
webuse nhanes2l, clear
(Second National Health and Nutrition Examination Survey)
describe bpsystol age hlthstat
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
bpsystol int %9.0g Systolic blood pressure
age byte %9.0g Age (years)
hlthstat byte %20.0g hlth Health status
summarize bpsystol age hlthstat
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
bpsystol | 10,351 130.8817 23.33265 65 300
age | 10,351 47.57965 17.21483 20 74
hlthstat | 10,335 2.586164 1.206196 1 5
label list hlth
hlth:
1 Excellent
2 Very good
3 Good
4 Fair
5 Poor
.a Blank but applicable
regress bpsystol i.hlthstat
Source | SS df MS Number of obs = 10,335
-------------+---------------------------------- F(4, 10330) = 158.34
Model | 325244.686 4 81311.1715 Prob > F = 0.0000
Residual | 5304728.67 10,330 513.526492 R-squared = 0.0578
-------------+---------------------------------- Adj R-squared = 0.0574
Total | 5629973.35 10,334 544.800982 Root MSE = 22.661
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Very good | 2.981587 .6415165 4.65 0.000 1.72409 4.239083
Good | 8.034913 .6230047 12.90 0.000 6.813703 9.256123
Fair | 14.71925 .721698 20.40 0.000 13.30459 16.13392
Poor | 16.42304 .9580047 17.14 0.000 14.54517 18.30092
|
_cons | 124.3191 .4618951 269.15 0.000 123.4137 125.2245
------------------------------------------------------------------------------
regress bpsysto1 i.hlthstat age
variable bpsysto1 not found
r(111);
regress bpsystol i.hlthstat c.age i.hlthstat#c.age
Source | SS df MS Number of obs = 10,335
-------------+---------------------------------- F(9, 10325) = 356.94
Model | 1336009.83 9 148445.537 Prob > F = 0.0000
Residual | 4293963.52 10,325 415.880244 R-squared = 0.2373
-------------+---------------------------------- Adj R-squared = 0.2366
Total | 5629973.35 10,334 544.800982 Root MSE = 20.393
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Very good | -.7278773 1.56738 -0.46 0.642 -3.800247 2.344492
Good | -1.805066 1.628709 -1.11 0.268 -4.997651 1.38752
Fair | -2.953822 2.28133 -1.29 0.195 -7.425671 1.518028
Poor | -1.789794 4.17601 -0.43 0.668 -9.975582 6.395994
|
age | .5482008 .026058 21.04 0.000 .497122 .5992797
|
hlthstat#|
c.age |
Very good | .0429235 .0349712 1.23 0.220 -.0256268 .1114738
Good | .0997614 .0345571 2.89 0.004 .0320228 .1675
Fair | .1556511 .0428922 3.63 0.000 .071574 .2397282
Poor | .1222002 .0708112 1.73 0.084 -.0166035 .2610038
|
_cons | 102.3143 1.125537 90.90 0.000 100.108 104.5206
------------------------------------------------------------------------------
regress bpsystol i.hlthstat##c.age
Source | SS df MS Number of obs = 10,335
-------------+---------------------------------- F(9, 10325) = 356.94
Model | 1336009.83 9 148445.537 Prob > F = 0.0000
Residual | 4293963.52 10,325 415.880244 R-squared = 0.2373
-------------+---------------------------------- Adj R-squared = 0.2366
Total | 5629973.35 10,334 544.800982 Root MSE = 20.393
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Very good | -.7278773 1.56738 -0.46 0.642 -3.800247 2.344492
Good | -1.805066 1.628709 -1.11 0.268 -4.997651 1.38752
Fair | -2.953822 2.28133 -1.29 0.195 -7.425671 1.518028
Poor | -1.789794 4.17601 -0.43 0.668 -9.975582 6.395994
|
age | .5482008 .026058 21.04 0.000 .497122 .5992797
|
hlthstat#|
c.age |
Very good | .0429235 .0349712 1.23 0.220 -.0256268 .1114738
Good | .0997614 .0345571 2.89 0.004 .0320228 .1675
Fair | .1556511 .0428922 3.63 0.000 .071574 .2397282
Poor | .1222002 .0708112 1.73 0.084 -.0166035 .2610038
|
_cons | 102.3143 1.125537 90.90 0.000 100.108 104.5206
------------------------------------------------------------------------------
regress bpsystol i.hlthstat#c.age
Source | SS df MS Number of obs = 10,335
-------------+---------------------------------- F(5, 10329) = 642.14
Model | 1335043.76 5 267008.751 Prob > F = 0.0000
Residual | 4294929.6 10,329 415.812721 R-squared = 0.2371
-------------+---------------------------------- Adj R-squared = 0.2368
Total | 5629973.35 10,334 544.800982 Root MSE = 20.391
------------------------------------------------------------------------------
bpsystol | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat#|
c.age |
Excellent | .570586 .0163132 34.98 0.000 .538609 .6025629
Very good | .5973404 .0148871 40.12 0.000 .5681587 .626522
Good | .6339932 .0133315 47.56 0.000 .6078609 .6601255
Fair | .6720568 .0133007 50.53 0.000 .6459848 .6981288
Poor | .6583505 .0158065 41.65 0.000 .6273667 .6893342
|
_cons | 101.2738 .6122637 165.41 0.000 100.0737 102.474
------------------------------------------------------------------------------
testparm i.hlthstat
no such variables;
the specified varlist does not identify any testable coefficients
r(111);
testparm i.hlthstat#c.age
( 1) 1b.hlthstat#c.age = 0
( 2) 2.hlthstat#c.age = 0
( 3) 3.hlthstat#c.age = 0
( 4) 4.hlthstat#c.age = 0
( 5) 5.hlthstat#c.age = 0
F( 5, 10329) = 642.14
Prob > F = 0.0000
margins hlthstat
Predictive margins Number of obs = 10,335
Model VCE: OLS
Expression: Linear prediction, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Excellent | 128.4142 .4579315 280.42 0.000 127.5166 129.3119
Very good | 129.6868 .4087679 317.26 0.000 128.8856 130.4881
Good | 131.4303 .3542135 371.05 0.000 130.7359 132.1246
Fair | 133.2408 .4272309 311.87 0.000 132.4033 134.0782
Poor | 132.5888 .605521 218.97 0.000 131.4019 133.7758
------------------------------------------------------------------------------
margins, at(age=(20(10)80))
Predictive margins Number of obs = 10,335
Model VCE: OLS
Expression: Linear prediction, predict()
1._at: age = 20
2._at: age = 30
3._at: age = 40
4._at: age = 50
5._at: age = 60
6._at: age = 70
7._at: age = 80
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_at |
1 | 113.632 .3881179 292.78 0.000 112.8712 114.3927
2 | 119.811 .290047 413.07 0.000 119.2425 120.3796
3 | 125.9901 .2191439 574.92 0.000 125.5605 126.4196
4 | 132.1691 .2057325 642.43 0.000 131.7658 132.5724
5 | 138.3482 .2589067 534.36 0.000 137.8407 138.8557
6 | 144.5272 .3494917 413.54 0.000 143.8422 145.2123
7 | 150.7063 .4556986 330.71 0.000 149.813 151.5995
------------------------------------------------------------------------------
margins hlthstat, at(age=(20(10)80))
Adjusted predictions Number of obs = 10,335
Model VCE: OLS
Expression: Linear prediction, predict()
1._at: age = 20
2._at: age = 30
3._at: age = 40
4._at: age = 50
5._at: age = 60
6._at: age = 70
7._at: age = 80
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_at#hlthstat |
1#Excellent | 112.6856 .3983764 282.86 0.000 111.9047 113.4665
1#Very good | 113.2206 .4065918 278.46 0.000 112.4236 114.0176
1#Good | 113.9537 .4147495 274.75 0.000 113.1407 114.7667
1#Fair | 114.715 .4432383 258.81 0.000 113.8461 115.5838
1#Poor | 114.4408 .4833949 236.74 0.000 113.4933 115.3884
2#Excellent | 118.3914 .3611896 327.78 0.000 117.6834 119.0994
2#Very good | 119.1941 .3564125 334.43 0.000 118.4954 119.8927
2#Good | 120.2936 .3520097 341.73 0.000 119.6036 120.9836
2#Fair | 121.4355 .4004119 303.28 0.000 120.6507 122.2204
2#Poor | 121.0244 .4878791 248.06 0.000 120.068 121.9807
3#Excellent | 124.0973 .3942536 314.77 0.000 123.3245 124.8701
3#Very good | 125.1675 .3647853 343.13 0.000 124.4524 125.8825
3#Good | 126.6336 .3336917 379.49 0.000 125.9795 127.2877
3#Fair | 128.1561 .3994761 320.81 0.000 127.3731 128.9392
3#Poor | 127.6079 .5406943 236.01 0.000 126.548 128.6677
4#Excellent | 129.8031 .4833609 268.54 0.000 128.8557 130.7506
4#Very good | 131.1409 .4282897 306.20 0.000 130.3013 131.9804
4#Good | 132.9735 .3665177 362.80 0.000 132.2551 133.6919
4#Fair | 134.8767 .4406978 306.05 0.000 134.0128 135.7405
4#Poor | 134.1914 .6297964 213.07 0.000 132.9568 135.4259
5#Excellent | 135.509 .6042047 224.28 0.000 134.3246 136.6934
5#Very good | 137.1143 .527372 260.00 0.000 136.0805 138.148
5#Good | 139.3134 .4391651 317.22 0.000 138.4526 140.1743
5#Fair | 141.5972 .514033 275.46 0.000 140.5896 142.6049
5#Poor | 140.7749 .7422303 189.66 0.000 139.32 142.2298
6#Excellent | 141.2149 .7414261 190.46 0.000 139.7615 142.6682
6#Very good | 143.0877 .6458605 221.55 0.000 141.8217 144.3537
6#Good | 145.6534 .5356701 271.91 0.000 144.6033 146.7034
6#Fair | 148.3178 .6079697 243.96 0.000 147.1261 149.5096
6#Poor | 147.3584 .8689862 169.58 0.000 145.655 149.0618
7#Excellent | 146.9207 .8874604 165.55 0.000 145.1811 148.6603
7#Very good | 149.0611 .7749036 192.36 0.000 147.5421 150.58
7#Good | 151.9933 .6454181 235.50 0.000 150.7282 153.2584
7#Fair | 155.0384 .7144273 217.01 0.000 153.638 156.4388
7#Poor | 153.9419 1.004658 153.23 0.000 151.9726 155.9112
------------------------------------------------------------------------------
marginsplot, xdimension(at(age))
Variables that uniquely identify margins: age hlthstat
marginsplot, xdimension(at(age)) bydimension(hlthstat)
Variables that uniquely identify margins: age hlthstat
marginsplot, xdimension(at(age)) graphdimension(hlthstat)
Variables that uniquely identify margins: age hlthstat
webuse nhanes2l, clear
(Second National Health and Nutrition Examination Survey)
describe highbp hlthstat
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
highbp byte %8.0g * High blood pressure
hlthstat byte %20.0g hlth Health status
label list hlth
hlth:
1 Excellent
2 Very good
3 Good
4 Fair
5 Poor
.a Blank but applicable
logistic highbp i.hlthstat
Logistic regression Number of obs = 10,335
LR chi2(4) = 349.04
Prob > chi2 = 0.0000
Log likelihood = -6866.2073 Pseudo R2 = 0.0248
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Very good | 1.207864 .0725424 3.14 0.002 1.073733 1.358751
Good | 1.890382 .1084935 11.10 0.000 1.689262 2.115447
Fair | 2.567386 .1690847 14.32 0.000 2.256483 2.921125
Poor | 2.940382 .2552911 12.42 0.000 2.480278 3.485838
|
_cons | .4596725 .0201717 -17.71 0.000 .4217893 .5009583
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
testparm i.hlthstat
( 1) [highbp]2.hlthstat = 0
( 2) [highbp]3.hlthstat = 0
( 3) [highbp]4.hlthstat = 0
( 4) [highbp]5.hlthstat = 0
chi2( 4) = 340.67
Prob > chi2 = 0.0000
margins hlthstat
Adjusted predictions Number of obs = 10,335
Model VCE: OIM
Expression: Pr(highbp), predict()
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
hlthstat |
Excellent | .3149148 .0094674 33.26 0.000 .2963591 .3334706
Very good | .357005 .0094125 37.93 0.000 .3385568 .3754533
Good | .4649421 .0092018 50.53 0.000 .4469069 .4829774
Fair | .5413174 .0121934 44.39 0.000 .5174188 .5652159
Poor | .5747599 .0183103 31.39 0.000 .5388723 .6106476
------------------------------------------------------------------------------
marginsplot, xdimension (hlthstat)
Variables that uniquely identify margins: hlthstat
marginsplot, xdimension (hlthstat) recast(bar)
Variables that uniquely identify margins: hlthstat
marginsplot, xdimension (hlthstat) recast(bar) plotopts(barwidth(.9))
>
Variables that uniquely identify margins: hlthstat
marginsplot, xdimension (hlthstat) horizontal recast(bar) plotopts(barwidth(.9))
Variables that uniquely identify margins: hlthstat
marginsplot, xdimension (hlthstat) horizontal recast(scatter)
Variables that uniquely identify margins: hlthstat
marginsplot, xdimension (hlthstat) horizontal recast(scatter) plotregion(margin(large))
Variables that uniquely identify margins: hlthstat
webuse nhanes21, clear
file https://www.stata-press.com/data/r17/nhanes21.dta not found
r(601);
describe highbp age
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
highbp byte %8.0g * High blood pressure
age byte %9.0g Age (years)
summarize highbp age
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
highbp | 10,351 .4227611 .494022 0 1
age | 10,351 47.57965 17.21483 20 74
logistic highbp age
Logistic regression Number of obs = 10,351
LR chi2(1) = 1462.36
Prob > chi2 = 0.0000
Log likelihood = -6319.5836 Pseudo R2 = 0.1037
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.048402 .0013826 35.84 0.000 1.045696 1.051115
_cons | .0731028 .0050675 -37.74 0.000 .0638159 .0837413
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
logistic highbp c.age
Logistic regression Number of obs = 10,351
LR chi2(1) = 1462.36
Prob > chi2 = 0.0000
Log likelihood = -6319.5836 Pseudo R2 = 0.1037
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.048402 .0013826 35.84 0.000 1.045696 1.051115
_cons | .0731028 .0050675 -37.74 0.000 .0638159 .0837413
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
logistic highbp c.age##c.age
Logistic regression Number of obs = 10,351
LR chi2(2) = 1477.28
Prob > chi2 = 0.0000
Log likelihood = -6312.1244 Pseudo R2 = 0.1048
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.087957 .0105858 8.66 0.000 1.067406 1.108904
|
c.age#c.age | .9996097 .0001013 -3.85 0.000 .9994112 .9998082
|
_cons | .0337278 .0072241 -15.82 0.000 .0221653 .0513221
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
testparm c.age c.age#c.age
( 1) [highbp]age = 0
( 2) [highbp]c.age#c.age = 0
chi2( 2) = 1270.04
Prob > chi2 = 0.0000
margins, at(age = (20 (10) 80))
Adjusted predictions Number of obs = 10,351
Model VCE: OIM
Expression: Pr(highbp), predict()
1._at: age = 20
2._at: age = 30
3._at: age = 40
4._at: age = 50
5._at: age = 60
6._at: age = 70
7._at: age = 80
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_at |
1 | .1347557 .007904 17.05 0.000 .1192641 .1502473
2 | .2293961 .0061505 37.30 0.000 .2173414 .2414508
3 | .3447995 .0074774 46.11 0.000 .3301441 .3594549
4 | .4624931 .0084434 54.78 0.000 .4459443 .4790419
5 | .5654424 .006734 83.97 0.000 .552244 .5786408
6 | .6453799 .0094833 68.05 0.000 .6267929 .6639668
7 | .7018715 .0191131 36.72 0.000 .6644105 .7393325
------------------------------------------------------------------------------
marginsplot, xdimension(at(age))
Variables that uniquely identify margins: age
webuse nhanes2l, clear
(Second National Health and Nutrition Examination Survey)
describe highbp age hlthstat
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
highbp byte %8.0g * High blood pressure
age byte %9.0g Age (years)
hlthstat byte %20.0g hlth Health status
summarize highbp age hlthstat
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
highbp | 10,351 .4227611 .494022 0 1
age | 10,351 47.57965 17.21483 20 74
hlthstat | 10,335 2.586164 1.206196 1 5
label list hlth
hlth:
1 Excellent
2 Very good
3 Good
4 Fair
5 Poor
.a Blank but applicable
logistic highbp age
Logistic regression Number of obs = 10,351
LR chi2(1) = 1462.36
Prob > chi2 = 0.0000
Log likelihood = -6319.5836 Pseudo R2 = 0.1037
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.048402 .0013826 35.84 0.000 1.045696 1.051115
_cons | .0731028 .0050675 -37.74 0.000 .0638159 .0837413
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
logistic highbp age i.hlthstat
Logistic regression Number of obs = 10,335
LR chi2(5) = 1497.60
Prob > chi2 = 0.0000
Log likelihood = -6291.9277 Pseudo R2 = 0.1064
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.045961 .0014608 32.17 0.000 1.043102 1.048828
|
hlthstat |
Very good | 1.042593 .0667692 0.65 0.515 .9196075 1.182026
Good | 1.331022 .0821632 4.63 0.000 1.179346 1.502206
Fair | 1.338533 .0963162 4.05 0.000 1.162464 1.541269
Poor | 1.314017 .1223369 2.93 0.003 1.094845 1.577063
|
_cons | .0697511 .0053325 -34.83 0.000 .0600449 .0810263
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
logistic highbp age i.hlthstat c.age#i.hlthstat
Logistic regression Number of obs = 10,335
LR chi2(9) = 1509.14
Prob > chi2 = 0.0000
Log likelihood = -6286.1541 Pseudo R2 = 0.1072
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.049792 .0030917 16.50 0.000 1.04375 1.05587
|
hlthstat |
Very good | 1.131421 .2146923 0.65 0.515 .7800187 1.641133
Good | 1.582604 .3016515 2.41 0.016 1.089255 2.299404
Fair | 1.824619 .4689123 2.34 0.019 1.102606 3.019424
Poor | 5.239768 2.235995 3.88 0.000 2.270252 12.09344
|
hlthstat#|
c.age |
Very good | .9979987 .0039481 -0.51 0.613 .9902905 1.005767
Good | .9960764 .0038529 -1.02 0.309 .9885533 1.003657
Fair | .9937174 .0047134 -1.33 0.184 .9845221 1.002999
Poor | .9762062 .0070891 -3.32 0.001 .9624102 .9902
|
_cons | .059485 .0081386 -20.63 0.000 .0454934 .0777797
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
logistic highbp c.age##i.hlthstat
Logistic regression Number of obs = 10,335
LR chi2(9) = 1509.14
Prob > chi2 = 0.0000
Log likelihood = -6286.1541 Pseudo R2 = 0.1072
------------------------------------------------------------------------------
highbp | Odds ratio Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 1.049792 .0030917 16.50 0.000 1.04375 1.05587
|
hlthstat |
Very good | 1.131421 .2146923 0.65 0.515 .7800187 1.641133
Good | 1.582604 .3016515 2.41 0.016 1.089255 2.299404
Fair | 1.824619 .4689123 2.34 0.019 1.102606 3.019424
Poor | 5.239768 2.235995 3.88 0.000 2.270252 12.09344
|
hlthstat#|
c.age |
Very good | .9979987 .0039481 -0.51 0.613 .9902905 1.005767
Good | .9960764 .0038529 -1.02 0.309 .9885533 1.003657
Fair | .9937174 .0047134 -1.33 0.184 .9845221 1.002999
Poor | .9762062 .0070891 -3.32 0.001 .9624102 .9902
|
_cons | .059485 .0081386 -20.63 0.000 .0454934 .0777797
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
testparm i.hlthstat#c.age
( 1) [highbp]2.hlthstat#c.age = 0
( 2) [highbp]3.hlthstat#c.age = 0
( 3) [highbp]4.hlthstat#c.age = 0
( 4) [highbp]5.hlthstat#c.age = 0
chi2( 4) = 11.92
Prob > chi2 = 0.0180
margins hlthstat, at(age=(20(10) 80))
Adjusted predictions Number of obs = 10,335
Model VCE: OIM
Expression: Pr(highbp), predict()
1._at: age = 20
2._at: age = 30
3._at: age = 40
4._at: age = 50
5._at: age = 60
6._at: age = 70
7._at: age = 80
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_at#hlthstat |
1#Excellent | .1358516 .0098562 13.78 0.000 .1165339 .1551693
1#Very good | .1459442 .0104193 14.01 0.000 .1255227 .1663656
1#Good | .1869827 .0130893 14.29 0.000 .1613282 .2126372
1#Fair | .201836 .0235745 8.56 0.000 .1556307 .2480413
1#Poor | .3372591 .0614491 5.49 0.000 .2168212 .4576971
2#Excellent | .2035494 .0100141 20.33 0.000 .1839221 .2231768
2#Very good | .214017 .010546 20.29 0.000 .1933472 .2346868
2#Good | .2644192 .0126073 20.97 0.000 .2397092 .2891291
2#Fair | .2784913 .0225602 12.34 0.000 .2342742 .3227084
2#Poor | .3940257 .0505936 7.79 0.000 .294864 .4931874
3#Excellent | .2935237 .0099824 29.40 0.000 .2739587 .3130888
3#Very good | .3025915 .0100517 30.10 0.000 .2828906 .3222925
3#Good | .3597353 .0109182 32.95 0.000 .3383359 .3811346
3#Fair | .3707369 .0188989 19.62 0.000 .3336958 .407778
3#Poor | .4538045 .0376138 12.06 0.000 .3800828 .5275262
4#Excellent | .4031382 .0121593 33.15 0.000 .3793064 .4269701
4#Very good | .4087597 .0108143 37.80 0.000 .3875641 .4299552
4#Good | .4675702 .0098026 47.70 0.000 .4483575 .4867828
4#Fair | .4734859 .0142865 33.14 0.000 .4454849 .5014869
4#Poor | .5149457 .0249403 20.65 0.000 .4660637 .5638277
5#Excellent | .5233628 .0167798 31.19 0.000 .4904749 .5562506
5#Very good | .5241804 .0139565 37.56 0.000 .4968262 .5515346
5#Good | .5785222 .0112047 51.63 0.000 .5565614 .600483
5#Fair | .5785308 .0128344 45.08 0.000 .5533758 .6036857
5#Poor | .5756428 .0184818 31.15 0.000 .5394192 .6118664
6#Excellent | .6409395 .0208784 30.70 0.000 .6000185 .6818605
6#Very good | .6370746 .0173875 36.64 0.000 .6029957 .6711535
6#Good | .6820744 .013595 50.17 0.000 .6554287 .7087202
6#Fair | .6769184 .0154983 43.68 0.000 .6465423 .7072945
6#Poor | .6341409 .0235355 26.94 0.000 .5880122 .6802695
7#Excellent | .7437153 .0222859 33.37 0.000 .7000358 .7873948
7#Very good | .7366409 .0189832 38.80 0.000 .6994344 .7738473
7#Good | .7702871 .0148118 52.00 0.000 .7412565 .7993177
7#Fair | .7617951 .018181 41.90 0.000 .726161 .7974292
7#Poor | .6889326 .0329706 20.90 0.000 .6243115 .7535537
------------------------------------------------------------------------------
marginsplot, xdimension(at(age))
Variables that uniquely identify margins: age hlthstat
marginsplot, xdimension(at(age)) bydimension(hlthstat)
Variables that uniquely identify margins: age hlthstat
marginsplot, xdimension(at(age)) graphdimension(hlthstat)
Variables that uniquely identify margins: age hlthstat