["Balance MSEP 150000 50000 02468 10 12 number of components # Comment: # We see that the smallest CV error occurs # when M = 11 components are used. This is # barely fewer than M = 12, which amounts # to simply performing least squares, because # when all of the components are used in PCR # no dimension reduction occurs. However, # from the plot we also see that the CV error # is roughly the same when only one component # is included in the model. This suggests # that a model that uses just a small # number of components might suffice. # Perform PCR on training data: set.seed(1) pcr.fit <- pcr( Balance ~., data = data, subset = train, scale = TRUE, validation = \\\"CV\\\" ) validationplot(pcr.fit, val.type = \\\"MSEP\\\") 201","Balance MSEP 150000 50000 0 2 4 6 8 10 12 number of components pcr.pred <- predict(pcr.fit,x[test,],ncomp = 10) mean((pcr.pred - y.test)^2) ## [1] 67014.07 # Fit PCR on full data set: pcr.fit <- pcr(y ~ x, scale = TRUE, ncomp = 7) summary(pcr.fit) ## Data: X dimension: 400 12 5 comps 6 comps 7 comps ## Y dimension: 400 1 64.23 72.34 80.36 ## Fit method: svdpc 61.39 62.34 67.36 ## Number of components considered: 7 ## TRAINING: % variance explained ## 1 comps 2 comps 3 comps 4 comps ## X 22.98 36.54 46.05 55.25 ## y 57.93 58.37 61.06 61.34 # Partial Least Squares: set.seed(1) pls.fit = plsr( Balance ~., data = data, subset = train, scale = TRUE,TRUEvalidation = \\\"CV\\\" ) summary(pls.fit) ## Data: X dimension: 200 12 202","## Y dimension: 200 1 ## Fit method: kernelpls ## Number of components considered: 12 ## TRAINING: % variance explained ## 1 comps 2 comps 3 comps 4 comps 5 comps 6 comps 7 comps 68.53 ## X 23.41 31.68 35.93 46.64 55.75 61.85 96.21 ## Balance 70.92 84.90 95.30 96.13 96.20 96.21 ## 8 comps 9 comps 10 comps 11 comps 12 comps ## X 77.28 80.13 85.75 93.52 100.00 ## Balance 96.21 96.25 96.26 96.26 96.26 validationplot(pls.fit, val.type = \\\"MSEP\\\") Balance MSEP 150000 0 50000 02468 10 12 number of components # Test set MSE: pls.pred <- predict(pls.fit, x[test,],ncomp = 2) mean((pls.pred - y.test)^2) ## [1] 34724.48 # Perform PLS using full data set: pls.fit <- plsr( Balance ~., data = data, scale = TRUE, ncomp = 2 ) summary(pls.fit) ## Data: X dimension: 400 12 ## Y dimension: 400 1 ## Fit method: kernelpls 203","## Number of components considered: 2 ## TRAINING: % variance explained ## 1 comps 2 comps ## X 22.54 29.96 ## Balance 69.67 86.42 204"]
Search
Read the Text Version
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204