stata log ( needed to answer exam questions exam stata... · (file c:\users\jtonasci\desktop\exam...

15
Class 12: Exam STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS) Multiple Linear Regression p. 12-2 Multiple Logistic Regression p.12-10 Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 1

Upload: others

Post on 05-Apr-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

Class 12: Exam

STATA LOG

( NEEDED TO ANSWER EXAM QUESTIONS)

Multiple Linear Regression p. 12-2

Multiple Logistic Regression p.12-10

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 1

Page 2: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

Class 12: Exam

1. Multiple Linear Regression

. * Input data

.

. use cnvpt.dta, clear

.

.

. codebook

----------------------------------------------------------------------------------------------------id (unlabeled)----------------------------------------------------------------------------------------------------

type: numeric (float)

range: [1002,16018] units: 1 unique values: 156 missing .: 0/312

mean: 6828.01 std. dev: 4864.78

percentiles: 10% 25% 50% 75% 90% 1024 2017.5 6015.5 11008 14016

----------------------------------------------------------------------------------------------------eye eye OD | OS----------------------------------------------------------------------------------------------------

type: numeric (long) label: eye_n

range: [1,2] units: 1 unique values: 2 missing .: 0/312

tabulation: Freq. Numeric Label 156 1 OD 156 2 OS

----------------------------------------------------------------------------------------------------group treatment group----------------------------------------------------------------------------------------------------

type: numeric (byte) label: group_lab

range: [0,1] units: 1 unique values: 2 missing .: 0/312

tabulation: Freq. Numeric Label 156 0 no trt 156 1 laser trt

----------------------------------------------------------------------------------------------------sex sex-(sex)----------------------------------------------------------------------------------------------------

type: numeric (long) label: gender

range: [1,2] units: 1 unique values: 2 missing .: 0/312

tabulation: Freq. Numeric Label 190 1 F 122 2 M

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 2

Page 3: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

----------------------------------------------------------------------------------------------------age age, yrs----------------------------------------------------------------------------------------------------

type: numeric (byte)

range: [51,85] units: 1 unique values: 31 missing .: 0/312

mean: 70.8846 std. dev: 6.81304

percentiles: 10% 25% 50% 75% 90% 62 66 71 75.5 79

----------------------------------------------------------------------------------------------------evrsmk smoking status----------------------------------------------------------------------------------------------------

type: numeric (long) label: evrsmk

range: [0,1] units: 1 unique values: 2 missing .: 0/312

tabulation: Freq. Numeric Label 140 0 never 172 1 ever

----------------------------------------------------------------------------------------------------hypstat hypertension status----------------------------------------------------------------------------------------------------

type: numeric (byte) label: hypstat_lab

range: [0,1] units: 1 unique values: 2 missing .: 4/312

tabulation: Freq. Numeric Label 118 0 normal 190 1 hyper + 4 .

----------------------------------------------------------------------------------------------------diabetic diabetic----------------------------------------------------------------------------------------------------

type: numeric (long)

range: [0,1] units: 1 unique values: 2 missing .: 0/312

tabulation: Freq. Value 302 0 10 1

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 3

Page 4: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

----------------------------------------------------------------------------------------------------va0 (unlabeled)----------------------------------------------------------------------------------------------------

type: numeric (byte)

range: [66,95] units: 1 unique values: 29 missing .: 0/312

mean: 80.8942 std. dev: 6.43331

percentiles: 10% 25% 50% 75% 90% 72 76 81 85 90

va24 (unlabeled)----------------------------------------------------------------------------------------------------

type: numeric (byte)

range: [3,95] units: 1 unique values: 49 missing .: 38/312

mean: 78.1204 std. dev: 13.4084

percentiles: 10% 25% 50% 75% 90% 67 75 80 86 90

. * Part a. MULTIPLE LINEAR REGRESSION

.

.

. * Untreated eye only

.

. regress va0 eye sex age evrsmk hypstat diabetic if group==0

Source | SS df MS Number of obs = 154-------------+------------------------------ F( 6, 147) = 4.95 Model | 1096.30494 6 182.71749 Prob > F = 0.0001 Residual | 5429.23402 147 36.9335648 R-squared = 0.1680-------------+------------------------------ Adj R-squared = 0.1340 Total | 6525.53896 153 42.6505814 Root MSE = 6.0773

------------------------------------------------------------------------------ va0 | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- eye | -.1732781 .9845634 -0.18 0.861 -2.119005 1.772449 sex | 1.459723 1.037867 1.41 0.162 -.5913439 3.510791 age | -.2996288 .0745573 -4.02 0.000 -.4469714 -.1522862 evrsmk | .3841479 1.022941 0.38 0.708 -1.637421 2.405717 hypstat | 3.025248 1.014468 2.98 0.003 1.020422 5.030073 diabetic | -3.148276 2.812282 -1.12 0.265 -8.706001 2.409449 _cons | 98.58152 5.694789 17.31 0.000 87.32729 109.8358------------------------------------------------------------------------------

.

.

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 4

Page 5: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

. * Scale for age

. . acprplot age , lowess title("AUGUMENTED COMPONENT+RESIDUAL PLOT: AGE")

. graph export exam2014_mlr/acprplot.wmf, replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/acprplot.wmf written in Windows Metafile

. * Predicteds

. predict y_hat(option xb assumed; fitted values)(4 missing values generated)

. * Studentized residuals

.

. predict estud, rstudent(4 missing values generated). graph twoway scatter estud y_hat , yline(-2 0 2) title("RSTUDENT BY PREDICTED")

. graph export exam2014_mlr/rstudent.wmf,replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/rstudent.wmf written in Windows Metafile form> at)

