6.2. Developing a model to predict permeability (see Sect. 1.4) could save significant resources for a pharmaceutical company, while at the same time more rapidly identifying molecules that have a sufficient permeability to become a drug:
(a) Start R and use these commands to load the data:
library(AppliedPredictiveModeling)
data(permeability)
The matrix fingerprints contains the 1,107 binary molecular predictors for the 165 compounds, while permeability contains permeability response.

  1. The fingerprint predictors indicate the presence or absence of substructures of a molecule and are often sparse meaning that relatively few of the molecules contain each substructure. Filter out the predictors that have low frequencies using the nearZeroVar function from the caret package. How many predictors are left for modeling?
    There were 1107 predictors.
## [1]  165 1107
## [1]  165 1107
  1. Split the data into a training and a test set, pre-process the data, and tune a PLS model. How many latent variables are optimal and what is the corresponding resampled estimate of R2?
    Optimal corresponding resampled estimate of R2 is 0.4718104 and there were 10 components with optimal tuning.
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570, X579,
## X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X691, X692, X693,
## X694, X695, X730, X731, X736, X737, X738, X739, X740, X741, X742, X743, X744,
## X745, X746, X747, X748, X749, X783, X785, X786, X787, X788, X789, X901, X902,
## X903, X904, X912, X913, X914, X915, X916, X917, X918, X919, X920, X921, X922,
## X923, X924, X925, X926, X927, X928, X929, X930, X931, X932, X933, X934, X935,
## X936, X937, X938, X939, X940, X941, X974, X975, X976, X977, X978, X979, X980,
## X981, X982, X983, X984, X985, X986, X987, X988, X989, X990, X991, X992, X993,
## X1002, X1003, X1004, X1005, X1006, X1007, X1008, X1009, X1010, X1013, X1015,
## X1081, X1082, X1083, X1084, X1085, X1086, X1087, X1088, X1089, X1090
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X475, X476, X477, X478,
## X479, X480, X481, X482, X483, X484, X485, X486, X487, X488, X489, X490, X491,
## X492, X493, X494, X495, X502, X528, X567, X569, X570, X579, X580, X581, X596,
## X606, X607, X608, X609, X610, X611, X612, X691, X692, X693, X694, X695, X730,
## X731, X736, X737, X738, X739, X740, X741, X742, X743, X744, X745, X746, X747,
## X748, X749, X783, X785, X786, X787, X788, X789, X912, X913, X914, X915, X916,
## X917, X918, X919, X920, X921, X922, X923, X924, X925, X926, X927, X928, X929,
## X930, X931, X932, X933, X934, X935, X936, X937, X938, X939, X940, X941, X974,
## X975, X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986, X987,
## X988, X989, X990, X991, X992, X993, X996, X1002, X1003, X1004, X1005, X1006,
## X1007, X1008, X1009, X1010, X1013, X1015, X1031, X1032, X1033
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut
## = 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24,
## X30, X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417,
## X418, X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430,
## X431, X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446,
## X448, X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464,
## X465, X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570,
## X579, X580, X581, X596, X605, X606, X607, X608, X609, X610, X611, X612, X623,
## X627, X628, X629, X630, X631, X632, X633, X634, X635, X636, X637, X638, X639,
## X640, X645, X647, X691, X692, X693, X694, X695, X725, X730, X731, X736, X737,
## X738, X739, X740, X741, X742, X743, X744, X745, X746, X747, X748, X749, X756,
## X757, X758, X759, X760, X761, X762, X783, X785, X786, X787, X788, X789, X912,
## X913, X914, X915, X916, X917, X918, X919, X920, X921, X922, X923, X924, X925,
## X926, X927, X928, X929, X930, X931, X932, X933, X934, X935, X936, X937, X938,
## X939, X940, X941, X974, X975, X976, X977, X978, X979, X980, X981, X982, X983,
## X984, X985, X986, X987, X988, X989, X990, X991, X992, X993, X1002, X1003, X1004,
## X1005, X1006, X1007, X1008, X1009, X1010, X1013, X1015, X1054, X1101, X1102,
## X1103
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570, X579,
## X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X691, X692, X693,
## X694, X695, X730, X731, X736, X737, X738, X739, X740, X741, X742, X743, X744,
## X745, X746, X747, X748, X749, X783, X785, X786, X787, X788, X789, X815, X816,
## X817, X818, X819, X820, X821, X822, X823, X824, X825, X826, X827, X828, X829,
## X830, X831, X832, X833, X883, X886, X887, X888, X889, X912, X913, X914, X915,
## X916, X917, X918, X919, X920, X921, X922, X923, X924, X925, X926, X927, X928,
## X929, X930, X931, X932, X933, X934, X935, X936, X937, X938, X939, X940, X941,
## X974, X975, X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986,
## X987, X988, X989, X990, X991, X992, X993, X1002, X1003, X1004, X1005, X1006,
## X1007, X1008, X1009, X1010, X1013, X1015, X1041, X1042, X1043, X1044, X1045,
## X1046, X1047, X1048, X1049
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570, X579,
## X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X691, X692, X693,
## X694, X695, X730, X731, X736, X737, X738, X739, X740, X741, X742, X743, X744,
## X745, X746, X747, X748, X749, X783, X785, X786, X787, X788, X789, X836, X837,
## X838, X839, X840, X841, X842, X844, X847, X848, X849, X850, X851, X852, X853,
## X854, X855, X856, X857, X858, X859, X860, X861, X862, X863, X864, X865, X866,
## X867, X868, X897, X898, X899, X900, X912, X913, X914, X915, X916, X917, X918,
## X919, X920, X921, X922, X923, X924, X925, X926, X927, X928, X929, X930, X931,
## X932, X933, X934, X935, X936, X937, X938, X939, X940, X941, X949, X974, X975,
## X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986, X987, X988,
## X989, X990, X991, X992, X993, X1002, X1003, X1004, X1005, X1006, X1007, X1008,
## X1009, X1010, X1013, X1015
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X110, X113, X114, X115, X123, X145, X147,
## X148, X151, X161, X164, X165, X166, X415, X416, X417, X418, X419, X420, X421,
## X422, X423, X424, X425, X426, X427, X428, X429, X430, X431, X432, X433, X434,
## X435, X436, X437, X438, X442, X443, X444, X445, X446, X448, X449, X450, X451,
## X452, X456, X458, X459, X460, X461, X462, X463, X464, X465, X466, X467, X468,
## X469, X470, X471, X472, X473, X474, X528, X569, X570, X579, X580, X581, X596,
## X606, X607, X608, X609, X610, X611, X612, X691, X692, X693, X694, X695, X730,
## X731, X736, X737, X738, X739, X740, X741, X742, X743, X744, X745, X746, X747,
## X748, X749, X783, X785, X786, X787, X788, X789, X912, X913, X914, X915, X916,
## X917, X918, X919, X920, X921, X922, X923, X924, X925, X926, X927, X928, X929,
## X930, X931, X932, X933, X934, X935, X936, X937, X938, X939, X940, X941, X974,
## X975, X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986, X987,
## X988, X989, X990, X991, X992, X993, X1002, X1003, X1004, X1005, X1006, X1007,
## X1008, X1009, X1010, X1013, X1015, X1034, X1035, X1036, X1037, X1038, X1039,
## X1040, X1091
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570, X579,
## X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X680, X682, X683,
## X684, X685, X686, X687, X688, X689, X690, X691, X692, X693, X694, X695, X730,
## X731, X736, X737, X738, X739, X740, X741, X742, X743, X744, X745, X746, X747,
## X748, X749, X783, X785, X786, X787, X788, X789, X912, X913, X914, X915, X916,
## X917, X918, X919, X920, X921, X922, X923, X924, X925, X926, X927, X928, X929,
## X930, X931, X932, X933, X934, X935, X936, X937, X938, X939, X940, X941, X974,
## X975, X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986, X987,
## X988, X989, X990, X991, X992, X993, X997, X1002, X1003, X1004, X1005, X1006,
## X1007, X1008, X1009, X1010, X1013, X1015, X1050, X1092, X1093, X1094, X1095,
## X1096, X1097, X1098, X1099, X1100, X1105, X1106, X1107
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X283, X287, X288, X415,
## X416, X417, X418, X419, X420, X421, X422, X423, X424, X425, X426, X427, X428,
## X429, X430, X431, X432, X433, X434, X435, X436, X437, X438, X442, X443, X444,
## X445, X446, X448, X449, X450, X451, X452, X456, X458, X459, X460, X461, X462,
## X463, X464, X465, X466, X467, X468, X469, X470, X471, X472, X473, X474, X513,
## X523, X525, X526, X527, X528, X569, X570, X579, X580, X581, X596, X606, X607,
## X608, X609, X610, X611, X612, X691, X692, X693, X694, X695, X730, X731, X736,
## X737, X738, X739, X740, X741, X742, X743, X744, X745, X746, X747, X748, X749,
## X777, X778, X783, X785, X786, X787, X788, X789, X912, X913, X914, X915, X916,
## X917, X918, X919, X920, X921, X922, X923, X924, X925, X926, X927, X928, X929,
## X930, X931, X932, X933, X934, X935, X936, X937, X938, X939, X940, X941, X974,
## X975, X976, X977, X978, X979, X980, X981, X982, X983, X984, X985, X986, X987,
## X988, X989, X990, X991, X992, X993, X1002, X1003, X1004, X1005, X1006, X1007,
## X1008, X1009, X1010, X1013, X1015, X1057, X1058, X1059, X1060, X1061
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417, X418,
## X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430, X431,
## X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446, X448,
## X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464, X465,
## X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570, X579,
## X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X650, X651, X652,
## X691, X692, X693, X694, X695, X730, X731, X736, X737, X738, X739, X740, X741,
## X742, X743, X744, X745, X746, X747, X748, X749, X769, X770, X771, X772, X783,
## X785, X786, X787, X788, X789, X912, X913, X914, X915, X916, X917, X918, X919,
## X920, X921, X922, X923, X924, X925, X926, X927, X928, X929, X930, X931, X932,
## X933, X934, X935, X936, X937, X938, X939, X940, X941, X974, X975, X976, X977,
## X978, X979, X980, X981, X982, X983, X984, X985, X986, X987, X988, X989, X990,
## X991, X992, X993, X1002, X1003, X1004, X1005, X1006, X1007, X1008, X1009, X1010,
## X1013, X1015, X1051, X1052, X1053, X1056
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut =
## 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24, X30,
## X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X273, X415, X416, X417,
## X418, X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430,
## X431, X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446,
## X448, X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464,
## X465, X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570,
## X579, X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X691, X692,
## X693, X694, X695, X730, X731, X736, X737, X738, X739, X740, X741, X742, X743,
## X744, X745, X746, X747, X748, X749, X783, X785, X786, X787, X788, X789, X908,
## X909, X910, X911, X912, X913, X914, X915, X916, X917, X918, X919, X920, X921,
## X922, X923, X924, X925, X926, X927, X928, X929, X930, X931, X932, X933, X934,
## X935, X936, X937, X938, X939, X940, X941, X947, X974, X975, X976, X977, X978,
## X979, X980, X981, X982, X983, X984, X985, X986, X987, X988, X989, X990, X991,
## X992, X993, X995, X1002, X1003, X1004, X1005, X1006, X1007, X1008, X1009, X1010,
## X1013, X1015
## Warning in preProcess.default(thresh = 0.95, k = 5, freqCut = 19, uniqueCut
## = 10, : These variables have zero variances: X7, X8, X18, X19, X22, X23, X24,
## X30, X31, X32, X81, X82, X89, X90, X92, X115, X145, X147, X415, X416, X417,
## X418, X419, X420, X421, X422, X423, X424, X425, X426, X427, X428, X429, X430,
## X431, X432, X433, X434, X435, X436, X437, X438, X442, X443, X444, X445, X446,
## X448, X449, X450, X451, X452, X456, X458, X459, X460, X461, X462, X463, X464,
## X465, X466, X467, X468, X469, X470, X471, X472, X473, X474, X528, X569, X570,
## X579, X580, X581, X596, X606, X607, X608, X609, X610, X611, X612, X691, X692,
## X693, X694, X695, X730, X731, X736, X737, X738, X739, X740, X741, X742, X743,
## X744, X745, X746, X747, X748, X749, X783, X785, X786, X787, X788, X789, X912,
## X913, X914, X915, X916, X917, X918, X919, X920, X921, X922, X923, X924, X925,
## X926, X927, X928, X929, X930, X931, X932, X933, X934, X935, X936, X937, X938,
## X939, X940, X941, X974, X975, X976, X977, X978, X979, X980, X981, X982, X983,
## X984, X985, X986, X987, X988, X989, X990, X991, X992, X993, X1002, X1003, X1004,
## X1005, X1006, X1007, X1008, X1009, X1010, X1013, X1015

