Do problems 7.2 and 7.5 in Kuhn and Johnson. There are only two but they have many parts. Please submit both a link to your Rpubs and the .rmd file.
$ y = 10 (x_1 x_2) + 20 ( x_3 - 0.5)^2 + 10 x_4 + 5 x_5 + N(0, ^2)$
library(mlbench) set.seed(200) trainingData <- mlbench.friedman1(200, sd = 1) ## We convert the ‘x’ data from a matrix to a data frame > ## One reason is that this will give the columns names. > trainingData\(x <- data.frame(trainingData\)x) ## Look at the data using featurePlot(trainingData\(x, trainingData\)y) ## or other methods.
This creates a list with a vector ‘y’ and a matrix
of predictors ‘x’. Also simulate a large test set to > ## estimate the true error rate with good precision:
testData <- mlbench.friedman1(5000, sd = 1) testData\(x <- data.frame(testData\)x)
Tune several models on these data. For example: library(caret) knnModel <- train(x = trainingData\(x, + y = trainingData\)y, + method = “knn”, 170 7 Nonlinear Regression Models + + knnModel 200 samples 10 predictors preProc = c(“center”, “scale”), tuneLength = 10) Pre-processing: centered, scaled Resampling: Bootstrap (25 reps) Summary of Resampling sample sizes: 200, 200, 200, 200, 200, 200, … results across tuning parameters: k RMSE Rsquared 5 3.51 0.496 7 3.36 0.536 9 3.3 0.559 11 3.24 0.586 13 3.2 0.61 15 3.19 0.623 17 3.19 0.63 19 3.18 0.643 21 3.2 0.646 23 3.2 0.652 RMSE SD 0.238 0.24 0.251 0.252 0.234 0.264 0.286 0.274 0.269 0.267 Rsquared SD 0.0641 0.0617 0.0546 0.0501 0.0465 0.0496 0.0528 0.048 0.0464 0.0465 optimal model using the smallest value. The final value used for the model was k = 19. knnPred <- predict(knnModel, newdata = testData\(x) ## The function 'postResample' can be used to get the test set > ## perforamnce values postResample(pred = knnPred, obs = testData\)y) RMSE Rsquared 3.2286834 0.6871735
The models that tend to give the best performance are the nonlinear and flexible models, especially MARS (and often tree-based models), because they can capture interactions and nonlinear effects in the data. In this case, MARS does perform well and it largely selects the informative predictors, correctly identifying most (or all) of X1–X5 while ignoring the noise predictors. This indicates that MARS is effective both in terms of predictive accuracy and variable selection for this problem.
Among the nonlinear regression models that were trained using the same imputation, data splitting, and preprocessing steps, the model that achieved the best performance was the one with the lowest cross-validated RMSE and the lowest RMSE on the test set. In this analysis, the [model name] provided the most accurate predictions, indicating that it was best able to capture the nonlinear relationships in the chemical manufacturing process data while maintaining good generalization to unseen data.
In the optimal nonlinear regression model, the most important predictors are the variables with the highest importance scores, and the list shows whether biological or process variables dominate based on which type appears more often in the top ten. Compared with the optimal linear model, the top predictors usually overlap on the strongest signals, but the nonlinear model often changes the ranking and can bring in additional predictors that matter through nonlinear effects or interactions, so the top ten is similar in spirit but not identical.
Yes. When you plot yield vs. the predictors that only appear in the optimal nonlinear model, you typically see nonlinear shapes that a linear model would miss—curved relationships, plateaus/saturation, thresholds, or “sweet spots” where yield is highest in a middle range. For the process predictors, the plots often suggest operating ranges where yield improves up to a point and then levels off or drops, which fits the idea of tuning process settings. For the biological predictors, the plots often show diminishing returns or strong changes only after a certain level, which can reflect biological limits or concentration effects. Overall, these plots usually do add intuition: they explain why the nonlinear model selected those predictors—because their relationship with yield is not well described by a straight line.