1015

2025

3035

Augm

ente

d co

mpo

nent

plu

s re

sidu

al

50 60 70 80 90age, yrs

AUGUMENTED COMPONENT+RESIDUAL PLOT: AGE

5003

-20

24

RST

UD

ENT

STUDENTIZED RESIDUALS

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 5

Page 6: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

* Q-Q plot. . qnorm estud , title("Q-Q PLOT OF RESIDUALS"). graph export exam2014_mlr/q-q.wmf, replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/q-q.wmf written in Windows Metafile format)

. * Kernel density plot

. kdensity estud , normal title("KERNEL DENSITY ESTIMATE")

. graph export exam2014_mlr/kdensity.wmf, replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/kdensity.wmf written in Windows Metafile

. * Shapiro-Wilk Test

.

. swilk estud

Shapiro-Wilk W test for normal data

Variable | Obs W V z Prob>z-------------+-------------------------------------------------- estud | 308 0.99314 1.495 0.945 0.17231

.

.

.

-4-2

02

4R

STU

DEN

T

-4 -2 0 2 4Inverse Normal

Q-Q PLOT OF RESIDUALS

0.1

.2.3

.4D

ensi

ty

-4 -2 0 2 4RSTUDENT

Kernel density estimateNormal density

kernel = epanechnikov, bandwidth = 0.2863

KERNEL DENSITY ESTIMATE

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 6

Page 7: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

. * Boxplot leverages.