## Partial Least Squares 
## 
##  133 samples
## 1107 predictors
## 
## Pre-processing: centered (1107), scaled (1107) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 118, 119, 120, 120, 121, 120, ... 
## Resampling results across tuning parameters:
## 
##   ncomp  RMSE      Rsquared   MAE      
##    1     13.00043  0.3483384  10.158961
##    2     12.18887  0.4703066   8.721064
##    3     12.49875  0.4393031   8.918540
##    4     12.76471  0.4242249   9.421740
##    5     12.52404  0.4322170   9.350952
##    6     12.10890  0.4605089   9.184670
##    7     12.23473  0.4625990   9.186727
##    8     12.37189  0.4515646   9.310798
##    9     12.06570  0.4698448   9.056395
##   10     12.18506  0.4718104   9.274797
##   11     12.36643  0.4678491   9.495268
##   12     12.42021  0.4664730   9.573359
##   13     12.39563  0.4682074   9.678799
##   14     12.38058  0.4656623   9.707065
##   15     12.48472  0.4629709   9.776938
##   16     12.60426  0.4574551   9.897138
##   17     12.45793  0.4648462   9.792717
##   18     12.59535  0.4571132   9.928574
##   19     12.73848  0.4502578  10.067646
##   20     12.86065  0.4460723  10.172813
## 
## Rsquared was used to select the optimal model using the largest value.
## The final value used for the model was ncomp = 10.
  1. Predict the response for the test set. What is the test set estimate of R2?
    R squared is: 0.5020753
