TBA2104 Predictive Analytics 2018/19 Sem 2
Individual Assignment 2
· This assignment contributes 15% to the final course grade. The total marks for this assignment is 15.
· Deadline: 12 Apr 2019 2359hrs (Friday 11:59pm)
· Late submission will be penalized.
· Upload the softcopy (a single pdf or doc/docx) to IVLE workbin (Deliverables Submission > Assignment 2)
· Please ensure that you have written your name and matric number in the document
1. This question is based on the diabetes dataset (diabetes.arff). This dataset consists of 768 observations and 9 attributes. The brief description of the attributes are as follows:
· preg : Number of times the patient is pregnant
· plas: Plasma glucose concentration
· pres : Diastolic blood pressure (mm Hg)
· skin : Triceps skin fold thickness (mm)
· insu: 2-hour serum insulin (mu U/ml)
· mass : Body mass index (weight in kg / (height in m)^2)
· pedi : Diabetes pedigree function
· age : Age (years)
· class : Class variable (either tested_negative or tested_positive)
a) Provide the R codes for loading the data into a variable Diabetes. (1 mark)
b) Provide the R codes generating the CSV equivalent of the diabetes dataset (diabetes.csv). (1 mark)
c) Compare and contrast the similarities and differences of the ARFF format and the CSV format. (2 marks)
d) Provide the R codes for generating a logistic regression model (model) using
class as the response and the other attributes as predictors. (1 mark)
e) Using the logistic regression results of the model, write down the equation of log- odds of the model. Please round off all the coefficient estimates to 4 decimal places. (1 mark)
f) We learned that logistic regression uses a logistic function: Pr(Y=REFERENCE_ CLASS | data) (i.e. the probability of class = REFERENCE_CLASS given a data point. It turns out that R uses the first level value of a factor-type attribute as the reference class.
 tested_positive …
 tested_negative …
Levels: tested_negative tested_positive
I.e. from the above output, we can tell that the REFERENCE_CLASS is test_negative. Using this model, determine whether the following testing data point should be classified as tested_negative or tested_positive. You show the step by step (mathematical) working how you arrive at this conclusion.
g) Provide the R codes for verifying the probability value of f) using the predict()
function in R. (2 marks)
h) Suppose you want to change the reference class in R to tested_positive, you could use the relevel() function. Read the help pages and provide the R command to change reference class to test_positive so that predict() will be based on tested_positive. (1 mark)
i) If you were to generate a new model (model2) using tested_positive as the reference class, what is the difference in the regression model of model2 compared to model? (2 marks)