. predict lev, leverage(4 missing values generated). graph box lev, marker(1,mlab(id)) outergap(200) medtype(cline) medline(lwidth(1.0)

. graph export exam2014_mlr/boxleverage.wmf, replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/boxleverage.wmf written in Windows Metafile

. * Boxplot dfits

.

. predict dfits, dfits(158 missing values generated). . graph box dfits, marker(1,mlab(id)) outergap(200) medtype(cline) medline(lwidth(1.0)). graph export exam2014_mlr/boxdfits.wmf, replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_mlr/boxdfits.wmf written in Windows Metafile

.

.

300670206015100610066015160161300711012500111012601050016010103216010160101032700770071400914009

702470243003110133003300111013104430011044

0.0

5.1

.15

.2.2

5LE

VER

AGE

LEVERAGE

11013

1044

-1-.5

0.5

1D

fits

DFITS

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 7

Page 8: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

. * Collinearity

. estat vif

Variable | VIF 1/VIF -------------+---------------------- age | 1.08 0.925939 evrsmk | 1.08 0.926772 sex | 1.07 0.936223 diabetic | 1.04 0.965313 hypstat | 1.01 0.986029 eye | 1.01 0.993821-------------+---------------------- Mean VIF | 1.05

.

.

. * Check linear scale for age

.

. mkspline pre65 65 post65 = age, marginal

. regress va0 eye sex pre65 post65 evrsmk hypstat diabetic

Source | SS df MS Number of obs = 308-------------+------------------------------ F( 7, 300) = 8.94 Model | 2185.25944 7 312.179919 Prob > F = 0.0000 Residual | 10471.1919 300 34.9039729 R-squared = 0.1727-------------+------------------------------ Adj R-squared = 0.1534 Total | 12656.4513 307 41.2262257 Root MSE = 5.908

------------------------------------------------------------------------------ va0 | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- eye | .5779221 .6732743 0.86 0.391 -.7470165 1.902861 sex | 2.232772 .7128439 3.13 0.002 .8299643 3.63558 pre65 | -.0864345 .1668669 -0.52 0.605 -.4148124 .2419433 post65 | -.3046378 .2045565 -1.49 0.137 -.7071851 .0979094 evrsmk | .1909015 .7030726 0.27 0.786 -1.192677 1.57448 hypstat | 1.856574 .6977131 2.66 0.008 .4835426 3.229606 diabetic | -3.188683 1.932811 -1.65 0.100 -6.992267 .6149019 _cons | 83.98504 10.6806 7.86 0.000 62.96666 105.0034------------------------------------------------------------------------------

.

.

.

.

. * MLR OF ALL EYES - GEE and ROBUST VARIANCE ESTIMATION

.

. regress va0 eye sex age evrsmk hypstat diabetic, cluster(id) robust

Linear regression Number of obs = 308 F( 6, 153) = 8.44 Prob > F = 0.0000 R-squared = 0.1665 Root MSE = 5.9199

(Std. Err. adjusted for 154 clusters in id)------------------------------------------------------------------------------ | Robust va0 | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- eye | .5779221 .5252561 1.10 0.273 -.4597687 1.615613 sex | 2.194555 .8662673 2.53 0.012 .4831656 3.905944 age | -.322952 .0551152 -5.86 0.000 -.4318371 -.214067 evrsmk | .1843887 .8480823 0.22 0.828 -1.491074 1.859852 hypstat | 1.808282 .8048057 2.25 0.026 .2183159 3.398249 diabetic | -3.186163 2.479453 -1.29 0.201 -8.084547 1.712221 _cons | 98.80258 4.184588 23.61 0.000 90.53555 107.0696------------------------------------------------------------------------------

.

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 8

Page 9: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

1. Multiple Linear Regression (cont'd)

Class 12: Exam

. * Mixed Effects

.

. xtmixed va0 eye sex age evrsmk hypstat diabetic || id: , nolog

Mixed-effects ML regression Number of obs = 308Group variable: id Number of groups = 154

Obs per group: min = 2 avg = 2.0 max = 2

Wald chi2(6) = 44.80Log likelihood = -968.09627 Prob > chi2 = 0.0000

------------------------------------------------------------------------------ va0 | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- eye | .5779221 .5184065 1.11 0.265 -.4381361 1.59398 sex | 2.194555 .8336961 2.63 0.008 .5605406 3.828569 age | -.322952 .059928 -5.39 0.000 -.4404087 -.2054954 evrsmk | .1843887 .8227856 0.22 0.823 -1.428241 1.797019 hypstat | 1.808282 .815647 2.22 0.027 .2096435 3.406921 diabetic | -3.186163 2.261956 -1.41 0.159 -7.619515 1.247189 _cons | 98.80258 4.456718 22.17 0.000 90.06757 107.5376------------------------------------------------------------------------------

------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]-----------------------------+------------------------------------------------id: Identity | sd(_cons) | 3.681756 .4030882 2.970731 4.562961-----------------------------+------------------------------------------------ sd(Residual) | 4.548999 .2592033 4.068311 5.086482------------------------------------------------------------------------------LR test vs. linear regression: chibar2(01) = 26.24 Prob >= chibar2 = 0.0000

.

. log close END OF MLR

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 9

Page 10: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

Class 12: Exam

2. Multiple Logistic Regression

. * Input data

.

. use cnvpt.dta, clear

.

.

.

. * GENERATE LETTERS LOST, 24 MO vs. BASELINE

. * Negative values = worse than BASELINE

.

. gen letslost24 = va24 - va0(38 missing values generated)

.

. codebook letslost24

----------------------------------------------------------------------------------------------------letslost24 (unlabeled)----------------------------------------------------------------------------------------------------

type: numeric (float)

range: [-82,21] units: 1 unique values: 45 missing .: 38/312

mean: -2.87591 std. dev: 12.8747

percentiles: 10% 25% 50% 75% 90% -11 -5 -1 3 7

. stem letslost24

Stem-and-leaf plot for letslost24

-8* | 2 -7. | -7* | 100 -6. | 5 -6* | -5. | 9 -5* | -4. | -4* | 43 -3. | -3* | 2 -2. | 9 -2* | 32000 -1. | 877755 -1* | 433321111100 -0. | 99999988888887777666666666666666655555555555 -0* | 444444444444444433333333333333333332222222222222211111111111111111 0* | 000000000000011111111111111111111112222222222222222222223333333 ... (80) 0. | 5555555666666666666677777788888899999 1* | 00011111224 1. | 88 2* | 1

.

.

.

. * GENERATE BINARY: LOST > 3 LETTERS

.

. gen lost3lets = (letslost24<=-3) if letslost24!=.(38 missing values generated)

.

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 10

Page 11: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

2. Multiple Logistic Regression (cont'd)

Class 12: Exam

. tab lost3lets , missing

lost3lets | Freq. Percent Cum.------------+----------------------------------- 0 | 162 51.92 51.92 1 | 112 35.90 87.82 . | 38 12.18 100.00------------+----------------------------------- Total | 312 100.00

. lowess lost3lets age, logit

. graph export exam2014_logit\lowess.wmf,replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile

. * GENERATE CATEGORICAL: LOST 0-3 , 4-9, or 10+ LETTERS

.

. gen lostcateg = letslost24

(38 missing values generated)

. recode lostcateg (-3/50 = 1) (-9/-4 = 2) (-100/-10 = 3)(lostcateg: 252 changes made)

. tab lostcateg, missing

lostcateg | Freq. Percent Cum.------------+----------------------------------- 1 | 181 58.01 58.01 2 | 60 19.23 77.24 3 | 33 10.58 87.82 . | 38 12.18 100.00------------+----------------------------------- Total | 312 100.00

.

.

.

-2-1

01

lost

3let

s

50 60 70 80 90age, yrs

bandwidth = .8

Logit transformed smoothLowess smoother

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 11

Page 12: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

2. Multiple Logistic Regression (cont'd)

Class 12: Exam

. * Fit logistic regression with GEE and robust variance estimation

.

. logistic lost3lets group sex age evrsmk hypstat, cluster(id) robust

Logistic regression Number of obs = 270 Wald chi2(5) = 9.26 Prob > chi2 = 0.0992Log pseudolikelihood = -177.60251 Pseudo R2 = 0.0288

(Std. Err. adjusted for 135 clusters in id)------------------------------------------------------------------------------ | Robust lost3lets | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- group | .5505154 .1348184 -2.44 0.015 .3406548 .8896608 sex | .7746617 .210509 -0.94 0.347 .4547826 1.319533 age | 1.043112 .0232002 1.90 0.058 .9986174 1.089589 evrsmk | 1.115575 .3005671 0.41 0.685 .6579021 1.89163 hypstat | 1.122232 .3005224 0.43 0.667 .6639566 1.896819 _cons | .0587517 .093936 -1.77 0.076 .002559 1.34889------------------------------------------------------------------------------

. logit

Logistic regression Number of obs = 270 Wald chi2(5) = 9.26 Prob > chi2 = 0.0992Log pseudolikelihood = -177.60251 Pseudo R2 = 0.0288

(Std. Err. adjusted for 135 clusters in id)------------------------------------------------------------------------------ | Robust lost3lets | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- group | -.5969004 .244895 -2.44 0.015 -1.076886 -.116915 sex | -.2553289 .2717432 -0.94 0.347 -.7879358 .277278 age | .0422086 .0222413 1.90 0.058 -.0013836 .0858008 evrsmk | .10937 .269428 0.41 0.685 -.4186992 .6374391 hypstat | .1153199 .2677898 0.43 0.667 -.4095385 .6401783 _cons | -2.834436 1.598865 -1.77 0.076 -5.968153 .2992822------------------------------------------------------------------------------

.

. estat gof

Logistic model for lost3lets, goodness-of-fit test

number of observations = 270 number of covariate patterns = 188 Pearson chi2(182) = 190.79 Prob > chi2 = 0.3127

. estat gof, group(5) table

Logistic model for lost3lets, goodness-of-fit test

(Table collapsed on quantiles of estimated probabilities) +--------------------------------------------------------+ | Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total | |-------+--------+-------+-------+-------+-------+-------| | 1 | 0.3210 | 16 | 15.8 | 40 | 40.2 | 56 | | 2 | 0.3785 | 17 | 18.6 | 36 | 34.4 | 53 | | 3 | 0.4411 | 20 | 22.2 | 34 | 31.8 | 54 | | 4 | 0.4948 | 28 | 24.8 | 25 | 28.2 | 53 | | 5 | 0.6350 | 30 | 29.7 | 24 | 24.3 | 54 | +--------------------------------------------------------+

number of observations = 270 number of groups = 5 Hosmer-Lemeshow chi2(3) = 1.38 Prob > chi2 = 0.7109

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 12

Page 13: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

2. Multiple Logistic Regression (cont'd)

Class 12: Exam

. predict phat(4 missing values generated)

. roctab lost3lets phat, binomial summary graph

ROC -- Binomial Exact -- Obs Area Std. Err. [95% Conf. Interval] -------------------------------------------------------- 270 0.6228 0.0349 0.56145 0.68028

. graph export exam2014_logit\roc.wmf,replace(file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\roc.wmf written in Windows Metafile format)

. * Fit ordinal logistic regression

.

. ologit lostcateg group sex age evrsmk hypstat , or nolog cluster(id) robust

Ordered logistic regression Number of obs = 270 Wald chi2(5) = 7.75 Prob > chi2 = 0.1706Log pseudolikelihood = -228.04896 Pseudo R2 = 0.0198

(Std. Err. adjusted for 135 clusters in id)------------------------------------------------------------------------------ | Robust lostcateg | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- group | .6614299 .1652359 -1.65 0.098 .4053591 1.079264 sex | .8711553 .2304949 -0.52 0.602 .5186569 1.463225 age | 1.049798 .0243973 2.09 0.037 1.003053 1.098722 evrsmk | 1.43094 .3936528 1.30 0.193 .8345555 2.453509 hypstat | .9380146 .2541613 -0.24 0.813 .5515322 1.595322-------------+---------------------------------------------------------------- /cut1 | 3.873394 1.764766 .4145155 7.332272 /cut2 | 5.253482 1.79055 1.744069 8.762896------------------------------------------------------------------------------

.

0.00

0.25

0.50

0.75

1.00

Sens

itivi

ty

0.00 0.25 0.50 0.75 1.001 - Specificity

Area under ROC curve = 0.6228

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 13

Page 14: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

2. Multiple Logistic Regression (cont'd)

Class 12: Exam

. * Goodness of fit - downloaded sg76

. omodel logit lostcateg group sex age evrsmk hypstat

Ordered logit estimates Number of obs = 270 LR chi2(5) = 9.21 Prob > chi2 = 0.1011Log likelihood = -228.04896 Pseudo R2 = 0.0198

------------------------------------------------------------------------------ lostcateg | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- group | -.4133513 .2563501 -1.61 0.107 -.9157883 .0890857 sex | -.137935 .2696494 -0.51 0.609 -.6664382 .3905681 age | .0485981 .0205511 2.36 0.018 .0083188 .0888775 evrsmk | .3583317 .2651744 1.35 0.177 -.1614006 .8780641 hypstat | -.0639898 .2628103 -0.24 0.808 -.5790884 .4511089-------------+---------------------------------------------------------------- _cut1 | 3.873394 1.506923 (Ancillary parameters) _cut2 | 5.253483 1.522743 ------------------------------------------------------------------------------

Approximate likelihood-ratio test of proportionality of oddsacross response categories: chi2(5) = 5.41 Prob > chi2 = 0.3683

.

.

.

. * Fit multinomial logistic regression

.

. mlogit lostcateg group sex age evrsmk hypstat , rrr nolog cluster(id) robust baseoutcome(1)

Multinomial logistic regression Number of obs = 270 Wald chi2(10) = 12.56 Prob > chi2 = 0.2491Log pseudolikelihood = -225.44753 Pseudo R2 = 0.0310

(Std. Err. adjusted for 135 clusters in id)------------------------------------------------------------------------------ | Robust lostcateg | RRR Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------1 | (base outcome)-------------+----------------------------------------------------------------2 | group | .5634033 .1661076 -1.95 0.052 .3161262 1.004103 sex | .834244 .2857102 -0.53 0.597 .4263588 1.632341 age | 1.050975 .0297657 1.76 0.079 .994225 1.110964 evrsmk | .9508372 .2991935 -0.16 0.873 .5131736 1.761765 hypstat | 1.007544 .3246579 0.02 0.981 .5357764 1.894716 _cons | .0168767 .0327572 -2.10 0.035 .000376 .7576054-------------+----------------------------------------------------------------3 | group | .7463762 .274176 -0.80 0.426 .363308 1.533348 sex | .8296139 .3205113 -0.48 0.629 .3890672 1.768998 age | 1.056104 .0353283 1.63 0.103 .9890831 1.127667 evrsmk | 2.418283 1.01944 2.09 0.036 1.05847 5.525045 hypstat | .8159866 .3303014 -0.50 0.615 .3690856 1.80401 _cons | .0037296 .0098372 -2.12 0.034 .0000212 .6558203------------------------------------------------------------------------------

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 14

Page 15: STATA LOG ( NEEDED TO ANSWER EXAM QUESTIONS EXAM STATA... · (file C:\Users\jtonasci\Desktop\Exam 2014\exam2014_logit\lowess.wmf written in Windows Metafile * GENERATE CATEGORICAL:

2. Multiple Logistic Regression (cont'd)

Class 12: Exam

. mlogit

Multinomial logistic regression Number of obs = 270 Wald chi2(10) = 12.56 Prob > chi2 = 0.2491Log pseudolikelihood = -225.44753 Pseudo R2 = 0.0310

(Std. Err. adjusted for 135 clusters in id)------------------------------------------------------------------------------ | Robust lostcateg | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------1 | (base outcome)-------------+----------------------------------------------------------------2 | group | -.5737595 .294829 -1.95 0.052 -1.151614 .0040947 sex | -.1812294 .342478 -0.53 0.597 -.852474 .4900152 age | .0497183 .028322 1.76 0.079 -.0057918 .1052283 evrsmk | -.0504124 .3146632 -0.16 0.873 -.667141 .5663161 hypstat | .0075153 .3222271 0.02 0.981 -.6240383 .6390689 _cons | -4.08182 1.940968 -2.10 0.035 -7.886047 -.2775926-------------+----------------------------------------------------------------3 | group | -.2925255 .3673429 -0.80 0.426 -1.012504 .4274533 sex | -.1867949 .3863379 -0.48 0.629 -.9440032 .5704134 age | .0545869 .0334516 1.63 0.103 -.0109769 .1201508 evrsmk | .883058 .4215554 2.09 0.036 .0568246 1.709291 hypstat | -.2033573 .4047877 -0.50 0.615 -.9967268 .5900121 _cons | -5.591446 2.637588 -2.12 0.034 -10.76102 -.4218684------------------------------------------------------------------------------

.

. test group

( 1) [1]o.group = 0 ( 2) [2]group = 0 ( 3) [3]group = 0 Constraint 1 dropped

chi2( 2) = 3.90 Prob > chi2 = 0.1422

. test age

( 1) [1]o.age = 0 ( 2) [2]age = 0 ( 3) [3]age = 0 Constraint 1 dropped

chi2( 2) = 4.67 Prob > chi2 = 0.0968

.

. log close----------------------------------------------------------------------------------------------------

Biostatistics 624 © 2014 by JHU Biostatistics Dept. Wed, 7 May 2014 (5:23p) CLASS 12 - 15