##       RMSE   Rsquared        MAE 
## 11.4340826  0.5020753  8.7805579
  1. Try building other models discussed in this chapter. Do any have better predictive performance?
    The R squared here is too low, but I think that may be b/c of a code error. Ideally, GLM model should have better predictive performance here.

  2. Would you recommend any of your models to replace the permeability laboratory experiment?

I would anticipate the GLM model.

6.3. A chemical manufacturing process for a pharmaceutical product was discussed in Sect. 1.4. In this problem, the objective is to understand the relationship between biological measurements of the raw materials (predictors), measurements of the manufacturing process (predictors), and the response of product yield. Biological predictors cannot be changed but can be used to assess the quality of the raw material before processing. On the other hand, manufacturing process predictors can be changed in the manufacturing process. Improving product yield by 1 % will boost revenue by approximately one hundred thousand dollars per batch:

  1. Start R and use these commands to load the data:
    library(AppliedPredictiveModeling)
    data(chemicalManufacturing)
    The matrix processPredictors contains the 57 predictors (12 describing the input biological material and 45 describing the process predictors) for the 176 manufacturing runs. yield contains the percent yield for each run

  2. A small percentage of cells in the predictor set contain missing values. Use an imputation function to fill in these missing values (e.g., see Sect. 3.8).

