Question 1
- A linear regression model is fit for the
carsdataset. The dataset has 50 observations with 2 variablesdistandspeed. Study the code and answer the following subquestions:
data(cars)y <- cars$distx <- cars$speed
car_mod <- lm(y ~ x, data = cars)coef(car_mod)
## Output> coef(car_mod)(Intercept) x -17.579095 3.932409(a) Find the best fit line . [2 Marks]
(b) Find the residual corresponding to the data point . [3 Marks]
- Let be i.i.d. samples from a normal distribution with mean and variance . Consider the sample mean and sample variance as
then which of the following are true? Select all that apply [3 Marks]
(a)
(b)
(c)
(d)
(e)
- Consider the first 10 rows of the
irisdataset as below:
head(iris, 10)
## output Sepal.Length Sepal.Width Petal.Length Petal.Width Species1 5.1 3.5 1.4 0.2 setosa2 4.9 3.0 1.4 0.2 setosa3 1.0 1.0 1.0 1.0 <NA>4 4.6 3.1 1.5 0.2 setosa5 5.0 3.6 1.4 0.2 setosa6 5.4 3.9 1.7 0.4 setosa7 2.0 2.0 2.0 2.0 <NA>8 5.0 3.4 1.5 0.2 setosa9 3.0 3.0 3.0 3.0 <NA>10 4.9 3.1 1.5 0.1 setosa(a) What will be the output of iris[7, 5]? [1 Mark]
(b) What will be the output of the following code snippet? [2 Marks]
iris$Sepal.Length[c(1, 4, 7)] = c(5, 5, 5)iris[c(1, 4, 5), ](c) The iris dataset contains a total of 150 observations. Consider the following output:
var(iris$Sepal.Length)[1] 0.8636282Then, find the population variance of the variable Sepal.Length. [2 Marks]
- Consider the linear model :
where :
- is a random effect for group , independent of .
- are independent errors.
- is a known covariate.
Find the distribution of . [2 Marks]
- Suppose you fit a linear regression model to the following data:
| 1 | 2 |
| 2 | 4 |
| 3 | 5 |
| 4 | 4 |
| 5 | 5 |
and the estimated regression equation is : . If the prediction errors be defined by , then calculate the value of . [4 Marks]
-
Let be a linear model and . Prove that is estimable . [4 Marks]
-
Consider a model:
where and 's are uncorrelated random variables with variance ; .
(a) If we want to rewrite the model as , then find and . [2Marks]
(b) Define Normal equations and using normal equations find the least square estimates of and . [5 Marks]
I have written answers on the answer sheets
Not applicable
