Professional Documents
Culture Documents
> install.pacages("earth")
Error in install.pacages("earth") :
> install.packages("earth")
--- Please select a CRAN mirror for use in this session ---
downloaded 1.1 MB
downloaded 173 KB
downloaded 1.5 MB
downloaded 1.2 MB
downloaded 2.1 MB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
> install.packages("caTools")
downloaded 41 KB
downloaded 309 KB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
> install.packages("corrplot")
downloaded 2.8 MB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
> install.packages("metrics")
Warning messages:
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
> install.packages("Metrics")
downloaded 80 KB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
> install.packages("olsrr")
also installing the dependencies ‘bit’, ‘bit64’, ‘clipr’, ‘vroom’, ‘tzdb’, ‘rematch’, ‘prettyunits’, ‘backports’,
‘generics’, ‘purrr’, ‘stringr’, ‘tidyr’, ‘tidyselect’, ‘evaluate’, ‘highr’, ‘yaml’, ‘xfun’, ‘matrixStats’,
‘RcppArmadillo’, ‘forcats’, ‘hms’, ‘readr’, ‘cpp11’, ‘cellranger’, ‘progress’, ‘zip’, ‘stringi’, ‘colorspace’, ‘cli’,
‘crayon’, ‘utf8’, ‘broom’, ‘dplyr’, ‘magrittr’, ‘numDeriv’, ‘knitr’, ‘SparseM’, ‘MatrixModels’, ‘conquer’, ‘sp’,
‘haven’, ‘curl’, ‘readxl’, ‘openxlsx’, ‘minqa’, ‘nloptr’, ‘RcppEigen’, ‘farver’, ‘labeling’, ‘lifecycle’, ‘munsell’,
‘R6’, ‘RColorBrewer’, ‘viridisLite’, ‘ellipsis’, ‘fansi’, ‘pillar’, ‘pkgconfig’, ‘vctrs’, ‘carData’, ‘abind’, ‘pbkrtest’,
‘quantreg’, ‘maptools’, ‘rio’, ‘lme4’, ‘digest’, ‘glue’, ‘gtable’, ‘isoband’, ‘rlang’, ‘scales’, ‘tibble’, ‘withr’,
‘car’, ‘data.table’, ‘ggplot2’, ‘goftest’, ‘gridExtra’, ‘nortest’, ‘Rcpp’
There are binary versions available but the source versions are later:
downloaded 627 KB
downloaded 552 KB
downloaded 51 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/vroom_1.5.5.zip'
downloaded 1.9 MB
downloaded 1.3 MB
downloaded 15 KB
downloaded 36 KB
downloaded 96 KB
downloaded 70 KB
downloaded 420 KB
downloaded 211 KB
downloaded 1.0 MB
downloaded 199 KB
downloaded 74 KB
downloaded 45 KB
downloaded 349 KB
downloaded 580 KB
downloaded 2.6 MB
downloaded 349 KB
downloaded 1.7 MB
downloaded 319 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/cellranger_1.1.0.zip'
downloaded 102 KB
downloaded 83 KB
downloaded 1.1 MB
downloaded 15.7 MB
downloaded 2.5 MB
downloaded 741 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/crayon_1.4.1.zip'
downloaded 139 KB
downloaded 205 KB
downloaded 1.7 MB
downloaded 1.3 MB
downloaded 230 KB
downloaded 113 KB
downloaded 1.4 MB
downloaded 1.0 MB
downloaded 424 KB
downloaded 932 KB
downloaded 1.7 MB
downloaded 1.2 MB
downloaded 1.6 MB
downloaded 2.7 MB
downloaded 835 KB
downloaded 1.2 MB
downloaded 2.7 MB
downloaded 1.7 MB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/labeling_0.4.2.zip'
downloaded 61 KB
downloaded 239 KB
downloaded 82 KB
downloaded 54 KB
downloaded 1.2 MB
downloaded 47 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/fansi_0.5.0.zip'
downloaded 242 KB
downloaded 21 KB
downloaded 1.2 MB
downloaded 1.7 MB
downloaded 62 KB
downloaded 348 KB
downloaded 1.9 MB
downloaded 2.1 MB
downloaded 524 KB
downloaded 5.1 MB
downloaded 263 KB
downloaded 152 KB
downloaded 2.6 MB
downloaded 1.1 MB
downloaded 545 KB
downloaded 850 KB
downloaded 208 KB
downloaded 1.5 MB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/data.table_1.14.0.zip'
downloaded 2.5 MB
downloaded 3.9 MB
downloaded 73 KB
downloaded 1.1 MB
downloaded 37 KB
downloaded 3.1 MB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/olsrr_0.5.3.zip'
downloaded 2.6 MB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
downloaded 42 KB
downloaded 97 KB
downloaded 1.1 MB
* installing *source* package 'lifecycle' ...
** R
** inst
** help
badge html
deprecate_soft html
deprecated html
expect_deprecated html
last_lifecycle_warnings html
lifecycle-package html
lint_lifecycle html
signal_experimental html
signal_stage html
verbosity html
** installing vignettes
* DONE (lifecycle)
** R
** help
Deprecated html
hms-package html
hms html
parse_hms html
round_hms html
vec_cast.hms html
vec_ptype2.hms html
* DONE (hms)
** R
** inst
** help
align html
char html
colonnade html
ctl_new_pillar html
deprecated html
dim_desc html
expect_known_display html
extra_cols html
format_glimpse html
format_tbl html
format_type_sum html
get_extent html
glimpse html
new_ornament html
new_pillar html
new_pillar_component html
new_pillar_shaft html
new_pillar_title html
new_pillar_type html
new_tbl_format_setup html
num html
pillar-package html
pillar html
pillar_options html
pillar_shaft html
squeeze html
style_subtle html
tbl_format_body html
tbl_format_footer html
tbl_format_header html
tbl_format_setup html
tbl_sum html
type_sum html
** installing vignettes
* DONE (pillar)
‘C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages’
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> install.packages("splines")
Warning message:
> install.packages("earth")
downloaded 2.1 MB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
> print(data)
y.x1.x2.x3.x4.x5.x6
1 11.43,1,16,1,6,2,756723
2 9.97,1,16,2,7,2,411758
3 10.69,1,17,1,7,2,602575
4 9.56,2,17,2,5,1,315000
5 8.43,2,18,1,4,2,538760
6 8.67,2,19,2,3,1,385730
7 8.88,2,20,1,4,1,343327
8 8.8,2,21,2,5,1,358350
9 8.87,2,22,2,6,1,2761910
10 7.31,2,23,2,5,2,658150
11 6.18,2,24,2,8,2,249000
12 4.55,1,24,1,9,2,443710
13 3.98,2,20,2,5,1,338930
14 4.95,1,22,2,6,1,451800
15 3.98,2,21,2,7,1,680400
16 5.26,1,18,2,5,1,403046
17 2.88,2,16,2,4,1,2786440
18 2.77,1,81,2,5,2,2980950
19 5.56,2,17,1,4,2,579411
20 2.73,1,16,2,5,2,320972
21 4.19,2,16,1,6,2,473000
22 4.54,1,16,2,5,1,333000
23 4.49,2,16,1,4,1,390000
24 2.98,1,17,2,5,1,2892030
25 3.16,1,17,1,6,1,303950
26 1.91,2,18,2,3,2,467700
27 3.64,2,19,1,3,2,361853
28 2.94,2,20,2,3,2,549100
29 2.88,2,21,1,3,2,423500
30 1.37,1,22,2,3,2,304100
31 1.17,2,23,1,4,2,588300
32 1.8,2,24,1,4,1,334270
33 4.11,2,24,2,5,2,361966
34 7.6,2,20,2,5,1,2698030
35 7.06,2,22,2,6,1,2722430
36 9.8,2,21,2,2,1,2719430
37 7.38,1,18,1,4,1,2843970
38 2.26,2,16,2,6,2,300400
39 6.39,1,81,2,7,2,2906000
40 5.94,2,17,1,7,2,2968990
41 3.94,1,16,2,4,1,300293
42 6.38,2,16,2,8,2,316850
43 7.93,1,17,2,5,1,313218
44 9.43,2,17,1,5,1,301010
45 11.67,1,17,2,5,1,433450
46 16.5,2,24,2,5,1,405210
47 7.42,1,20,1,5,1,2140100
48 6.92,2,22,1,4,1,2425500
49 5.91,1,21,1,4,2,1728640
50 6.78,1,18,1,4,2,538439
51 7.49,2,16,2,3,1,2615000
52 7.48,2,81,2,4,2,515991
53 10.12,2,17,2,4,2,658820
54 11.13,2,16,2,2,2,493800
55 12.2,1,16,2,2,2,303480
56 12.23,2,16,1,4,2,373368
57 10.48,2,16,1,8,2,343853
58 13.26,1,17,1,7,2,332100
59 17.78,1,17,1,7,1,328215
60 17.67,1,18,2,6,1,357130
61 19.74,1,19,2,6,1,457550
62 14.09,1,20,2,6,1,316100
63 15.77,2,21,1,5,1,358800
64 13.77,1,22,2,6,2,299200
65 14.26,2,23,2,4,2,243000
66 16.41,2,24,2,4,2,384000
67 18.85,1,24,2,4,2,309700
68 18.83,2,20,2,8,1,2819800
69 25.02,1,22,2,8,2,326900
70 23.24,2,21,1,9,2,359300
> str(data)
'data.frame': 70 obs. of 1 variable:
> print(Datatraining)
> print(Datatraining)
> print(datatraining)
X.y.x1.x2.x3.x4.x5.x6
1 6,8.67,2,19,2,3,1,385730
2 7,8.88,2,20,1,4,1,343327
3 8,8.8,2,21,2,5,1,358350
4 9,8.87,2,22,2,6,1,2761910
5 10,7.31,2,23,2,5,2,658150
6 11,6.18,2,24,2,8,2,249000
7 12,4.55,1,24,1,9,2,443710
8 13,3.98,2,20,2,5,1,338930
9 14,4.95,1,22,2,6,1,451800
10 15,3.98,2,21,2,7,1,680400
11 16,5.26,1,18,2,5,1,403046
12 17,2.88,2,16,2,4,1,2786440
13 18,2.77,1,81,2,5,2,2980950
14 19,5.56,2,17,1,4,2,579411
15 20,2.73,1,16,2,5,2,320972
16 21,4.19,2,16,1,6,2,473000
17 22,4.54,1,16,2,5,1,333000
18 23,4.49,2,16,1,4,1,390000
19 24,2.98,1,17,2,5,1,2892030
20 25,3.16,1,17,1,6,1,303950
21 26,1.91,2,18,2,3,2,467700
22 27,3.64,2,19,1,3,2,361853
23 28,2.94,2,20,2,3,2,549100
24 29,2.88,2,21,1,3,2,423500
25 30,1.37,1,22,2,3,2,304100
26 31,1.17,2,23,1,4,2,588300
27 32,1.8,2,24,1,4,1,334270
28 33,4.11,2,24,2,5,2,361966
29 34,7.6,2,20,2,5,1,2698030
30 35,7.06,2,22,2,6,1,2722430
31 36,9.8,2,21,2,2,1,2719430
32 37,7.38,1,18,1,4,1,2843970
33 38,2.26,2,16,2,6,2,300400
34 39,6.39,1,81,2,7,2,2906000
35 40,5.94,2,17,1,7,2,2968990
36 41,3.94,1,16,2,4,1,300293
37 42,6.38,2,16,2,8,2,316850
38 43,7.93,1,17,2,5,1,313218
39 44,9.43,2,17,1,5,1,301010
40 45,11.67,1,17,2,5,1,433450
41 46,16.5,2,24,2,5,1,405210
42 47,7.42,1,20,1,5,1,2140100
43 48,6.92,2,22,1,4,1,2425500
44 49,5.91,1,21,1,4,2,1728640
45 50,6.78,1,18,1,4,2,538439
46 51,7.49,2,16,2,3,1,2615000
47 52,7.48,2,81,2,4,2,515991
48 53,10.12,2,17,2,4,2,658820
49 54,11.13,2,16,2,2,2,493800
50 55,12.2,1,16,2,2,2,303480
51 56,12.23,2,16,1,4,2,373368
52 57,10.48,2,16,1,8,2,343853
53 58,13.26,1,17,1,7,2,332100
54 59,17.78,1,17,1,7,1,328215
55 60,17.67,1,18,2,6,1,357130
56 61,19.74,1,19,2,6,1,457550
57 62,14.09,1,20,2,6,1,316100
58 63,15.77,2,21,1,5,1,358800
59 64,13.77,1,22,2,6,2,299200
60 65,14.26,2,23,2,4,2,243000
61 66,16.41,2,24,2,4,2,384000
62 67,18.85,1,24,2,4,2,309700
63 68,18.83,2,20,2,8,1,2819800
64 69,25.02,1,22,2,8,2,326900
65 70,23.24,2,21,1,9,2,359300
X.y.x1.x2.x3.x4.x5.x6
1 1,11.43,1,16,1,6,2,756723
2 2,9.97,1,16,2,7,2,411758
3 3,10.69,1,17,1,7,2,602575
4 4,9.56,2,17,2,5,1,315000
5 5,8.43,2,18,1,4,2,538760
> print(MARS)
> library(earth)
> print(MARS)
> print(MARS)
> m2=earth(TEAC~.,data=data,penalty=2,pmethod="backward",degree=1,nk=200,nfold=3,keepxy=T)
> library(MASS)
> library(tidyverse)
> library(earth)
> library(caret)
Error in library(caret) : there is no package called ‘caret’
> set.seed(2021)
> ?Boston
> print(MARS)
> library(MARS)
> library(earth)
> print(MARS)
> print(earth)
function (...)
UseMethod("earth")
<bytecode: 0x0935a378>
<environment: namespace:earth>
>
> d=read.table("F:/data.txt",header=T)
> str(d)
$ x1 : int 1 1 1 2 2 2 2 2 2 2 ...
$ x2 : int 16 16 17 17 18 19 20 21 22 23 ...
$ x3 : int 1 2 1 2 1 2 1 2 2 2 ...
$ x4 : int 6 7 7 5 4 3 4 5 6 5 ...
$ x5 : int 2 2 2 1 2 1 1 1 1 2 ...
$ x6 : int 756723 411758 602575 315000 538760 385730 343327 358350 2761910 658150 ...
> install.packages("earth")
> library(earth)
> m1=earth(x1~.,data=d,penalty=2,degree=1,nk=200,nfold=10,keepxy=T)
> summary(m1,digits=3)
nk=200)
coefficients
(Intercept) 1.59
Note: the cross-validation sd's below are standard deviations across folds
> d=read.table("F:/data.txt",header=T)
> str(d)
$ x1 : int 21781 32139 22042 19703 31066 9792 15696 14809 8413 29169 ...
$ X5 : num 7.48 4.19 6.06 4 5.52 4.51 3.44 2.91 2.16 3.11 ...
$ x10: int 1056602 995216 597322 499256 813312 341140 455063 671386 449235 694772 ...
> d=read.table("F:/data.txt",header=T)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
>
> d=read.table("F:/data.txt",header=T)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
> d=read.table("F:/data.txt",header=T)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
> d=read.table("F:/data.txt",header=T)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
> d=read.table("F:/data.txt",header=T)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
> d=read.table("F:/data.txt",header=T)
>
> str(d)
$ X5 : num 7.48 4.19 6.06 4 5.52 4.51 3.44 2.91 2.16 3.11 ...
$ x7 : int 37824 35286 23390 16809 15719 9157 19551 16936 11906 16258 ...
$ x10: int 1056602 995216 597322 499256 813312 341140 455063 671386 449235 694772 ...
> m1=earth(x1~.,data=d,penalty=2,degree=1,nk=200,nfold=10,keepxy=T)
> summary(m1,digits=3)
nk=200)
coefficients
(Intercept) 16482
h(x3-69.32) 1489
h(X5-3.44) 2973
h(597322-x10) 0
Note: the cross-validation sd's below are standard deviations across folds
CVRSq sd MaxErr sd
> print(m1)
GCV 48539059 RSS 1087274932 GRSq 0.5767614 RSq 0.7129593 CVRSq -3.574852
nk=200)
1=
1.65e+04
GCV 48539059 RSS 1.09e+09 GRSq 0.577 RSq 0.713 CVRSq -3.57
Note: the cross-validation sd's below are standard deviations across folds
CVRSq sd MaxErr sd
> evimp(m1)
x3 2 74.6 72.2
X5 1 56.6 51.1
> cor.test(Datatraining$Y,predict(MARS))
>
> cor.test(datatraining$Y,predict(m1))
> library(caret)
also installing the dependencies ‘listenv’, ‘parallelly’, ‘future’, ‘globals’, ‘future.apply’, ‘progressr’,
‘SQUAREM’, ‘lava’, ‘prodlim’, ‘iterators’, ‘gower’, ‘ipred’, ‘lubridate’, ‘timeDate’, ‘foreach’, ‘plyr’,
‘ModelMetrics’, ‘reshape2’, ‘recipes’, ‘pROC’
There are binary versions available but the source versions are later:
downloaded 104 KB
downloaded 269 KB
downloaded 674 KB
downloaded 93 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/future.apply_1.8.1.zip'
downloaded 151 KB
downloaded 178 KB
downloaded 2.9 MB
downloaded 411 KB
downloaded 335 KB
downloaded 291 KB
trying URL 'https://repo.bppt.go.id/cran/bin/windows/contrib/4.1/ipred_0.9-12.zip'
downloaded 391 KB
downloaded 1.7 MB
downloaded 1.5 MB
downloaded 142 KB
downloaded 1.4 MB
downloaded 843 KB
downloaded 798 KB
downloaded 1.5 MB
downloaded 6.0 MB
C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages
downloaded 104 KB
downloaded 665 KB
** R
** demo
** inst
global_progression_handler html
handler_ascii_alert html
handler_beepr html
handler_debug html
handler_filesize html
handler_newline html
handler_notifier html
handler_pbcol html
handler_pbmcapply html
handler_progress html
handler_rstudio html
handler_shiny html
handler_tkprogressbar html
handler_txtprogressbar html
handler_void html
handler_winprogressbar html
handlers html
make_progression_handler html
progress html
progress_aggregator html
progress_progressr html
progression html
progressor html
progressr html
progressr.options html
register_global_progression_handler html
slow_sum html
withProgressShiny html
with_progress html
** installing vignettes
* DONE (progressr)
** R
** inst
add_step html
bake html
check_class html
check_cols html
check_missing html
check_name html
check_new_values html
check_range html
check_type html
detect_step html
discretize html
fixed html
format_ch_vec html
formula.recipe html
fully_trained html
get_keep_original_cols html
has_role html
juice html
names0 html
prep html
prepper html
print.recipe html
rand_id html
recipe html
recipes-internal html
recipes html
recipes_eval_select html
recipes_pkg_check html
reexports html
required_pkgs.recipe html
roles html
selections html
step html
step_BoxCox html
step_YeoJohnson html
step_arrange html
step_bin2factor html
step_bs html
step_center html
step_classdist html
step_corr html
step_count html
step_cut html
step_date html
step_depth html
step_discretize html
step_downsample html
step_dummy html
step_dummy_multi_choice html
step_factor2string html
step_filter html
step_geodist html
step_harmonic html
step_holiday html
step_hyperbolic html
step_ica html
step_impute_bag html
step_impute_knn html
step_impute_linear html
step_impute_lower html
step_impute_mean html
step_impute_median html
step_impute_mode html
step_impute_roll html
step_indicate_na html
step_integer html
step_interact html
step_intercept html
step_inverse html
step_invlogit html
step_isomap html
step_kpca html
step_kpca_poly html
step_kpca_rbf html
step_lag html
step_lincomb html
step_log html
step_logit html
step_mutate html
step_mutate_at html
step_naomit html
step_nnmf html
step_normalize html
step_novel html
step_ns html
step_num2factor html
step_nzv html
step_ordinalscore html
step_other html
step_pca html
step_pls html
step_poly html
step_profile html
step_range html
step_ratio html
step_regex html
step_relevel html
step_relu html
step_rename html
step_rename_at html
step_rm html
step_sample html
step_scale html
step_select html
step_shuffle html
step_slice html
step_spatialsign html
step_sqrt html
step_string2factor html
step_unknown html
step_unorder html
step_upsample html
step_window html
step_zv html
summary.recipe html
terms_select html
tidy.recipe html
tunable.recipe html
update.step html
*** copying figures
** installing vignettes
* DONE (recipes)
‘C:\Users\user\AppData\Local\Temp\RtmpMJZrff\downloaded_packages’
> library(caret)
> print(Hypergrid)
degree nprune
1 1 3.00000
2 2 3.00000
3 3 3.00000
4 1 13.77778
5 2 13.77778
6 3 13.77778
7 1 24.55556
8 2 24.55556
9 3 24.55556
10 1 35.33333
11 2 35.33333
12 3 35.33333
13 1 46.11111
14 2 46.11111
15 3 46.11111
16 1 56.88889
17 2 56.88889
18 3 56.88889
19 1 67.66667
20 2 67.66667
21 3 67.66667
22 1 78.44444
23 2 78.44444
24 3 78.44444
25 1 89.22222
26 2 89.22222
27 3 89.22222
28 1 100.00000
29 2 100.00000
30 3 100.00000
>
> m1=earth(x1~.,data=d,penalty=2,degree=1,nk=200,nfold=10,keepxy=T)
nk=200)
1=
1.65e+04
GCV 48539059 RSS 1.09e+09 GRSq 0.577 RSq 0.713 CVRSq -2.14
Note: the cross-validation sd's below are standard deviations across folds
> print(Hypergrid)
degree nprune
1 1 3.00000
2 2 3.00000
3 3 3.00000
4 1 13.77778
5 2 13.77778
6 3 13.77778
7 1 24.55556
8 2 24.55556
9 3 24.55556
10 1 35.33333
11 2 35.33333
12 3 35.33333
13 1 46.11111
14 2 46.11111
15 3 46.11111
16 1 56.88889
17 2 56.88889
18 3 56.88889
19 1 67.66667
20 2 67.66667
21 3 67.66667
22 1 78.44444
23 2 78.44444
24 3 78.44444
25 1 89.22222
26 2 89.22222
27 3 89.22222
28 1 100.00000
29 2 100.00000
30 3 100.00000
> Tunedm1$results
>