Docsity

Solved Problems on Intermediate Biostatistics - Study Guide | PUBHLTH 640, Study notes of Community Health

Toggle sidebar
bg1
PubHlth 640 Intermediate Biostatistics 1
Unit 5 – Logistic Regression
Practice Problems -Week #8
SOLUTIONS
1. Source: Kleinbaum, Kupper, Miller, and Nizam. Applied Regression Analysis and Other Multivariable
Methods, Third Edition. Pacific Grove: Duxbury Press, 1998. p 683 (problem 2).
A five year follow-up study on 600 disease free subjects was carried out to assess the effect
of 0/1 exposure E on the development (or not) of a certain disease. The variables AGE (continuous)
and obesity status (OBS), the latter a 0/1 variable were determined at the start of the follow-up and were
to be considered as control variables in analyzing the data.
(A) State the logit form of a logistic regression model that assesses the effect of the 0/1 exposure
variable E controlling for the confounding effects of AGE and OBS and the interaction effects
of AGE with E and OBS with E.
Solution:
01 2 3 4 5
logit[π] = β + β*E + β*AGE + β*OBS + β*AGEE + β*OBSE
I used the following notation:
π = Probability [ disease ]
AGEE = AGE * E. This is a created variable that is the interaction of AGE with E
OBSE = OBS * E Similarly, this is the interaction of OBS with E.
01 2 3 4 5
logit[π] = β + β*E + β*AGE + β*OBS + β*AGEE + β*OBSE
Wk8_solutions.doc
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Solved Problems on Intermediate Biostatistics - Study Guide | PUBHLTH 640 and more Study notes Community Health in PDF only on Docsity!

Unit 5 – Logistic Regression Practice Problems -Week

SOLUTIONS

1. Methods, Third Edition.Source: Kleinbaum, Kupper, Miller, and Nizam. Pacific Grove: Duxbury Press, 1998. Applied Regression Analysis and Other Multivariable p 683 (problem 2).

A five year follow-up study on 600 disease free subjects was carried out to assess the effectof 0/1 exposure E on the development (or not) of a certain disease. The variables AGE (continuous)and obesity status (OBS), the latter a 0/1 variable were determined at the start of the follow-up and were

to be considered as control variables in analyzing the data.

(A) State the logit form of a logistic regression model that assesses the effect of the 0/1 exposurevariable E controlling for the confounding effects of AGE and OBS and the interaction effectsof AGE with E and OBS with E.

Solution: logit[π] = β 0 + β 1 *E + β 2 *AGE + β 3 *OBS + β 4 *AGEE + β 5 *OBSE

I used the following notation: π = Probability [ disease ]

AGEE = AGE * E. OBSE = OBS * E This is a created variable that is the interaction of AGE with ESimilarly, this is the interaction of OBS with E.

logit[π] = β 0 + β 1 *E + β 2 *AGE + β 3 *OBS + β 4 *AGEE + β 5 *OBSE

(B) Given the model you have for part “A”, give a formula for the odds ratio for the exposure-diseaserelationship that controls for the confounding and interactive effects of AGE and OBS.

Solution: The solution here follows the ideas on pp 9-11 in Lecture Notes 5, Logistic Regression.

Predictor Value of Predictor for Person who isExposed Not Exposed

OBS^ AGE^ E^ AGEOBS1^1 1 OBSAGE^000

AGEEOBSE AGEOBS 11

Then OR = exp { logit[π for exposed person] - logit[π for NON exposed person] }

= exp { - [[ ββ 0 0 ++ ββ 1 2 *AGE+ β 2 *AGE 0 + β 1 3 *OBS ] }+ β 3 *OBS 0 1 + β 4 *AGE 1 + β 5 *OBS ] 1

= exp { β 1 + β 2 *(AGE -AGE ) + 1 o β 3 *(OBS - OBS ) + 1 0 β 4 *AGE 1 + β 5 *OBS } 1

(C) Now use the formula that you have for part “B” to write an expression for the estimated oddswhen AGE=40 and OBS=1.ratio for the exposure-disease relationship that considers both confounding and interaction

Solution: OR = exp {ˆ β 1 + (40)β 4 + β 5 }