## [1] 106
## [1] 0
  1. Split the data into a training and a test set, pre-process the data, and tune a model of your choice from this chapter. What is the optimal value of the performance metric?
    R squared value of 0.6085393, ncomp = 3.
## Partial Least Squares 
## 
## 176 samples
##  56 predictor
## 
## Pre-processing: centered (56), scaled (56) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 159, 158, 159, 158, 159, 158, ... 
## Resampling results across tuning parameters:
## 
##   ncomp  RMSE      Rsquared   MAE     
##    1     1.450590  0.4696359  1.154193
##    2     1.858675  0.4925041  1.181454
##    3     1.240098  0.6085393  0.992501
##    4     1.554534  0.5620507  1.077206
##    5     1.900907  0.5495897  1.168728
##    6     1.965715  0.5524720  1.174477
##    7     2.087397  0.5474242  1.212946
##    8     2.102091  0.5380572  1.230476
##    9     2.264644  0.5179190  1.295949
##   10     2.427544  0.5035974  1.344158
##   11     2.497611  0.4947891  1.365116
##   12     2.472319  0.4851540  1.367073
##   13     2.432840  0.4826618  1.362695
##   14     2.396271  0.4889996  1.355284
##   15     2.400860  0.4974873  1.349712
##   16     2.402193  0.5027265  1.342879
##   17     2.390370  0.5006932  1.337510
##   18     2.385688  0.4994290  1.334412
##   19     2.378250  0.4981096  1.334706
##   20     2.380911  0.4976755  1.338270
## 
## RMSE was used to select the optimal model using the smallest value.
## The final value used for the model was ncomp = 3.

