Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

PHP 2511: Applied Regression Analysis, Spring 2025

Homework 3: Transformation, Predictors, and Model Selection

Due: March 14 at 11:59 PM ET

Instructions:

•  All homework assignments must be submitted on Canvas by the due date.  The course syllabus includes details on the late policy.

• You are encouraged to collaborate with peers on assignments, but you must submit an individual assignment and all work must be your own.  You must abide by the Brown University Academic Code concerning:  i) use of sources, ii) creative work, iii) examinations, quizzes, and tests, and iv) laboratory work and assignments (https://college.brown.edu/design-your-education/academic-policies).

•  There are 4 questions in this assignment.

Please read each question carefully and provide complete answers including plots, tables, or sentence explanations as appropriate.

Questions  1-6  must be completed using statistical software.   You  must show your code to receive full credit.

•  This assignment requires data analysis of data from two studies.  Please make sure that you have the following data downloaded from Canvas to complete your assignment:

1. We will use data from the paper Evaluating  the performance of equations for estimating glomerular filtration rate” in the file ‘kidney small.csv’ .  The purpose of this study is to find a good model for predicting GFR (glomerular filtration rate) which is used to diagnose kidney failure. The dataset has information on the following variables:

gfr : glomerular filtration rate (mL / min)

bascre: serum creatinine (mg/ dL)

sbase: systolic blood pressure (mmHg)

dbase: diastolic blood pressure (mmHg)

baseu: urine protein (mg/dL)

age:  age (years)

male: male (1 if male, 0 if not)

black: Black (1 if Black, 0 if not)

2. We will use data from the paper “A clinical score for identifying active tuberculosis while await- ing microbiological results.” The goal of this paper was to identify patients at high risk for tuberculosis (TB) from clinical measures while awaiting test results. There are two data files ’tb kharitode.csv’ and ’tb stomp.csv.’ The former contains data from adults tested for TB with Xpert MTB/RIF in rural South Africa. This will be the training data. The latter is data from primary health clinics in urban Uganda and will be used as an external validation set. https: //journals.plos.org/plosmedicine/article?id=10.1371/journal.pmed.1003420. The dataset has information on the following variables:

tb: whether or not a person is diagnosed with TB with Xpert (1= tested positive, 0=tested negative)

age group: age group of the patient

male: recorded patient sex (1=male, 0=female)

hiv pos:  whether or not the patient has previously tested positive for HIV (1=Yes, 0 = No)

cough: whether or not the patient had a cough as a symptom (1=Yes, 0=No)

fever: whether or not the patient had a fever as a symptom (1=Yes, 0=No)

weight loss: whether or not the patient experienced weight loss (1=Yes, 0=No)

night sweats: whether or not the patient had night sweats as a symptom (1=Yes, 0=No)

chest pain: whether or not the patient had chest pain as a symptom (1=Yes, 0=No)

ever smoke: whether or not the patient has ever smoked (1=Yes, 0=No)

past tb: whether or not the patient has been diagnosed with TB previously (1=Yes, 0=No)

Your homework submission should include:

A word or pdf file with complete answers to the homework questions (including all final tables and plots you used in your data analysis).  You can type your answers in a separate word document or in a PDF version of this document. The document should be single-spaced with 12 point font in Arial, Calibri or Times New Roman.

A file with the code (well annotated) that you used to conduct the statistical analysis. The code should be written in R software or other statistical software and included in the Appendix not in the main document.  Assignments submitted without any code is an incomplete assignment. Your code in the Appendix.

• Files to Submit: submit one file saved as “PHP2511 Lastname Firstname HW3 Spring2024” .

•  Grading: This assignment is worth 40 points.  The grading criteria is based on the following learning objectives in the table below.

Concepts: transformation, predictors, model selection (Lectures 6-8, 12, and Vittinghoff et al.  CH 4.4- 4.8, 10) and logistic regression, interpreting results, stepwise selection, model evaluation, model validation (Lectures 9-11 and Vittinghoff et al.  CH 5.1-5.7)

Learning Objectives:

1. Understands methods for transformation (log, polynomial).

2. Interpret summary statistics for regression models including model coefficients, multiple correlation coefficients (R2 ), Adjusted R2 .

3.  Describe and evaluate assumptions of regression models.

4. Understands modelselection measures including likelihood ratio tests, AIC, BIC, MAE, and RMSE.

5.  Understands how to develop logistic regression models and evaluate model assumptions

6. Interpret summary statistics for logistic regression models including model coefficients

7. Understands model selection measures including likelihood ratio tests, AIC

8. Apply statistical software to fit models to data, visualize model diagnostics, and perform analysis.

Grading Rubric: This assignment is worth 40 points.

Question

1

Apply statistical software to fit models to data  and demonstrates understanding of transformation (log), AIC and Adjusted R2 (a).

Explains a few con- cepts, but  at least one part incorrect.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

2

Shows techniques using statistical software to fit models and correctly interprets sum- mary statistics for regression models includ- ing model coefficients, AIC, likelihood ratio tests (a) to (c).

Explains some con- cepts, but shows misunderstanding

for at least one part.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

3

Apply statistical software to create plots, fit models to data,  and  demonstrates  under- standing  of transformation   (polynomial),

AIC (a) to (b).

Explains some con- cepts, but shows misunderstanding

for at least one part.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

4

Demonstrates  understanding  of model  se- lection measures including likelihood ratio tests, AIC, BIC, MAE, and RMSE (a) to (d).

Explains some con- cepts, but shows misunderstanding

for at least one part.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

5

Shows understanding of applying software to summarize data, develop logistic regres- sion  models, evaluate  model assumptions and conduct model selection (a) to (d).

Explains a few con- cepts, but  at least one part incorrect.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

6

Demonstrates understanding of how to In- terpret summary statistics for logistic re- gression models including model coefficients (a) to (d).

Explains some con- cepts, but shows misunderstanding

for at least one part.

Does not address all concepts. Signifi- cant errors.

Incorrect.

Partial credit.

Homework 3

Use the kidney small. csv dataset and statistical software to answer questions 1 to 4.

Question 1. Read in the data and split the data into two sets to create a train and test data set. This code is provided in the code template.

(a)  Fit four regression models using these formulas

(a)  ‘mod1     < − log(gfr) ~ baseu + bascre + sbase + dbase + age + male ’

(b)  ‘mod2     < − log(gfr) ~ log(baseu) + bascre + sbase + dbase + age + male ’

(c)  ‘mod3     < − log(gfr) ~ baseu + log(bascre) + sbase + dbase + age + male ’

(d)  ‘mod4     < − log(gfr) ~ log(baseu) + log(bascre) + sbase + dbase + age + male ’

(b)  Determine whether you should log transform either bascre and/or baseu.   To do so, report the Adjusted R Squared and AIC for each model.  Explain why the investigator would use these two measures to compare these models, comment on the results, and explain why model 4 would be chosen using these criteria. Write about 4-6 sentences explaining your results.

Question 2. The investigator considers variable selection. The investigator decides to drop both sbase‘ and ‘dbase‘ variables from model 4 by finding the corresponding AIC value when dropping each variable. Additionally, the investigator uses a nested hypothesis to test this decision.

(a)  Calculate AIC for the models when ‘sbase‘ and ‘dbase‘ variables are removed from model 4.  Note that you should have 3 AIC values for 3 cases:  when only ‘sbase‘ is dropped  (call this ‘mod4 ‘), when ‘dbase‘ is dropped (call this ‘mod5 ‘), and when both ‘sbase‘ and ‘dbase‘ variables are dropped (call this ‘mod6‘).

(b) Explain what the null hypothesis and alternative hypothesis is for the nested hypothesis test and comment on the results in 2-4 sentences.

(c) Interpret the coefficients for the model when both ‘sbase‘ and ‘dbase‘ are dropped.  Be sure to take into account that a log transformation is used for the outcome and/or predictors.

Question 3  (BONUS). Using ‘mod6 ‘defined in Question 2, the investigator considers a polynomial transformation for serum creatinine.

(a)  Plot the residuals vs log serum creatinine from ‘mod6‘ .  What do you observe?  Write 2-3 sentences.

(b)  Consider a polynomial transformation for log serum creatinine.  Be sure to explain how you are choosing the degree for your polynomial transformation.  Using AIC as the model selection criteria, explain what polynomial transformation you recommend? Write 2-3 sentences.

Question 4. Evaluate your final model from Question 3.

(a) Use MAE and RMSE on both the training set and the withheld test set and compare the results. Write 2-3 sentences.

(b)  Discuss what you observe related to the bias-variance trade-off discussed in class.  Write 2-3 sen- tences.

(c) Assess the diagnostic plots for your resulting model from the training and testing sets (you may limit yourself to the four default plots in R in this discussion). Write 2-3 sentences.

(d)  Relate these results to the motivating question: overall how useful do you think your model would be for predicting GFR in practice? Write 2-3 sentences.

Question 5.  Use  statistical software  to  answer  the  questions  below  and the datasets  (  tb kharitode. csv and tb stomp. csv to answer the following questions.

(a) Fit an initial model containing all variables as predictors called ‘Model 1’ .

(b) Next, perform backwards stepwise selection using AIC to determine whether or not to remove any variables from the model.   The resulting model will be called Model 2.’   Explain how stepwise selection makes its decisions in iteration and comment on the results.   Hint:   To  do  backwards stepwise selection on a model in R you can run step(mod), where mod is the name of the model object.

(c) Use a likelihood ratio test to test the difference between the two models and interpret the results.

Question 6. Use ‘Model 2’ from Question 5 to answer the following questions.

(a) Interpret each of the estimated coefficients for Model 2.

(b)  Consider a possible interaction between HIV status and one other variable by using the variable definitions and the model output.  Fit this model with the interaction term to the data and name this ‘Model 3’ . Explain the interaction term you included in 1-2 sentences.

(c)  Determine whether or not you will keep this interaction in the model and justify your decision.

(d) Interpret the coefficients for the two variables and their interaction (you do not have to interpret the intercept or coefficients for variables not involved in the interaction).