Predictor Value of Predictor for Person who isExposed Not Exposed

OBS^ AGE^ E^4011

AGEEOBSE 401 00

OR = exp { β 1 + β 2 *(40-40) + β 3 *(1 - 1) + β 4 *40 + β 5 *1 } = exp { β 1 + β 4 *40 + β 5 *1 }

(B) Using these quartile values, create a set of 2 distribution of each of these three indicator variables.nd 25%, 3 rd 25%, and upper 25% of the values of age. Produce a frequency table three design variables that are indicators of the Hint – Design variables (also called

indicator or dummy variables) were introduced in51-53. Topic 2 (Regression and Correlation). See pp

------------+-----------------------------------^ i_age2^ 01 | || Freq. 22272 Percent75.5124.49^ 100.00Cum.75. ------------+----------------------------------- Total | 294 100. ------------+-----------------------------------^ i_age3 01^ |||^ Freq. 21579 Percent73.1326.87^ 100.0073.13Cum. ------------+----------------------------------- Total | 294 100. ------------+-----------------------------------^ i_age4 01^ |||^ Freq. 22668 Percent76.8723.13^ 100.0076.87Cum. ------------+----------------------------------- Total | 294 100.

(C) Fit a logistic regression model for the outcome CASES that includes as predictors the designvariables you produced in part “B”

Logistic Log likelihood regression = -132.23409 Number LR ProbPseudo chi2(3) > ofchi2R2 obs ==== (^) 0.30100.01363.66 294 ------------------------------------------------------------------------------ -------------+---------------------------------------------------------------- i_age2 cases || (^) -.0300523Coef. Std..4045487 Err. -0.07z P>|z|0.941 (^) -.8229533[95% Conf. Interval]. ------------------------------------------------------------------------------^ i_age3^ i_age4^ _cons^ |||^ -.5166637-.7099543-1.304949^ .4301908.4702295.2818673^ -1.20-1.51-4.63^ 0.2300.1310.000^ -1.359822-1.631587-1.857398^ .3264948.2116785-.

(D) group (the lowest quartile of AGE) is 0. Fill in the following table. Notice that the estimated regression coefficient for the referent

Quartile 1 Midpoint___ 23 __ βˆ 0 se( 0 βˆ)

234 _________ 345168 ______ _-0.0301-0.5167-0.7100______ _________0.40450.43020.4702______

(E) Construct a plot of X=Midpoint versus Y=construct a similar plot with accompanying 95% confidence limits. β^ ˆ. If you’re feeling ambitious,

Source: week8_640.png

(F) From the plot you constructed in part “E”, what do you conclude about the linearityof logit (CASES) in AGE?

Solution: Logit (CASES) is marginally linear in AGE.

. ------------+----------------------------------- tabulate i_age4 i_age4 | Freq. Percent Cum. ------------+----------------------------------- Total^01 |||^22629468 100.0076.8723.13^ 100.0076. ... (^) (^) SOLUTION * logit Fit (^) a cases logistic for i_age2 #2C regression i_age3 i_age4 model using the command LOGIT and the 3 design variables just created Logistic Log likelihood regression = -132.23409 Number LR ProbPseudo chi2(3) > ofchi2R2 obs ==== (^) 0.30100.01363.66 294 ------------------------------------------------------------------------------ -------------+---------------------------------------------------------------- i_age2 cases || (^) -.0300523Coef. Std..4045487 Err. -0.07z P>|z|0.941 (^) -.8229533[95% Conf. Interval]. ------------------------------------------------------------------------------^ i_age3^ i_age4^ _cons^ |||^ -.5166637-.7099543-1.304949^ .4301908.4702295.2818673^ -1.20-1.51-4.63^ 0.2300.1310.000^ -1.359822-1.631587-1.857398^ .3264948.2116785-. ...* (^) * (^) ***** (^) * sort (^) Fill SOLUTION Use (^) agequart incommand the for table (^) SORT #2D withto sort midpoint data byof quartileage and betasof age and se's .. ---------------------------------------------------------------------------------------------------------------- (^) * by use agequart: command (^) centile CENTILE (^) age, with (^) c(50) option c(50) preceded by BY command to obtain midpoints -> agequart Variable = | (^1) Obs Percentile Centile --[95% Binom. Conf. Interp. Interval] -- -------------+------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------- age | 75 50 23 22 24 -> agequart Variable = | (^2) Obs Percentile Centile --[95% Binom. Conf. Interp. Interval] -- -------------+------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------- age | 72 50 34 33 36 -> agequart Variable = | (^3) Obs Percentile Centile --[95% Binom. Conf. Interp. Interval] -- -------------+------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------- age | 79 50 51 50 54 -> agequart Variable = | (^4) Obs Percentile Centile --[95% Binom. Conf. Interp. Interval] -- -------------+------------------------------------------------------------- age | 68 50 68 65.38909 71

