主成分分析
https://stats.biopapyrus.jp/stats/pca/
https://data-science.gr.jp/implementation/ida_r_pca.html
library(car)
## Loading required package: carData
library(caret)
## Warning: package 'caret' was built under R version 3.6.2
## Loading required package: lattice
library(cluster)
library(dummies)
## dummies-1.5.6 provided by Decision Patterns
library(data.table)
## Warning: package 'data.table' was built under R version 3.6.2
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following object is masked from 'package:car':
##
## recode
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(e1071)
## Warning: package 'e1071' was built under R version 3.6.2
library(epitools)
library(effects)
## Warning: package 'effects' was built under R version 3.6.3
## Registered S3 methods overwritten by 'lme4':
## method from
## cooks.distance.influence.merMod car
## influence.merMod car
## dfbeta.influence.merMod car
## dfbetas.influence.merMod car
## Use the command
## lattice::trellis.par.set(effectsTheme())
## to customize lattice options for effects plots.
## See ?effectsTheme for details.
library(ggplot2)
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.6.2
library(randomForest)
## Warning: package 'randomForest' was built under R version 3.6.3
## randomForest 4.6-14
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
## The following object is masked from 'package:dplyr':
##
## combine
## The following object is masked from 'package:ggplot2':
##
## margin
library(ranger)
## Warning: package 'ranger' was built under R version 3.6.2
##
## Attaching package: 'ranger'
## The following object is masked from 'package:randomForest':
##
## importance
library(rgl)
library(rattle)
## Warning: package 'rattle' was built under R version 3.6.2
## Rattle: A free graphical interface for data science with R.
## バージョン 5.3.0 Copyright (c) 2006-2018 Togaware Pty Ltd.
## 'rattle()' と入力して、データを多角的に分析します。
##
## Attaching package: 'rattle'
## The following object is masked from 'package:ranger':
##
## importance
## The following object is masked from 'package:randomForest':
##
## importance
library(readr)
## Warning: package 'readr' was built under R version 3.6.2
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 3.6.2
## Loading required package: rpart
library(rpart)
library(readr)
library(reshape)
## Warning: package 'reshape' was built under R version 3.6.2
##
## Attaching package: 'reshape'
## The following object is masked from 'package:dplyr':
##
## rename
## The following object is masked from 'package:data.table':
##
## melt
library(rsconnect)
## Warning: package 'rsconnect' was built under R version 3.6.2
library(reshape2)
##
## Attaching package: 'reshape2'
## The following objects are masked from 'package:reshape':
##
## colsplit, melt, recast
## The following objects are masked from 'package:data.table':
##
## dcast, melt
library(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
##
## smiths
## The following objects are masked from 'package:reshape':
##
## expand, smiths
library(xtable)
library(nnet)
## Warning: package 'nnet' was built under R version 3.6.2
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(randomForest)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.6.2
## -- Attaching packages ------------------------------------------------------------------------------ tidyverse 1.3.0 --
## √ tibble 2.1.3 √ stringr 1.4.0
## √ purrr 0.3.3 √ forcats 0.4.0
## Warning: package 'stringr' was built under R version 3.6.2
## Warning: package 'forcats' was built under R version 3.6.2
## -- Conflicts --------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::between() masks data.table::between()
## x randomForest::combine() masks dplyr::combine()
## x tidyr::expand() masks reshape::expand()
## x dplyr::filter() masks stats::filter()
## x dplyr::first() masks data.table::first()
## x dplyr::lag() masks stats::lag()
## x dplyr::last() masks data.table::last()
## x purrr::lift() masks caret::lift()
## x randomForest::margin() masks ggplot2::margin()
## x dplyr::recode() masks car::recode()
## x reshape::rename() masks dplyr::rename()
## x purrr::some() masks car::some()
## x purrr::transpose() masks data.table::transpose()
library(nnet)
library(ggplot2)
library(MASS, lib.loc = "C:/Program Files/R/R-3.6.1/library")
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
library(MASS)
library(VGAM)
## Warning: package 'VGAM' was built under R version 3.6.3
## Loading required package: stats4
## Loading required package: splines
##
## Attaching package: 'VGAM'
## The following object is masked from 'package:tidyr':
##
## fill
## The following object is masked from 'package:rattle':
##
## wine
## The following object is masked from 'package:caret':
##
## predictors
## The following object is masked from 'package:car':
##
## logit
library(maptools)
## Warning: package 'maptools' was built under R version 3.6.2
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.6.2
## Checking rgeos availability: FALSE
## Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib,
## which has a restricted licence. It is disabled by default;
## to enable gpclib, type gpclibPermit()
##
## Attaching package: 'maptools'
## The following object is masked from 'package:xtable':
##
## label
gesui = read_csv("enbi.csv")
## Parsed with column specification:
## cols(
## OBJECTID = col_double(),
## sys_name = col_double(),
## slope = col_double(),
## uedokaburi = col_double(),
## masuhonsuu = col_double(),
## long = col_double(),
## kubun = col_double(),
## did = col_double(),
## kouhou = col_double(),
## nendo = col_double(),
## ekijyouka = col_double(),
## kyouyounensuu = col_double(),
## kansyu = col_double(),
## kei = col_double(),
## kinkyuudo = col_double(),
## taisyo = col_double()
## )
gesui <- data.frame(gesui) # 教科書ではlogit
gesui <- gesui[-1:-2] #OBJECTID,sys_name列をデータから削除
gesui <- gesui[-13]
gesui <- gesui[-8]
gesui <- gesui[-10]
sapply(gesui, class)
## slope uedokaburi masuhonsuu long kubun
## "numeric" "numeric" "numeric" "numeric" "numeric"
## did kouhou ekijyouka kyouyounensuu kei
## "numeric" "numeric" "numeric" "numeric" "numeric"
## taisyo
## "numeric"
summary(gesui)
## slope uedokaburi masuhonsuu long
## Min. :0.000 Min. : 1.009 Min. : 0.000 Min. : 0.97
## 1st Qu.:1.900 1st Qu.: 2.462 1st Qu.: 0.000 1st Qu.:21.32
## Median :2.685 Median : 3.402 Median : 1.000 Median :30.06
## Mean :3.309 Mean : 4.218 Mean : 1.284 Mean :31.30
## 3rd Qu.:4.100 3rd Qu.: 5.397 3rd Qu.: 2.000 3rd Qu.:40.49
## Max. :9.900 Max. :13.385 Max. :11.000 Max. :96.82
## kubun did kouhou ekijyouka
## Min. :1.000 Min. :0.000 Min. :0.0000 Min. :0.0000
## 1st Qu.:1.000 1st Qu.:1.000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :1.000 Median :1.000 Median :0.0000 Median :0.0000
## Mean :1.209 Mean :0.766 Mean :0.3369 Mean :0.2021
## 3rd Qu.:1.000 3rd Qu.:1.000 3rd Qu.:1.0000 3rd Qu.:0.0000
## Max. :2.000 Max. :1.000 Max. :1.0000 Max. :1.0000
## kyouyounensuu kei taisyo
## Min. :10.00 Min. :200.0 Min. :0.0000
## 1st Qu.:25.00 1st Qu.:250.0 1st Qu.:0.0000
## Median :25.00 Median :250.0 Median :0.0000
## Mean :27.51 Mean :390.2 Mean :0.3121
## 3rd Qu.:27.00 3rd Qu.:600.0 3rd Qu.:1.0000
## Max. :40.00 Max. :900.0 Max. :1.0000
train <- gesui[1:200,]
test <- gesui[201:284,]
stargazer(as.data.frame(gesui),type = "html")
Statistic | N | Mean | St. Dev. | Min | Pctl(25) | Pctl(75) | Max |
slope | 282 | 3.309 | 2.017 | 0.000 | 1.900 | 4.100 | 9.900 |
uedokaburi | 282 | 4.218 | 2.570 | 1.009 | 2.462 | 5.397 | 13.385 |
masuhonsuu | 282 | 1.284 | 1.765 | 0 | 0 | 2 | 11 |
long | 282 | 31.300 | 15.309 | 0.970 | 21.325 | 40.492 | 96.820 |
kubun | 282 | 1.209 | 0.407 | 1 | 1 | 1 | 2 |
did | 282 | 0.766 | 0.424 | 0 | 1 | 1 | 1 |
kouhou | 282 | 0.337 | 0.473 | 0 | 0 | 1 | 1 |
ekijyouka | 282 | 0.202 | 0.402 | 0 | 0 | 0 | 1 |
kyouyounensuu | 282 | 27.514 | 5.204 | 10 | 25 | 27 | 40 |
kei | 282 | 390.248 | 162.287 | 200 | 250 | 600 | 900 |
taisyo | 282 | 0.312 | 0.464 | 0 | 0 | 1 | 1 |
p <- gesui[, 1:11]
p = prcomp(p,scale=T)
biplot(p)
names(p)
## [1] "sdev" "rotation" "center" "scale" "x"
head(p$x)
## PC1 PC2 PC3 PC4 PC5 PC6
## [1,] 1.960450 -3.2538385 1.25672320 1.11169748 -0.8878810 -0.29564148
## [2,] 2.373785 0.4462211 -0.22091070 1.41079958 0.3757950 0.07642351
## [3,] 2.344151 -2.5545670 0.12761088 1.18826691 0.7769509 -0.70570562
## [4,] 2.314187 -2.3646064 -0.06605524 0.54216676 -1.4410115 0.19143922
## [5,] 1.188562 -1.5669850 -1.48961539 0.88516841 0.4390677 0.92392702
## [6,] 2.345249 -2.6507858 0.04553914 -0.03347243 2.1719620 -1.71439586
## PC7 PC8 PC9 PC10 PC11
## [1,] -1.83129878 -1.17026549 1.4446072 0.10785612 -0.46657870
## [2,] -0.25880726 -1.58152480 0.9192206 0.68096255 -0.16243490
## [3,] -0.45375899 -0.03808309 0.7138217 0.21063539 -0.04502874
## [4,] -0.43204429 0.01976629 1.1005621 0.15081153 -0.12524461
## [5,] -1.10168122 -0.80722080 2.3602793 0.02694101 -1.19557888
## [6,] -0.04947104 0.08809693 0.3562377 0.09266457 0.12152994
princomp変数による解析
p <- princomp(gesui, cor = TRUE)
names(p)
## [1] "sdev" "loadings" "center" "scale" "n.obs" "scores" "call"
head(p$scores)
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## [1,] 1.963935 3.2596231 1.25895737 -1.11367383 -0.8894594 0.29616706
## [2,] 2.378005 -0.4470144 -0.22130343 -1.41330767 0.3764631 -0.07655937
## [3,] 2.348319 2.5591085 0.12783774 -1.19037938 0.7783322 0.70696021
## [4,] 2.318301 2.3688102 -0.06617267 -0.54313061 -1.4435733 -0.19177955
## [5,] 1.190675 1.5697707 -1.49226360 -0.88674204 0.4398483 -0.92556956
## [6,] 2.349419 2.6554983 0.04562009 0.03353194 2.1758233 1.71744367
## Comp.7 Comp.8 Comp.9 Comp.10 Comp.11
## [1,] -1.83455442 -1.17234597 -1.4471754 0.10804786 -0.4674082
## [2,] -0.25926737 -1.58433640 -0.9208547 0.68217315 -0.1627237
## [3,] -0.45456567 -0.03815080 -0.7150907 0.21100985 -0.0451088
## [4,] -0.43281237 0.01980143 -1.1025186 0.15107963 -0.1254673
## [5,] -1.10363976 -0.80865586 -2.3644754 0.02698891 -1.1977044
## [6,] -0.04955898 0.08825355 -0.3568711 0.09282930 0.1217460
標準偏差
head(p$sdev)
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## 1.7958143 1.1417211 1.1171777 1.0487125 0.9829994 0.9784615
固有ベクトル
head(p$loadings)
## [1] 0.1199789 -0.3794388 0.2098338 -0.2865882 0.3410772 0.2963940
特徴量平均値
head(p$center)
## slope uedokaburi masuhonsuu long kubun did
## 3.3089007 4.2180089 1.2836879 31.2998227 1.2092199 0.7659574
正規化パラメーター
head(p$scale)
## slope uedokaburi masuhonsuu long kubun did
## 2.0131238 2.5653834 1.7617941 15.2818480 0.4067517 0.4233989
主成分スコア
head(p$scores)
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
## [1,] 1.963935 3.2596231 1.25895737 -1.11367383 -0.8894594 0.29616706
## [2,] 2.378005 -0.4470144 -0.22130343 -1.41330767 0.3764631 -0.07655937
## [3,] 2.348319 2.5591085 0.12783774 -1.19037938 0.7783322 0.70696021
## [4,] 2.318301 2.3688102 -0.06617267 -0.54313061 -1.4435733 -0.19177955
## [5,] 1.190675 1.5697707 -1.49226360 -0.88674204 0.4398483 -0.92556956
## [6,] 2.349419 2.6554983 0.04562009 0.03353194 2.1758233 1.71744367
## Comp.7 Comp.8 Comp.9 Comp.10 Comp.11
## [1,] -1.83455442 -1.17234597 -1.4471754 0.10804786 -0.4674082
## [2,] -0.25926737 -1.58433640 -0.9208547 0.68217315 -0.1627237
## [3,] -0.45456567 -0.03815080 -0.7150907 0.21100985 -0.0451088
## [4,] -0.43281237 0.01980143 -1.1025186 0.15107963 -0.1254673
## [5,] -1.10363976 -0.80865586 -2.3644754 0.02698891 -1.1977044
## [6,] -0.04955898 0.08825355 -0.3568711 0.09282930 0.1217460
関数実行コマンドログ
head(p$call)
## princomp(x = gesui, cor = TRUE)
#主成分回帰分析 https://toukeier.hatenablog.com/entry/2018/09/25/221232
#多重共線性の確認
library(ISLR)
## Warning: package 'ISLR' was built under R version 3.6.3
library(pls)
## Warning: package 'pls' was built under R version 3.6.3
##
## Attaching package: 'pls'
## The following object is masked from 'package:caret':
##
## R2
## The following object is masked from 'package:stats':
##
## loadings
round(1/(1-cor(gesui[-1,-4])^2))
## slope uedokaburi masuhonsuu kubun did kouhou ekijyouka
## slope Inf 1 1 1 1 1 1
## uedokaburi 1 Inf 1 1 1 2 1
## masuhonsuu 1 1 Inf 1 1 1 1
## kubun 1 1 1 Inf 1 1 1
## did 1 1 1 1 Inf 1 1
## kouhou 1 2 1 1 1 Inf 1
## ekijyouka 1 1 1 1 1 1 Inf
## kyouyounensuu 1 1 1 1 1 1 1
## kei 1 1 1 1 1 2 1
## taisyo 1 1 1 1 1 1 1
## kyouyounensuu kei taisyo
## slope 1 1 1
## uedokaburi 1 1 1
## masuhonsuu 1 1 1
## kubun 1 1 1
## did 1 1 1
## kouhou 1 2 1
## ekijyouka 1 1 1
## kyouyounensuu Inf 1 1
## kei 1 Inf 1
## taisyo 1 1 Inf
set.seed(20180924)
sub <- sample(1:282, round(282*4/5))
sub
## [1] 223 15 180 214 57 192 63 132 149 215 267 245 168 30 47 32 97 225
## [19] 130 178 22 92 176 107 79 139 212 18 241 200 64 20 183 16 99 34
## [37] 156 113 125 274 169 144 106 211 166 161 82 184 242 114 69 121 19 185
## [55] 278 1 252 170 164 126 240 153 205 46 150 210 115 135 108 181 254 21
## [73] 231 155 187 91 197 40 140 162 86 190 206 202 237 85 41 186 148 272
## [91] 71 110 281 261 61 276 136 262 188 93 266 165 228 56 233 250 255 26
## [109] 173 277 44 201 247 217 249 204 172 251 29 14 159 65 3 163 53 112
## [127] 67 49 220 208 128 9 157 6 101 58 244 138 119 131 105 39 117 52
## [145] 189 265 37 207 68 263 66 103 258 23 84 142 62 280 43 243 28 4
## [163] 268 54 88 174 198 279 143 175 78 182 74 118 83 222 196 218 273 264
## [181] 271 100 160 224 253 2 221 145 151 124 77 256 96 11 232 73 50 171
## [199] 33 90 35 116 75 236 38 70 104 55 282 167 227 102 10 270 146 179
## [217] 158 234 111 72 89 248 239 120 13 24
data=gesui[sub,]
data
## slope uedokaburi masuhonsuu long kubun did kouhou ekijyouka kyouyounensuu
## 223 1.340 3.484858 4 20.20 1 1 0 0 25
## 15 1.740 1.436539 3 9.25 2 1 0 1 39
## 180 2.130 2.660371 2 29.31 1 1 0 0 40
## 214 2.320 4.574894 1 30.18 2 1 0 0 40
## 57 3.900 2.796943 2 30.01 2 1 0 1 37
## 192 2.300 2.346045 2 29.68 1 1 0 0 40
## 63 4.100 1.694001 1 31.01 2 1 0 0 37
## 132 1.100 10.907328 0 22.06 1 1 1 0 25
## 149 3.200 3.916999 0 40.78 1 0 1 0 25
## 215 5.600 2.498483 5 26.90 1 1 0 0 25
## 267 2.450 2.518753 2 26.93 1 1 0 0 25
## 245 1.010 3.850776 1 24.86 1 1 0 1 24
## 168 3.300 10.594034 0 30.59 1 1 1 0 25
## 30 5.000 6.649337 0 14.13 1 1 1 0 26
## 47 1.610 9.463612 1 15.54 1 1 0 0 25
## 32 1.580 4.386176 0 5.96 1 1 0 0 17
## 97 3.600 5.855999 1 55.42 1 0 0 0 27
## 225 1.990 2.754591 3 34.95 2 1 0 0 25
## 130 1.000 6.382495 0 31.11 1 1 1 1 26
## 178 2.100 5.403999 0 54.79 1 0 1 0 25
## 22 1.500 3.253370 0 13.00 1 0 0 0 25
## 92 1.400 6.330505 0 19.13 1 1 1 0 27
## 176 3.000 6.259277 0 58.39 1 0 1 0 25
## 107 3.300 4.910003 2 65.07 1 1 1 0 27
## 79 1.820 1.366309 0 23.59 2 1 0 1 24
## 139 2.100 4.224999 0 50.09 1 0 1 0 25
## 212 2.120 2.557118 5 32.00 1 1 0 0 40
## 18 2.200 6.027199 0 10.12 1 0 1 0 24
## 241 3.300 2.621705 3 33.74 1 1 0 0 25
## 200 3.400 5.916304 0 63.02 1 1 1 1 26
## 64 2.500 1.617001 3 24.86 2 1 0 0 37
## 20 5.000 3.847243 1 15.15 1 0 0 0 25
## 183 2.040 2.161000 0 29.91 1 1 0 0 40
## 16 4.270 1.472376 0 7.86 2 1 0 1 39
## 99 2.100 3.525528 1 63.57 1 0 0 0 27
## 34 6.500 4.590000 0 9.95 1 0 1 0 34
## 156 1.800 3.661790 2 28.05 1 0 1 1 28
## 113 4.900 3.828565 11 51.83 2 1 0 0 24
## 125 2.100 10.516000 0 42.60 1 1 1 0 25
## 274 2.670 2.685897 0 27.49 1 1 0 0 25
## 169 4.600 10.591164 1 26.39 1 0 1 0 25
## 144 4.100 3.810922 0 48.17 1 0 1 0 25
## 106 1.900 3.748734 0 42.66 2 0 0 0 27
## 211 1.480 1.864272 0 20.00 1 1 0 0 40
## 166 6.900 2.981946 0 34.58 1 1 0 0 26
## 161 2.800 2.990898 0 54.94 1 0 0 0 10
## 82 4.500 6.974002 0 96.82 1 1 1 1 27
## 184 2.030 2.351002 0 30.00 1 1 0 0 26
## 242 6.800 4.806221 0 29.86 1 1 0 0 25
## 114 3.500 3.400039 10 52.24 2 1 0 0 24
## 69 5.500 1.486400 3 26.99 2 1 0 1 37
## 121 1.700 12.168823 0 30.58 1 1 1 0 25
## 19 5.000 6.957029 1 15.65 1 0 1 0 25
## 185 1.730 1.838435 1 27.80 1 1 0 0 26
## 278 3.710 2.891690 3 27.74 1 1 0 0 25
## 1 1.220 1.054575 1 3.39 2 1 0 1 12
## 252 3.190 9.491322 4 19.56 1 1 0 0 24
## 170 3.200 8.921724 1 52.98 1 1 1 0 25
## 164 4.100 3.150200 1 50.89 1 0 0 0 26
## 126 2.500 9.882314 0 41.64 1 1 1 0 25
## 240 1.250 2.002232 6 26.20 1 1 0 0 25
## 153 2.100 4.563110 0 38.55 1 0 1 0 25
## 205 4.060 1.982026 4 25.49 1 1 0 0 26
## 46 7.720 9.556511 5 11.01 1 1 0 0 25
## 150 2.700 3.925999 0 41.25 1 0 1 0 25
## 210 9.700 2.816253 3 31.90 1 1 0 0 25
## 115 4.120 4.084854 7 51.90 2 1 1 0 24
## 135 1.000 4.740499 0 24.86 1 1 1 1 26
## 108 9.600 2.481001 3 39.08 2 1 0 0 26
## 181 2.300 1.660551 1 19.08 1 1 0 0 40
## 254 2.590 9.356372 0 19.97 1 0 0 0 25
## 21 1.500 2.211840 0 14.47 1 0 0 0 25
## 231 5.400 10.806235 0 40.03 1 0 1 0 34
## 155 2.400 4.211381 4 59.97 1 0 1 1 28
## 187 1.880 2.855000 2 30.04 1 1 0 1 26
## 91 1.000 6.574005 1 22.79 1 1 1 0 27
## 197 2.420 4.470321 1 29.94 2 1 0 0 40
## 40 4.100 2.749357 0 10.02 1 1 0 0 25
## 140 1.900 4.243001 0 50.01 1 0 1 0 25
## 162 3.200 2.937999 0 36.44 1 0 0 0 26
## 86 1.400 7.042785 1 40.03 1 1 1 1 27
## 190 9.200 2.236709 3 33.61 1 1 0 0 26
## 206 3.230 1.742547 3 30.95 1 1 0 0 26
## 202 4.020 2.240832 2 31.20 1 1 0 0 26
## 237 4.210 2.289566 1 23.22 2 1 0 0 25
## 85 1.100 4.548029 0 42.85 1 0 1 0 27
## 41 1.760 2.432278 0 7.87 1 1 0 0 25
## 186 1.820 2.143259 2 29.91 1 1 0 1 26
## 148 4.200 4.861001 0 40.29 1 0 1 0 25
## 272 1.960 2.694672 3 27.25 1 1 0 0 25
## 71 1.060 2.725467 1 29.09 2 1 0 0 26
## 110 3.500 3.403083 4 37.96 2 1 0 0 21
## 281 4.400 4.937003 0 39.80 1 1 1 0 25
## 261 3.210 3.068203 6 46.50 1 1 0 0 25
## 61 2.400 1.956000 2 25.15 2 1 0 1 37
## 276 4.800 4.976580 0 55.17 1 1 1 0 25
## 136 1.100 6.537330 0 47.24 1 1 1 1 26
## 262 4.300 6.827301 0 51.84 1 1 1 0 25
## 188 1.790 2.212618 2 30.12 1 1 0 1 26
## 93 5.000 3.920159 1 32.19 1 1 0 1 27
## 266 2.280 2.663494 2 27.46 1 1 0 0 25
## 165 3.100 3.199907 0 44.39 1 0 0 0 26
## 228 2.590 2.475453 0 32.61 1 1 0 0 40
## 56 5.700 3.024835 3 36.10 2 1 0 1 40
## 233 2.060 4.124568 0 77.03 1 1 1 0 25
## 250 1.710 9.652271 2 18.98 1 1 0 0 25
## 255 2.600 9.327517 1 28.02 1 0 0 0 25
## 26 1.690 1.824348 0 10.00 1 1 0 0 26
## 173 3.000 5.177794 1 18.24 1 0 0 0 25
## 277 3.670 2.667007 0 27.45 1 1 0 0 25
## 44 2.440 3.414251 0 14.07 2 1 0 0 24
## 201 3.900 2.064381 2 29.98 1 1 0 0 26
## 247 4.100 6.122001 0 46.81 1 1 1 1 25
## 217 8.000 2.589767 3 19.90 1 1 0 0 25
## 249 3.130 9.776862 2 19.94 1 1 0 0 25
## 204 4.070 1.891763 1 24.00 1 1 0 0 26
## 172 3.300 5.519844 1 21.85 1 0 1 0 25
## 251 1.630 9.552125 2 29.99 1 1 0 0 25
## 29 1.895 3.646695 0 2.71 1 1 0 0 27
## 14 1.300 6.858791 0 2.79 1 1 1 0 25
## 159 2.900 2.635552 1 48.85 1 0 0 0 26
## 65 3.600 1.572562 1 24.52 2 1 0 0 37
## 3 4.710 1.414000 0 5.02 2 1 0 1 24
## 163 3.800 2.868704 1 37.59 1 0 0 0 26
## 53 3.580 2.603039 1 16.04 1 1 0 0 25
## 112 2.500 3.922952 3 40.56 1 1 1 0 32
## 67 4.300 1.739730 0 24.93 2 1 0 0 37
## 49 2.730 2.860160 1 7.52 1 1 0 0 25
## 220 1.600 2.942733 3 31.80 1 1 0 0 25
## 208 4.010 1.798224 2 29.92 1 1 0 0 26
## 128 3.300 7.612320 0 38.28 1 1 1 0 26
## 9 1.300 1.819819 1 9.12 1 0 0 0 27
## 157 6.100 3.115186 0 43.01 1 0 0 0 26
## 6 8.900 1.738222 0 15.72 2 1 0 1 24
## 101 5.500 3.339510 0 36.44 1 0 0 0 27
## 58 4.400 2.611828 3 26.75 2 1 0 1 37
## 244 1.030 5.408001 0 41.07 1 1 1 1 24
## 138 1.800 4.652454 0 50.20 1 0 1 0 25
## 119 2.300 10.198399 3 45.18 1 1 1 0 25
## 131 8.700 1.926552 4 31.86 2 1 0 1 26
## 105 9.500 1.942961 0 39.40 1 1 0 0 27
## 39 3.900 2.736001 1 12.99 1 1 0 0 25
## 117 2.400 7.072001 2 51.09 1 1 1 0 25
## 52 3.280 3.394147 1 15.78 1 1 0 0 25
## 189 2.630 1.843763 2 27.15 1 1 0 0 40
## 265 2.280 2.499810 2 27.46 1 1 0 0 25
## 37 8.700 2.607048 1 8.70 1 1 0 0 25
## 207 3.830 1.909999 2 28.60 1 1 0 0 27
## 68 4.900 1.586905 2 24.91 2 1 0 0 37
## 263 5.400 5.521916 0 54.91 1 1 1 0 25
## 66 6.200 1.243001 4 46.92 2 1 0 1 28
## 103 2.600 5.532493 0 31.99 1 0 1 0 27
## 258 2.960 3.700743 3 26.81 1 1 0 0 25
## 23 1.400 3.677926 1 13.85 1 0 0 0 25
## 84 1.200 4.675212 0 45.45 1 0 1 0 27
## 142 3.400 4.247999 0 52.10 1 0 1 0 25
## 62 4.500 1.664466 1 26.14 2 1 0 0 37
## 280 3.710 1.889743 4 31.13 1 1 0 0 25
## 43 3.380 3.460195 1 12.04 2 1 0 0 25
## 243 5.300 5.008060 0 21.81 1 1 0 0 25
## 28 1.720 2.119883 0 17.00 1 1 0 0 40
## 4 1.100 1.544714 3 13.17 2 1 0 1 24
## 268 2.900 7.568516 0 54.50 1 1 1 0 25
## 54 1.630 2.476748 4 45.65 1 1 0 0 25
## 88 3.000 6.631325 0 45.98 1 1 1 1 27
## 174 3.400 2.611999 2 25.26 1 0 0 0 25
## 198 2.370 3.777865 0 29.87 2 1 0 0 40
## 279 2.380 4.197623 5 40.25 1 1 0 0 25
## 143 2.300 4.438878 0 46.81 1 0 1 0 25
## 175 4.000 3.250242 0 17.93 1 0 0 0 25
## 78 2.120 1.008538 2 30.99 2 1 0 1 24
## 182 2.140 1.856014 1 29.30 1 1 0 0 40
## 74 4.600 2.853477 0 39.85 2 1 0 1 26
## 118 7.000 7.090262 0 31.00 1 1 1 0 25
## 83 3.000 5.669425 9 40.00 1 1 1 0 33
## 222 7.800 7.650076 1 21.90 1 1 0 0 25
## 196 2.940 2.054423 2 28.86 1 1 0 0 40
## 218 9.900 2.596578 4 32.30 1 1 0 0 25
## 273 4.700 6.140733 1 54.96 1 1 1 0 25
## 264 1.990 2.896992 2 27.42 1 1 0 0 25
## 271 3.350 2.644891 2 36.92 1 1 0 0 25
## 100 4.700 3.494682 1 33.71 1 0 0 0 27
## 160 1.100 2.491678 1 54.95 1 0 0 0 26
## 224 2.500 3.318911 4 40.96 1 1 0 0 25
## 253 1.660 9.424565 4 31.98 1 1 0 0 25
## 2 2.500 1.533001 0 7.78 2 1 0 0 28
## 221 1.400 7.191373 1 32.10 1 1 0 0 25
## 145 2.800 5.456998 0 21.43 1 0 1 0 25
## 151 1.400 4.105612 0 37.92 1 0 1 0 25
## 124 2.400 11.925139 0 34.16 1 1 1 0 25
## 77 1.220 1.225071 0 25.56 2 1 0 1 24
## 256 3.990 1.993982 1 28.02 1 0 0 0 25
## 96 3.300 3.213998 1 29.89 1 1 0 0 27
## 11 1.300 3.583047 0 10.86 2 1 0 0 40
## 232 5.200 11.221190 0 44.00 1 0 1 0 34
## 73 4.500 2.714951 0 39.87 2 1 0 1 26
## 50 4.190 2.680456 0 3.50 1 1 0 0 25
## 171 2.100 8.576775 0 52.11 1 1 1 0 25
## 33 1.428 2.864370 0 7.68 1 1 0 0 25
## 90 3.700 6.981265 0 26.86 1 1 1 0 27
## 35 3.030 6.923674 0 9.21 1 0 1 0 34
## 116 2.700 7.091002 1 41.88 1 1 1 0 25
## 75 1.200 1.428993 0 27.22 2 1 0 1 24
## 236 3.690 4.178999 2 24.00 1 1 0 0 25
## 38 3.620 3.316654 0 11.03 1 1 0 0 25
## 70 6.300 1.578893 1 20.45 2 1 0 1 37
## 104 2.560 5.077001 0 61.47 1 0 1 0 27
## 55 1.787 2.453790 0 6.24 1 1 0 0 25
## 282 4.500 5.842998 0 39.55 1 1 1 0 25
## 167 2.600 8.277668 0 28.97 1 1 1 0 25
## 227 6.250 2.031941 3 19.73 2 1 0 0 25
## 102 2.300 5.376960 0 39.12 1 0 1 0 27
## 10 1.240 3.505754 0 9.42 2 1 0 0 40
## 270 1.940 2.559030 1 28.36 1 0 0 0 25
## 146 2.600 5.497247 0 49.16 1 0 1 0 25
## 179 7.070 3.457646 1 30.09 1 1 0 1 27
## 158 4.200 2.784306 0 42.89 1 0 0 0 26
## 234 2.010 2.395267 1 38.81 1 1 0 0 25
## 111 2.400 3.824999 0 38.06 2 1 0 0 21
## 72 6.700 2.457513 0 28.08 2 1 0 1 26
## 89 1.900 6.749645 0 50.18 1 1 1 1 27
## 248 2.000 6.358178 0 49.37 1 1 1 1 24
## 239 8.000 2.291207 0 19.86 1 1 0 0 25
## 120 1.600 11.327685 1 52.05 1 1 1 0 25
## 13 3.200 3.852999 1 9.97 1 1 1 0 32
## 24 7.000 3.632331 0 9.98 1 1 0 1 27
## kei taisyo
## 223 250 0
## 15 250 0
## 180 250 1
## 214 250 1
## 57 250 1
## 192 250 1
## 63 250 1
## 132 600 0
## 149 600 0
## 215 250 1
## 267 250 0
## 245 300 0
## 168 600 0
## 30 400 0
## 47 250 0
## 32 400 0
## 97 600 1
## 225 250 0
## 130 600 0
## 178 600 0
## 22 600 0
## 92 600 1
## 176 600 1
## 107 350 0
## 79 250 0
## 139 600 0
## 212 250 1
## 18 600 0
## 241 250 1
## 200 600 1
## 64 250 1
## 20 600 0
## 183 250 1
## 16 250 0
## 99 600 0
## 34 300 0
## 156 500 0
## 113 250 0
## 125 600 0
## 274 250 0
## 169 600 1
## 144 600 1
## 106 300 0
## 211 250 1
## 166 600 0
## 161 600 0
## 82 400 0
## 184 250 1
## 242 250 0
## 114 250 0
## 69 250 0
## 121 600 1
## 19 600 1
## 185 250 1
## 278 250 0
## 1 200 0
## 252 250 0
## 170 600 0
## 164 600 0
## 126 600 0
## 240 250 0
## 153 600 0
## 205 250 1
## 46 250 0
## 150 600 0
## 210 250 1
## 115 250 0
## 135 600 0
## 108 250 0
## 181 250 1
## 254 250 0
## 21 600 0
## 231 350 0
## 155 500 1
## 187 250 1
## 91 600 0
## 197 250 1
## 40 250 0
## 140 600 0
## 162 600 0
## 86 600 0
## 190 250 1
## 206 250 1
## 202 250 1
## 237 250 0
## 85 600 1
## 41 250 0
## 186 250 0
## 148 600 0
## 272 250 0
## 71 250 0
## 110 250 0
## 281 450 0
## 261 450 0
## 61 250 1
## 276 450 0
## 136 600 0
## 262 450 0
## 188 250 1
## 93 600 0
## 266 250 0
## 165 600 0
## 228 450 0
## 56 250 1
## 233 500 0
## 250 250 0
## 255 250 0
## 26 250 1
## 173 600 0
## 277 250 0
## 44 250 0
## 201 250 1
## 247 450 0
## 217 250 1
## 249 250 0
## 204 250 1
## 172 600 0
## 251 250 0
## 29 250 0
## 14 600 0
## 159 600 0
## 65 250 1
## 3 250 0
## 163 600 0
## 53 450 0
## 112 700 0
## 67 250 1
## 49 300 0
## 220 250 1
## 208 250 1
## 128 600 0
## 9 250 0
## 157 600 0
## 6 250 0
## 101 600 1
## 58 250 1
## 244 300 0
## 138 600 1
## 119 600 0
## 131 250 0
## 105 250 0
## 39 250 0
## 117 600 1
## 52 450 0
## 189 250 1
## 265 250 0
## 37 250 0
## 207 250 1
## 68 250 1
## 263 450 0
## 66 250 0
## 103 600 0
## 258 300 0
## 23 600 0
## 84 600 0
## 142 600 1
## 62 250 1
## 280 450 1
## 43 250 0
## 243 250 0
## 28 250 1
## 4 250 0
## 268 450 0
## 54 250 0
## 88 600 0
## 174 600 0
## 198 250 1
## 279 450 0
## 143 600 1
## 175 600 0
## 78 250 0
## 182 250 1
## 74 250 0
## 118 600 1
## 83 900 0
## 222 250 1
## 196 250 1
## 218 250 1
## 273 450 0
## 264 250 0
## 271 450 0
## 100 600 1
## 160 600 0
## 224 250 1
## 253 250 0
## 2 250 1
## 221 250 1
## 145 600 0
## 151 600 0
## 124 600 0
## 77 250 0
## 256 250 0
## 96 600 0
## 11 250 0
## 232 350 0
## 73 250 0
## 50 300 0
## 171 600 0
## 33 400 0
## 90 600 0
## 35 350 0
## 116 600 0
## 75 250 0
## 236 250 0
## 38 250 0
## 70 250 0
## 104 350 0
## 55 450 0
## 282 450 0
## 167 600 1
## 227 250 0
## 102 600 1
## 10 250 0
## 270 250 0
## 146 600 1
## 179 300 0
## 158 600 0
## 234 250 0
## 111 250 0
## 72 250 1
## 89 600 0
## 248 500 0
## 239 250 0
## 120 600 0
## 13 700 0
## 24 300 0
pcr.res.cv <- pcr(taisyo ~ ., data=gesui, validation="CV")