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

Multivariate Analysis Assignment

2021/2022

1.  Load the data set into R. Use the set.seed function in R to set the seed to your student number. Randomly generate a number between 1 and n (where n is the number of rows in the dataset), and delete that observation/row from the dataset. Ensure that you include the code used in this step in the R code associated with your assignment.  [0 marks]

2. Visualise the spectra and the protein trait α S l-casein using (separate) suitable plots. Comment on the plots. Remove any observations with α S l-casein outside of 3 standard deviations from the mean of the trait.  [10 marks]

3.  Use hierarchical clustering and k-means clustering to determine if there are clusters of similar MIR spectra in the data. Motivate any decisions you make. Compare the hierarchical clustering and k-means clustering solutions. Comment on/explore any clustering structure you uncover, considering the data generating context.  [25 marks]

4.  Apply principal components analysis to the spectra, motivating any decisions you make in the process. Plot the cumulative proportion of the variance explained by the first 10 principal components. How many principal components do you think are required to represent these data? Explain your answer. [10 marks]

5.  Derive the principal component scores for the milk samples from first principles (i.e. you should not use an inbuilt function such as predict(. . . )).  Plot the principal component scores for the milk samples. Comment on any structure you observe.  [15 marks]

6. Interest lies in predicting the level of the protein α S l-casein in a milk sample using MIR spectra. Principal components regression (PCR) and partial least squares regression (PLSR) are two approaches to doing so for these data.  Research these methods and how they work e.g. see An Introduction to Statistical Learning with Applications in R by James et al. (2017), The Elements of Statistical Learning by Hastie et al. (2017) as detailed in the module’s list of references, and/or the peer-reviewed journal article The pls Package: Principal Component and Partial Least Squares Regression in R by Mevik and Wehrens (2007). In your own words, write a maximum 1 page synopsis of the PCR and PLSR methods. Your synopsis should (i) explain the methods’ purposes, (ii) provide general descriptions of how the methods work, (iii) detail any choices that need to be made when using the methods and (iv) outline the advantages and disadvantages of the methods.  [50 marks]

7.  Use e.g. the pls R package to use PLSR to predict the α S l-casein trait for a test set of the MIR data provided, where the test set is one third of the original data. Motivate any decisions you make.  [20 marks]

8.  Perform the previous question again, but using your own code and from first principles, rather than using the pls function.  The peer-reviewed journal article The pls Package:  Principal Component and Partial Least Squares Regression in R by Mevik and Wehrens (2007), andor the other references mentioned in question 6, may be useful here. Use plots and summaries where relevant to assist in your analysis. You may use functions such as svd and/or lm if you wish, but not necessarily.  [70 marks]