. NOTE: with *** SOLUIION** theThe points solution for (^) that #2E to you #2E want requires to plot, saving saving depress.dta, it, and using clearing it… the work space, creating a new little data set ... (^) ** clear UseBefo there creatingdrop down a menu:new data FILE set, > SAVEuse theAS tocommand save yourCLEAR enhancements to your data. .... save UseWhenUse "/Users/carolbigelow/Desktop/week8plot.dta"the (^) theyou’re dropdrop done downdown entering menu:menu: DATA (^) FILEdata, >> DATAexitSAVE EDITORtheAS todata saveto editorcreate your newa new data data as set.WEEK8PLOT.dta file.. use Use/Users/carolbigelow/Desktop/week8plot.dta "/Users/carolbigelow/Desktop/week8plot.dta" the drop down menu: FILE > OPEN to actually saved use your new data set .. (^) * list Use +-----------------------------+ command LIST to check creation of data set 1. 2. |^ |-----------------------------|||^ midpoint 2334 betahat-.0301 0 sebeta.4045 0 ||| 3. 4. || +-----------------------------+ 5168 -.5167-.71 .4302.4702 || .. NOTE: (^) * graph Use (^) (^) Once command twoway the (^) connected GRAPH basic (^) TWOWAY graph betahat (^) has CONNECTED (^) been midpoint created followed for by you, Y variable you can (^) first click (^) then on the X (^) variable graph editor (it’s an icon that looks like When the (^) extension ayou histogram) are done, is (^) “png”. and be (^) try sure your to (^) save hand (^) yourat creating graph by titles, clicking etc. in the icon that looks like a disk. A good choice for

PubHlth 640 by age_grp; Intermediate Biostatistics 10 run; *^ tables I_age2 I_age3 I_age4; *_________________________________________ * * Homework * Produce a frequency distributionQuestion #2B - of the

  • three indicator variables. *_________________________________________; proc freq tables I_age2 I_age3 I_age4; data=temp; run; * *_____________________________________________ * * Homework * Fit a logistic regression Question #2C - model of outcome
  • CASES with predictors * variables. * * Use option DESCENDING theso that event three design modeled
  • is CASES=1 *_________________________________________________; proc logistic model cases=I_age2 data=temp I_age3 descending; I_age4; run; *_______________________________________________ *
  • Homework * * * Obtainfor plotting later. midpoint of age inQuestion #2D - each quartile
  • *________________________________________________; proc means (^) by age_grp;note - datadata=temp is already sorted by age_grp MEDIAN; run; *^ var^ age; ______________________________________________ * * _________________________________________________; Data set for plotting data temp2; input midage upp low = beta += beta - beta1.96sebeta;1.96sebeta; sebeta; cards; 23 0 34 -0.0301 0.4045 51 -0.5167 0.4302 0 ; run; *^ 68 -0.7100 0. *_____________________________________ * * Homework * Plot of X =Question midpoint of age versus #2E

PubHlth 640 * Y = estimated coefficient (^) from logistic model. Intermediate Biostatistics 11 ________________________________________; goptions reset=symbol; symbol1 v=square color=blue i=j; proc gplot run; plot title "Estimated beta betamidage; data=temp2; by Midpoint of Age";

  • *______________________________________________ * * Homework Question #2E
  • Similar ________________________________________________; goptions reset=symbol; symbol1 plotv=square color=red with 95% confidence i=j; limits proc gplot^ symbol2^ symbol3^ v=square color=blue i=j;v=square color=reddata=temp2;^ i=j; run;^ plot^ title "Estimated beta^ uppmidage betamidage lowmidage/overlay;^ by Midpoint of^ Age"; quit;

