Please help me solve the following in r studio
Recall the following theory: Suppose we have a set of P - 1 independent variables X1. ..., Xp-, which can be used to build a model for the response variable Y. This model is given by Y= Pot BIXat . + Bp-1Xip-1+ 4- Now suppose that we also fit a smaller model for the response variable Y using only p - 1 of all P - 1 independent variables, say X1. ...,Xp-1, where p s P, i.e., Y= Bot BIXat+ Bo-Xin-1+ 8. The formula for Mallow's C, obtained when fitting a model with only p - 1 of the independent variables is given by: SSEp Cp MSE(X 1, ..,XP-1 ) - (n - 2p). where n-P . MSE(X], .,Xp_1) = is the mean error sum of squares for the model based on all P - 1 predictor variables (note that , is the predicted value based on the full model with all the P - 1 regressors (independent variables), i.e., all P parameters are in the model, Bo, B1, .... Bp-1). . SSEp = EN-(Y - Ppi)" is the error sum of squares for the model based on only p - 1 predictor variables (note that Pp is the ith predicted value based on the smaller model with p - 1 regressors (independent variables), i.e., there are only p parameters in the model, Bo, B1, -...Pp-1). and n is the number of observations. Use the following data to test if the program works: y=c (10 , 15, 23,14, 26) (The observed response variable, Y). yhatl=c (12 , 18, 21,16, 24) (The predicted values, Y, based on a regression model with all P - 1 = 3 regressors, i.e., P = 4) yhat2=c (11 , 13, 22,17, 22) (The predicted values, Ypi, based on a regression model with only p - 1 = 2 regressors, i.e., p = 3) 3.1 Calculate MSE (X], ..., Xp_]) = =(1-P()] n-P (Code: 2) 3.2 Calculate SSEp = El-, (Y - Ppi) . (Code:1) SSEp 3.3 Calculate Cp = MSE(X1,XP-1) - - (n - 2p). (Code:1) 3.4 Structure the code of Questions 3.1, 3.2 and 3.3 so that it is a function that can be called. Name the function cp. The parameters of the function should be: y, the observed response variable, yhatl, the predicted values based on a full model using all P - 1 regressors, yhat2, the predicted values based on a smaller model with p - 1 regressors, and Allp, the number of parameters in the full model, P. . p, the number of parameters in the smaller model, p. The function should then return the following three values: MSEP: The value of MSE (X1, ..., Xp-1) SSEp: The value of SSEp. . Cp: The value of Cp