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

MATH70071 - Tutorial 1

Normal Linear Models

This problem sheet will investigate fitting a normal linear model to the trees dataset. To get started in R clear the workspace, load the data and perform some preliminary exploration of the data as follows:

> rm(list=ls())

> data(trees)

> head(trees)

> names(trees)

> dim(trees)

#clear loadspace

#bring the data  into the workspace

#the variable names

Make sure you understand what each of the R commands are doing.  More information about commands, functions and datasets can be found by typing e.g.

> ?trees

> ?head

in R.

For the trees dataset, suppose we are interested in fitting the model

v = ηh1+β2 g2+β3 γ, (1)

where v is the volume, is h the height and g the girth of a tree.  The η term is assumed to be a fixed constant and γ an error random variable with its realisations taking values around one.

Q1)  Give a physical interpretation of the error in model (1) in the context of the data.

Q2)  Show that the model in (1) can be written in the form:

Y = β1 + β2x2 + β3x3 + ϵ .                                            (2)

Make sure you identify all the βj  parameters with respect to the parameters in model (1). What assumption on γ is required for (2) to be a normal linear model?

Q3) Let’s visually inspect the data as presented and for the logged version. Start by creating a logged version of the dataset as follows:

> logtrees <- log(trees)

Use the boxplots and the pairs function in R to inspect the logged dataset.  Are there any concerns fitting a normal linear model to the dataset?  If there are concerns, which model assumptions are violated and how is this violation indicated in the graphical plots?

Note: The pairs function may be used as follows in R as:

> pairs(logtrees, main =  "trees data", upper.panel = NULL)

Q4) Fit the linear model (2) in R. Comment on the summary of the fitted model.

Q5) For the fitted model, inspect diagnostic plots i.e. the Q-Q plot, residual versus fitted plot etc.  Do these plots suggest any concern with the fitted model?  If there are any concerns, how would you refine the model to address these concerns?

Q6) Using the trees dataset, state a model that yields a RSS value equal to 0.   State another different model which gives RSS= 0.  State yet another different model which gives RSS= 0.

Note:  You can check in R that these models give a RSS value of 0  (or some value numerically very close to zero).

Q7)  Generate 99 new samples from model (2). Generate 1 other datapoint that has:

. High leverage and low residual value

. Low leverage and high residual value

. High leverage and high residual value

Note: you can generate n random numbers from a N(mu, sig2 ) distribution in R by

> rnorm(n, mean = mu, sd = sig)

Beware that the input in the rnorm function is the standard deviation, not the variance. The input for mu can be a vector e.g.

> rnorm(5, mean =  1:5, sd =  0.5)

[1]  1.327953  1.774283  2.910688  4.358952  4.862181

Q8)  Show how Equation (2.4) is obtained from (2.3) in the lecture notes.

Q9) Derive the confidence interval (Equation 2.5) for βj  from (2.4) in the lecture notes.