Week8_01.jpg Week8_02.jpg

  • ii.) Analyze > Descriptive Statistics > Frequencies Q2: Age 29 to
  • Valid .00 1.00 Frequency 22272 Percent75.524.5 Valid Percent75.524.5 Cumulative Percent100.075. - Total 294 100.0 100. - Q3: Age 43 to
  • Valid .00 1.00 Frequency 21579 Percent73.126.9 Valid Percent73.126.9 Cumulative Percent100.073. - Total 294 100.0 100. - Q4: Age 60 to
  • Valid .00 1.00 Frequency 22668 Percent76.923.1 Valid Percent76.923.1 Cumulative Percent100.076. - Total 294 100.0 100.

2C.) Analyze > Regression > Binary logistic

logit(P{CASES=1}) = β 0 + β1ageQ2 + β Variables in the Equation 2ageQ3 + β 3 ageQ

ageQ2 ageQ3 B-.030-.517^ S.E..405.430^ Wald1.442.006^ df^11 Sig..941.230^ Exp(B).970.

a Variable(s) entered on step 1: ageQ2, ageQ3, ageQ4.^ Step^ 1(a)^ ageQ4^ Constant^ -1.305-.710^ .470.282^ 21.4342.280^11 .131.000^ .492.

2D.) from estimates in 2B and 2C Quartile Midpoint (^) β SE(β) 123 23.535.551.0 (^) -0.030-0.517 (^0) 0.4050.430 0 2E.) Create a separate dataset to hold the data from 2D.^4 74.5^ -0.710^ 0. File > New > Data

20.0 30.0 40.0 midpoint 50.0 60.0 70.0 80.

betahat

2F.) logit(cases) appears to be linear in age with a negative slope. As age increases (as evidenced by midpoint) betahat ( decreases. β)

2A.) Stat > Basic Statistics > Display Descriptive Statistics…^ For Minitab Users

Click Statistics… button

Click OK.

Unfortunately, Minitab does not have a menu option to populate the data as required, so you will need to enter these by hand.However, drag filling and copy and paste techniques that work in Excel also work in Minitab. AGE AgeQ2 AgeQ3 AgeQ (^18) … (^29) … (^01 00 ) (^43) … 60 00 10 01 2C.) Stat > Regression > Binary Logistic Regression… logit(P{CASES=1}) = β 0 + β1ageQ2 + β2ageQ3 + β3ageQ

Click OK.

Binary Logistic Regression: CASES versus AgeQ2, AgeQ3, AgeQ4 Link Function: Logit

Response Information Variable CASES Value 1 Count 50 (Event)

0 Total 244294

Logistic Regression Table Predictor Coef SE Coef Z P Ratio Odds Lower95% CI Upper

Constant AgeQ2 AgeQ3 AgeQ4 -0.0300523-0.516664-0.709954-1.30495 0.2818670.4045490.4301910.470229 -4.63-0.07-1.20-1.51 0.0000.9410.2300.131 0.970.600.49 0.440.260.20 2.141.391.

Log-Likelihood = -132.234 Test that all slopes are zero: G = 3.656, DF = 3, P-Value = 0.301 >> Remarks :

  • • • CASES=1 is modeled as the event by default (a good thing for us).None of the covariates are significant at the alpha=0.05 levelWe failed to reject the global hypothesis that all slopes = 0, thus it is reasonable to assume there is no significant difference 2D.) from estimates in 2B and 2Camong the quartiles of age with respect to their association with the occurrence of depression Quartile 12 Midpoint23.535.5 (^) -0.030β 0 SE(0.405 0 β) 34 51.074.5 -0.517-0.710 0.4300. 2E.) File > New Worksheet Place the names of the new variables at the top of the columns (C1, C2, C3). Then enter the data from 2D by hand. Create a separate dataset to hold the data from 2D Graph > Scatterplot > With Regression