Statisical Modelling and Computing
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
MATH3821 Statisical Modelling and Computing
In your report please include all relevant R commands and outputs directly relevant to your answers. The
total marks for this assignment is 35. Up to 3 marks will be given to the overall presentation, i.e., clarity and
conciseness. The assignment is due on Monday June 19 at 5pm and should be submitted through the
link titled “Submission link - Assignment 1” on the subject’s moodle page.
Question 1 [5 Marks]
Use the command data<-read.csv("MATH3821_A#.csv") to import the data MATH3821_A#.csv to R, where
# is the last digit of your student ID (first download the data from the subject’s moodle page and set the
working directory of R to the folder where the data is stored, which can be done through the “Session”
tab). Construct pairwise plots of the data. Does a linear model appear to be appropriate? Comment on
whether there are apparent relationships between the predictors (the x’s) and response variable (y), and
which variable/s you expect to be significant as predictors.
Question 2 [10 marks]
Consider the linear model
yi = β0 +
4∑
j=1
βjxij + εi,
where the εi are independent normal mean zero errors, with common variance σ2.
(a) Write down an expression for the linear model, using the notation Y as the response vector, X as the
design matrix, β as the vector of coefficents, and ε as the vector of errors.
(b) Write down the expression for the log likelihood function. Use this expression to derive the maximum
likelihood estimator (MLE) for β and show that the MLE is equivalent to the least squares estimator
for β:
b = argmin
β
n∑
i=1
(
yi − β0 −
4∑
j=1
βjxij
)2
.
(c) Show that the MLE b is unbiased and derive its variance.
(d) Use your answer to (b) to compute b for the data in Question 1. Include the code you used for
this computation. (You may wish to use the commands X <- cbind(1,as.matrix(data[,-1])) and
Y<-as.vector(data[,1])).
Question 3 [5 marks]
Using R’s lm() function, fit the same linear model as in Question 2. Do you think any predictor/s can be
removed? Write down the resulting estimate, b∗, for β once you have removed the predictor/s. Explain how
you came to your estimate by including all R output and referring to any relevant tests used.