Assessed Coursework 2
ST221 Linear Statistical Modelling Deadline: 28 April 2022, 1 pm
Please read these instructions carefully!
This assignment counts for 15% of your final module mark. The maximum score for this coursework is 50
Copyright By PowCoder代写 加微信 powcoder
Your solutions must be produced using a word processor, R Markdown, or LaTeX. You may cut-and-paste R-output. Use a font size of 11pt or larger. Question sub-sections must be clearly labelled for ease of marking.
If you do not submit your solutions in a typed format, then this will not be accepted as a submission.
You should convert your solutions into one PDF file that should be submitted on the ST221 moodle page.
Please read Chapter 5 in the course guide which gives details around the procedures regarding coursework including applying for extensions and lateness penalties. If you have any queries regarding extensions or penalties please direct them to the Statistics student support office and not the module leader.
If you have any queries about the coursework itself, please post them on the ST221 forum, but do not post any part of your solutions. You can also submit questions to the anonymous question form on moodle.
Please be aware that your work will be submitted to TurnItIn, a piece of plagiarism-detection software.
Make sure to read the questions carefully. If asked to produce a plot, then please include the plot in your report. Make sure it is of appropriate scale and the axes are clearly labelled. Similarly, if asked to consider R output, please include this in your report. Include R code only if explicitly requested to do so.
Good luck with the assignment!
Download the file Coursework2Data.csv from the moodle webpage and load it into R.
The dataset comprises information on the retail prices of second hand cars. The variables are:
• Price: the retail price of the second hand car (in 1000 £);
• Age: the age of the car (in months);
• Mileage: the mileage, that is the distance that the car has driven in its lifetime (in 1000 miles);
• MOT: time passed since the last MOT, a vehicle safety inspection that a registered car needs to pass
every year;
• ABS: whether the car has ABS, that is an anti-lock brake system which is an enhanced safety feature;
• Sunroof: whether the car has a sun roof.
(a) [1 mark] Produce a scatterplot of Price against Mileage.
(b) [3 marks] Consider polynomials up to degree 3 to model the relationship between Mileage and Price. Fit each model and then add to your scatterplot from (a) the corresponding fitted lines/curves using different colours/line types for each. Don’t forget to add a legend. Judging from your plot, which seems the most appropriate model? Explain why.
(c) [3 marks] Perform a sequential ANOVA on the cubic model from (b) and include the output in your report. What conclusion can you draw from the results?
(d) [8 marks] Explain how to use the results from (c) to compute the entries for the standard ANOVA table for the existence of regression for the quadratic model. Write out this ANOVA table.
(e) [7 marks] Perform the test for existence of regression for the quadratic model at a 5% significance level.
In your answer state clearly
• the null and the alternative hypothesis;
• the definition of the relevant test statistic;
• the distribution of the test statistic under the null hypothesis; • the observed value of the test statistic;
• the corresponding p-value;
• the outcome of the test and
• the conclusion you draw from the test.
(Hint: you may either use the results from (d) or use any other approach to obtain the relevant quantities, but in the latter case explain how you obtained the relevant quantities.)
(f) [4 marks] Produce the four default diagnostic plots (Residuals vs Fitted Values plot, Normal Q-Q plot, Scale-Location plot and Residuals versus Leverages plot) for the quadratic model. Briefly (1-2 sentences) comment on each plot.
(g) [2 marks] Next fit the model
Pricej = β0 + β1Mileagej + β2Mileage2j + β3Agej + β4Age2j + εj ,
where j = 1, . . . , 172. Explain how to use the information provided in the model summary output for this model to obtain an unbiased estimate for the variance of the errors. Give the numerical value of the unbiased estimate for the variance of the errors.
(h) [7 marks] Perform a hypothesis test at a 5% significance level to decide whether the quadratic term in Age is needed in the model in (g). In your answer state clearly
• the null and the alternative hypothesis;
• the definition of the relevant test statistic;
• the distribution of the test statistic under the null hypothesis; • the observed value of the test statistic;
• the corresponding p-value;
• the outcome of the test and
• the conclusion you draw from the test.
(i) [2 marks] Use the function influenceIndexPlot from the car package applied to the fitted model in (g) to produce an index plot of the leverages. Which are the observations with the six highest leverages? (Hint: use the option list(n=6) in the command influenceIndexPlot to label the observations with the
six highest leverages.)
(j) [3 marks] Produce a scatterplot of Age against Mileage such that the observations with the six highest leverages identified in (i) have a different colour from the other data points. How would you characterise these observations in terms of their age and mileage?
(k) [2 marks] Produce an index plot of the Cook’s distances for the model in (g). Which are the observations with the three highest Cook’s distances?
(l) [3 marks] For the model in (g) use the command influencePlot(model, id=list(n=3)) from the car package to produce a bubble plot that flags up the datapoints with the three largest absolute studentised residuals, the datapoints with the three highest leverages and the datapoints with the three highest Cook’s distance. Explain in terms of their leverage and residual, why the observations identified in (k) have the highest Cook’s distance?
(m) [2 marks] Consider a new model produced by adding the explanatory variables MOT, ABS and Sunroof to the model in (g). Give the R code that you would use to fit the model and to perform a hypothesis test to decide whether the new model is a significant improvement over the model in (g).
(n) [3 marks] Perform a forward stepwise variable selection using the AIC as the model selection criterion. Use as the minimal model
Pricej = β0 + β1Mileagej + β3Agej + εj for j = 1, . . . , n.
As the maximal model use the model in (m). Include the output in your report. Which model is selected as
the final model and what value does the AIC take for this model?
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com