Linear model: Multiple R-squared: 0.7809, Adjusted R-squared: 0.6805

## 
## Call:
## lm(formula = Yield ~ ., data = c)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.19507 -0.53187 -0.04114  0.48027  2.02270 
## 
## Coefficients: (1 not defined because of singularities)
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            -4.515e+00  8.758e+01  -0.052  0.95897    
## BiologicalMaterial01    2.765e-01  3.341e-01   0.828  0.40954    
## BiologicalMaterial02   -1.177e-01  1.290e-01  -0.912  0.36358    
## BiologicalMaterial03    1.594e-01  2.366e-01   0.674  0.50183    
## BiologicalMaterial04   -1.151e-01  5.309e-01  -0.217  0.82877    
## BiologicalMaterial05    1.602e-01  1.075e-01   1.490  0.13886    
## BiologicalMaterial06    9.673e-03  3.034e-01   0.032  0.97462    
## BiologicalMaterial08    4.358e-01  6.422e-01   0.679  0.49865    
## BiologicalMaterial09   -9.132e-01  1.373e+00  -0.665  0.50722    
## BiologicalMaterial10    8.624e-02  1.388e+00   0.062  0.95057    
## BiologicalMaterial11   -8.868e-02  8.270e-02  -1.072  0.28571    
## BiologicalMaterial12    3.471e-01  6.355e-01   0.546  0.58598    
## ManufacturingProcess01  7.700e-02  9.591e-02   0.803  0.42364    
## ManufacturingProcess02  1.571e-02  4.549e-02   0.345  0.73043    
## ManufacturingProcess03 -3.236e+00  5.155e+00  -0.628  0.53144    
## ManufacturingProcess04  6.437e-02  2.955e-02   2.178  0.03137 *  
## ManufacturingProcess05  7.812e-04  3.884e-03   0.201  0.84092    
## ManufacturingProcess06  3.737e-02  4.347e-02   0.860  0.39177    
## ManufacturingProcess07 -1.929e-01  2.138e-01  -0.903  0.36856    
## ManufacturingProcess08 -7.000e-02  2.535e-01  -0.276  0.78294    
## ManufacturingProcess09  2.789e-01  1.802e-01   1.548  0.12426    
## ManufacturingProcess10 -7.868e-02  5.679e-01  -0.139  0.89004    
## ManufacturingProcess11  2.800e-01  7.638e-01   0.367  0.71452    
## ManufacturingProcess12  3.429e-05  1.031e-04   0.333  0.74002    
## ManufacturingProcess13 -2.247e-01  3.841e-01  -0.585  0.55961    
## ManufacturingProcess14  6.611e-04  1.109e-02   0.060  0.95257    
## ManufacturingProcess15  1.723e-03  9.133e-03   0.189  0.85064    
## ManufacturingProcess16 -6.453e-05  3.207e-04  -0.201  0.84087    
## ManufacturingProcess17 -1.704e-01  3.035e-01  -0.562  0.57542    
## ManufacturingProcess18  4.458e-03  4.473e-03   0.997  0.32091    
## ManufacturingProcess19 -1.409e-03  7.848e-03  -0.180  0.85781    
## ManufacturingProcess20 -4.717e-03  4.734e-03  -0.996  0.32105    
## ManufacturingProcess21         NA         NA      NA       NA    
## ManufacturingProcess22 -1.742e-02  4.196e-02  -0.415  0.67879    
## ManufacturingProcess23 -3.611e-02  8.377e-02  -0.431  0.66719    
## ManufacturingProcess24 -1.910e-02  2.338e-02  -0.817  0.41558    
## ManufacturingProcess25 -2.228e-03  1.464e-02  -0.152  0.87928    
## ManufacturingProcess26  3.196e-03  1.086e-02   0.294  0.76906    
## ManufacturingProcess27 -7.566e-03  7.817e-03  -0.968  0.33505    
## ManufacturingProcess28 -7.619e-02  3.112e-02  -2.448  0.01582 *  
## ManufacturingProcess29  1.373e+00  9.214e-01   1.490  0.13879    
## ManufacturingProcess30 -3.581e-01  6.278e-01  -0.570  0.56944    
## ManufacturingProcess31  3.948e-02  1.211e-01   0.326  0.74507    
## ManufacturingProcess32  3.299e-01  6.988e-02   4.721 6.42e-06 ***
## ManufacturingProcess33 -3.909e-01  1.299e-01  -3.011  0.00318 ** 
## ManufacturingProcess34 -1.170e+00  2.793e+00  -0.419  0.67597    
## ManufacturingProcess35 -1.913e-02  1.787e-02  -1.070  0.28657    
## ManufacturingProcess36  3.133e+02  3.152e+02   0.994  0.32220    
## ManufacturingProcess37 -7.004e-01  2.906e-01  -2.410  0.01745 *  
## ManufacturingProcess38 -1.925e-01  2.426e-01  -0.793  0.42912    
## ManufacturingProcess39  7.363e-02  1.317e-01   0.559  0.57714    
## ManufacturingProcess40  7.456e-01  6.587e+00   0.113  0.91006    
## ManufacturingProcess41  1.107e-01  4.771e+00   0.023  0.98153    
## ManufacturingProcess42  6.015e-02  2.110e-01   0.285  0.77614    
## ManufacturingProcess43  2.252e-01  1.190e-01   1.892  0.06087 .  
## ManufacturingProcess44 -4.200e-01  1.195e+00  -0.352  0.72579    
## ManufacturingProcess45  9.689e-01  5.442e-01   1.780  0.07753 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.043 on 120 degrees of freedom
## Multiple R-squared:  0.7809, Adjusted R-squared:  0.6805 
## F-statistic: 7.776 on 55 and 120 DF,  p-value: < 2.2e-16
  1. Predict the response for the test set. What is the value of the performance metric and how does this compare with the resampled performance metric on the training set?
    R squared was substantially higher using lars: 0.7569945, than with the linear model and training set; so I chose the lars method.
