Use function polyfitstat to test the observations used to create a multivariate polynomial regression.
1. Define a matrix that contains samples taken from 20 healthy individuals between 25 and 34 years old.
The columns of the matrix represent the triceps skinfold thickness, the thigh circumference, and the body fat, respectively, for each of the 20 individuals.
2. Use functions rows and cols to calculate the number of rows and columns.
3. Use the augment function to define matrix BM as the first two columns of the matrix. Use these measurements to predict the amount of fat in individuals.
4. Call polyfitstat to model the experiment by a first-order regression and to calculate the regression statistics.
5. Display the regression coefficients matrix found in row 7 of output matrix P.
6. Calculate the regression coefficients using matrix calculation.
The coefficients of regression fit the following equation:
7. Use the regression equation to calculate the predicted amount of body fat. Compare these values to the amount of body fat measured.
8. Use the submatrix function to display model statistics found in the first rows of output matrix P.
The first statistic is the standard deviation for the regression.
9. Display the model diagnostics found in the last nested matrix of output matrix P.
The observed and the predicted values correspond to the values displayed in step 7. The residuals are the difference between the observed and the predicted values:
10. Calculate the residuals, or the difference between the observed and the predicted values.
11. Use function diag to calculate the leverage values, or the diagonal values, of matrix H.
12. Calculate the studentized residuals.
The externally studentized residuals, or R-student, are calculated below. Constant p is the number of coefficients calculated for the regression and S2 is an estimate of s2 based on a data set where the ith observation is removed.
13. Use Cook's distance to measure the overall influence of a deleted point on a linear regression.
14. Calculate the difference between predicted values when all the observations are included in the fit and predicted values when the ith observation is omitted
15. Use functions augment and stack to display the above statistics.
16. Use functions max and qt to determine the largest R-student value in the data set. Use the Bonferroni test to decide if the corresponding observation is an outlier.
The largest R-student value is smaller than the Bonferroni test which indicates that the corresponding observation is not an outlier.
17. Determine the maximum DFFITS value.
The value is larger than 1, but it is close enough to 1 that the corresponding observation is not necessarily influential.
18. Create an index influence plot by plotting the Cook's distances against the runs.
The observation for run2 is the most influential observation of the data set. The observation for run12 identified in step 10 is also influential but much less than that for run2.
Reference
Reference: Neter, J., Kutner, M.H., Nachtsheim, C.J., Wasserman, W., Applied Linear Statistical Models, 4th ed., McGraw-Hill/Irwin, Boston, 1996, pp. 375