--- title: "Math 50 Fall 2017, Homework #3" ---
__NOTE: For your homework download and use the template__ (https://math.dartmouth.edu/~m50f17/HW3.Rmd) __Read the green comments in the rmd file to see where your answers should go.__


## Question-1 Is maximum-likelihood estimator $\tilde{\sigma}^2$ of $\sigma^2$ an unbiased estimator ? Verify your answer. Comment on the change of the value of $$E(\tilde{\sigma}^2) - {\sigma}^2$$ as $n$ goes to infinity. ### Answer:


## Question-2 Consider the shear strength vs age relation using the propellant data. (a) Recalculate the coefficients of the fitted linear regression model using the vector equations we obtained. (b) Suppose that the expectation of the initial shear strength is known to be 2400. Write the corresponding model (should involve only one parameter $\beta_1$). Calculate 95% CI on $\beta_1$. ### Answer: ```{r} # Computation part of the answer : ```


## Example : Phytoplankton Population A scientist is trying to model the relation between phytoplankton population in the city public water supply and concentration of two substances. The sample data is at : https://math.dartmouth.edu/~m50f17/phytoplankton.csv where headers are - pop : population of phytoplankton ($y$) - subs1 : concentration of substance-1 ($x_1$) - subs2 : concentration of substance-2 ($x_2$) Lets consider a guessed model $$ y = 200 + 10x_1 -15x_2 $$ Below is the corresponding code to plot the scatter diagram and the above plane. ```{r} # Note: Run the following in R console if you get errors in plotting or library loading : # install.packages("scatterplot3d") # install.packages("plot3D") library("plot3D") library("scatterplot3d") # Loading data pData <- read.table("https://math.dartmouth.edu/~m50f17/phytoplankton.csv", header=T, sep=",") pop <- pData$pop subs1 <- pData$subs1 subs2 <- pData$subs2 # Create a mesh meshP <- mesh( seq(min(subs1),max(subs1),0.03) , seq(min(subs2),max(subs2),0.03) ) x1Mesh <- meshP$x x2Mesh <- meshP$y myModel <- 200 + 10*x1Mesh - 15 *x2Mesh # Below is the code to plot the scatter diagram with red markers and your model # You need to set two variables before calling : # myModel : your model # PLOTTING # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sc1 <- scatterplot3d(subs2,subs1,pop, pch=17 , type = 'p', angle = 15 , highlight.3d = T ) sc1$points3d (x2Mesh,x1Mesh, myModel, cex=.02, col="blue") ``` ```{r} # You can also change the view angle to visually test the model # PLOTTING # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sc1 <- scatterplot3d(subs2,subs1,pop, pch=17 , type = 'p', angle = 125 , highlight.3d = T ) sc1$points3d (x2Mesh,x1Mesh, myModel, cex=.02, col="blue") ```


## Question-3 For the phytoplankton population data use regression model of the form $$ y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \varepsilon . $$ Fit a multiple linear regression model (using (3.13) and hat matrix H). Plot scatter diagram and fitted plane. Print predicted coefficients. Calculate $R^2$ and adjusted $R^2$. ### Answer: ```{r} # Computation part of the answer : ```


## Question-4 This time use a more general model for the phytoplankton population data ; $$ y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_{11} x_{1}^2 + \beta_{22} x_2^2 + \beta_{12} x_1 x_2 + \varepsilon. $$ Fit a multiple linear regression model (using (3.13) and hat matrix H). Plot scatter diagram and fitted surface. Print predicted coefficients. Calculate $R^2$ and adjusted $R^2$. Compare with the previous model. ### Answer: ```{r} # Computation part of the answer : ```