##      RMSE  Rsquared       MAE 
## 1.1258653 0.7569945 0.8700906
  1. Which predictors are most important in the model you have trained? Do either the biological or process predictors dominate the list?
    Most important predictors are BiologicalMaterial06, ManufacturingProcess13, ManufacturingProcess36, and ManufacturingProcess17
## loess r-squared variable importance
## 
##   only 20 most important variables shown (out of 56)
## 
##                        Overall
## ManufacturingProcess32  100.00
## ManufacturingProcess13   90.02
## BiologicalMaterial06     84.56
## ManufacturingProcess36   76.25
## ManufacturingProcess17   74.88
## BiologicalMaterial03     73.53
## ManufacturingProcess09   70.37
## BiologicalMaterial12     67.97
## BiologicalMaterial02     65.32
## ManufacturingProcess31   59.96
## ManufacturingProcess06   57.48
## ManufacturingProcess33   49.84
## BiologicalMaterial11     48.11
## BiologicalMaterial04     47.12
## BiologicalMaterial08     41.87
## ManufacturingProcess11   41.76
## BiologicalMaterial01     39.13
## ManufacturingProcess12   33.02
## BiologicalMaterial09     32.41
## ManufacturingProcess27   23.74
  1. Explore the relationships between each of the top predictors and the response. How could this information be helpful in improving yield in future runs of the manufacturing process?
    We can see that there are several variables that negative correlation with Yield. We can also see the greatest positive correlation between Yield and ManufacturingProcess32. This information is helpful in future runs because we can use the variables to predict yield.