-
Notifications
You must be signed in to change notification settings - Fork 1
/
彩种报告 - II.Rmd
1542 lines (1330 loc) · 67.8 KB
/
彩种报告 - II.Rmd
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "<span style='color:Red'>阿里彩票</span>"
subtitle: "彩种报告 (第II部)"
author: "雷欧 <img src='文艺坊图库/dashencaicai2.jpg' height='14'>"
date: "`r lubridate::today('Asia/Tokyo')`"
output:
html_document:
mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
number_sections: yes
toc: yes
toc_depth: 4
toc_float:
collapsed: yes
smooth_scroll: yes
code_folding: hide
css: CSSBackgrounds.css
---
# 主题
<img src='文艺坊图库/商场如战场.png' width='560'>
[[**主题曲**]{style="color:blue"}](https://github.com/englianhu/report/discussions)
🚄东方快车,🚄一带一路。
<audio controls loop autoplay src="文艺坊歌曲库/東方快車合唱團 Oriental Express - 紅紅青春敲呀敲 《黑松沙士》廣告主題曲.mp3" controls></audio>
<br>
# 设定
## SCSS 设置
<style>
pre {
overflow-x: auto;
}
pre code {
word-wrap: normal;
white-space: pre;
}
.table-hover > tbody > tr:hover {
background-color: #8D918D;
}
</style>
```{r load-sass, class.source='bg-success', class.output='bg-primary'}
# install.packages('remotes', dependencies = TRUE, INSTALL_opts = '--no-lock')
library('BBmisc', 'rmsfuns')
#remotes::install_github("rstudio/sass")
lib('sass')
## https://support.rstudio.com/hc/en-us/articles/200532197
## https://community.rstudio.com/t/r-does-not-display-korean-chinese/30889/3?u=englianhu
#Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
#Sys.setlocale("LC_CTYPE", "zh_CN.UTF-8")
#Sys.setlocale(category = "LC_CTYPE", "Chinese (Simplified)_China.936")
#Sys.setlocale(locale = "Chinese")
#Sys.setlocale(locale = "Japanese")
#Sys.setlocale(locale = "English")
# rmarkdown::render('/home/englianhu/Documents/owner/ryo-cn.Rmd', encoding = 'UTF-8')
#Sys.setlocale("LC_CTYPE", "UTF-8")
#Sys.setlocale(locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "chs")
#Sys.setlocale(category = "LC_ALL", locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "Chinese")
#Sys.setlocale(category = "LC_ALL", locale = "zh_CN.UTF-8")
Sys.setlocale("LC_ALL", "en_US.UTF-8")
```
```{scss set-scss, class.source='bg-success', class.output='bg-primary'}
/* https://stackoverflow.com/a/66029010/3806250 */
h1 { color: #002C54; }
h2 { color: #2F496E; }
h3 { color: #375E97; }
h4 { color: #556DAC; }
h5 { color: #92AAC7; }
/* ----------------------------------------------------------------- */
/* https://gist.github.com/himynameisdave/c7a7ed14500d29e58149#file-broken-gradient-animation-less */
.hover01 {
/* color: #FFD64D; */
background: linear-gradient(155deg, #EDAE01 0%, #FFEB94 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #EDAE01 20%, #FFEB94 80%);
}
}
.hover02 {
color: #FFD64D;
background: linear-gradient(155deg, #002C54 0%, #4CB5F5 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #002C54 20%, #4CB5F5 80%);
}
}
.hover03 {
color: #FFD64D;
background: linear-gradient(155deg, #A10115 0%, #FF3C5C 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #A10115 20%, #FF3C5C 80%);
}
}
```
```{r gb-opts, class.source='hover01', class.output='hover02'}
## Set the timezone but not change the datetime
Sys.setenv(TZ = 'Asia/Shanghai')
## Setting to omit all warnings
## https://stackoverflow.com/a/36846793/3806250
## Set width
## options(knitr.table.format = 'html') will set all kableExtra tables to be 'html', otherwise need to set the parameter on every single table.
options(warn = -1, width = 999, knitr.table.format = 'html')#, digits.secs = 6)
## https://stackoverflow.com/questions/39417003/long-vectors-not-supported-yet-abnor-in-rmd-but-not-in-r-script
## https://yihui.org/knitr/options
knitr::opts_chunk$set(
class.source = 'hover01', class.output = 'hover02', class.error = 'hover03',
message = FALSE, warning = FALSE, error = TRUE,
autodep = TRUE, aniopts = 'loop',
progress = TRUE, verbose = TRUE,
cache = FALSE, cache.lazy = FALSE, result = 'asis')
```
<br><br>
## 设置
```{r libs, eval=FALSE}
## Setup Options, Loading Required Libraries and Preparing Environment
## Loading the packages and setting adjustment
source('函数/libs.R')
```
读取程序包
```{r load-pkgs}
## Setup Options, Loading Required Libraries and Preparing Environment
## 3210448065@qq.com
## leiou123
## 2849108450@qq.com
## leiou123
## https://rstudio.cloud/project/1198888
## Loading the package 'BBmisc'
if(suppressMessages(!require('BBmisc'))){
install.packages('BBmisc', dependencies = TRUE, INSTALL_opts = '--no-lock')
suppressMessages(library('BBmisc'))
}
if (suppressMessages(!require('rmsfuns'))) {
install.packages('rmsfuns', dependencies = TRUE, INSTALL_opts = '--no-lock')
suppressMessages(library('rmsfuns'))
}
if(!require('REmap')) devtools::install_github('lchiffon/REmap')
## Loading multiple packages at once
#pkgs <- c('readr', 'plyr', 'dplyr', 'magrittr', 'tidyverse', 'devtools', 'zoo', 'lubridate', 'stringr', 'rvest', 'markdown', 'googleVis', 'knitr', 'rmarkdown', 'htmltools', 'knitr', 'kableExtra', 'formattable', 'echarts4r', 'radarchart', 'MASS', 'htmlwidgets', 'maps', 'REmap', 'ggmap', 'vembedr')
pkgs <- c('plyr', 'dplyr', 'magrittr', 'stringr', 'knitr', 'kableExtra', 'lubridate', 'broom', 'purrr', 'readxl', 'tibble', 'DT')
suppressAll(lib(pkgs))
load_pkg(pkgs)
rm(pkgs)
## Set the googleVis options first to change the behaviour of plot.gvis, so that
## only the chart component of the HTML file is written into the output file.
op <- options(gvis.plot.tag = 'chart')
## <audio src='music/bigmoney.mp3' autoplay controls loop></audio>
```
```{r set-prefer}
conflict_prefer('filter', 'dplyr')
conflict_prefer('select', 'dplyr')
conflict_prefer('mutate', 'dplyr')
conflict_prefer('rename', 'dplyr')
```
<br><br>
# 简介
当初在推广部门,**宋祖:宋组长**给个样本数据,我就尝试使用线性模型和时间序列`arima`模型分析了进粉业绩,详情请参考[阿里彩票 - 分析样本数据](https://rpubs.com/englianhu/ali)^[基于数据观测值太少^[[binary.com Interview Question I (Extention)](https://rpubs.com/englianhu/binary-Q1E)尝试分别使用`3个月`、`6个月`、`12个月`、`18个月`和`24个月`的数据,结果`12个月`的数据最为精准。],所以暂时没有预测。]。然后转到运维部门分析了[阿里彩票 - 彩种报告](https://rpubs.com/englianhu/ali_bet_type),只是基本分析彩种,将数据视觉化;此商业分析进一步使用混合线性模型分析数据,预测彩种盈利。
<br>
<br>
# 数据
<br>
读取样本数据。
```{r, results = 'asis', warning = FALSE}
## 读取数据
fls <- suppressWarnings(list.files('文艺数据库/彩种'))
smp <- fls %>%
llply(., function(x) {
dtt <- x %>% str_replace_all('.xls', '') %>% ymd
smpp <- read_excel(paste0('文艺数据库/彩种/', x)) %>%
.[-nrow(.),]
data.frame('日期' = dtt, smpp)
}) %>% bind_rows %>%
as_tibble %>%
mutate('彩种名称' = factor(彩种名称), '盈率' = as.numeric(percent(盈率))) %>%
mutate_if(is.character, as.numeric)
rm(fls)
nm <- names(smp)
names(smp) <- c('Date', 'Type', 'Bettor', 'Turnover', 'Won', 'Cancelled', 'Rebates', 'Profit', 'Profit_rate')
## 转化为大数据
smp2 <- smp
#smp2 <- copy_to(sc, smp2)
# smp2 %>%
# as_tibble %>%
# kbl('html', caption = '每日投注人数', escape = F) %>%
# kable_styling(
# bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
# scroll_box(height = '400px')
```
```{r}
smp %>% glimpse
```
<span style='color:Orange'>*图表2.1:数据简介*</span>
<s>上图</s>[阿里彩票 - 彩种报告](https://rpubs.com/englianhu/ali_bet_type)显示从`r smp$Date %>% range %>% .[1]`到`r smp$Date %>% range %>% .[2]`的报表数据,一共有`r nrow(smp2)`个观测值。
<br>
<br>
# 统计模型
<br>
## 多元相互式模型
<br>
以下数据显示每日投注人数。
```{r, results = 'asis', warning = FALSE}
# smp2 %>%
# spark_apply(
# function(e) summary(lm(Profit ~ Turnover * Bettor * Won, e))$r.squared,
# names = 'r.squared',
# group_by = 'Type')
# 每日观测值
smp2 %>%
ddply(.(Date), nrow) %>%
as_tibble %>% dplyr::rename(n = V1) %>%
## https://www.colorhexa.com/color-names
mutate(n = color_tile('#007fff', 'white')(n)) %>% #azure
kbl('html', caption = '每日投注人数', escape = F, align = 'c') %>%
kable_styling(
bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
scroll_box(height = '400px')
```
<span style='color:Orange'>*图表3.1.1:每日观测值*</span>
<br>
我不晓得最优模型,先以完整数据观测值为标准,以下乃`多元相互式模型`^[[如何 Estimate linear models](https://d.cosx.org/d/419820-estimate-linear-models/7)中的[UNDERSTANDING 3-WAY INTERACTIONS BETWEEN CONTINUOUS VARIABLES](https://tomhouslay.com/2014/03/21/understanding-3-way-interactions-between-continuous-variables/#comment-63365)]。
$$
\begin{align*}
Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\
&= \beta_{0} + {\color{Red} \widetilde{\beta_{1}}}X_{1} + \beta_{2}X_{2};
{\color{Red} \widetilde{\beta_{1}}} = \beta_{1} + \beta_{2}X_{2}\\
\end{align*}
$$
<span style='color:Orange'>*方程3.1.1:多元相互式模型*([*在线LaTEX方程编辑器*](https://www.codecogs.com/latex/eqneditor.php))</span>
```{r, results = 'asis', eval = FALSE, warning = FALSE}
# lm1 <- lm(Profit ~ Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2)
# m.aic.backward1 <- step(lm1, direction = 'backward', trace = 1)
# m.aic.backward2 <- step(lm1)
md <- list(
m00 = lm(Profit ~ Date * Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m01 = lm(Profit ~ Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m02 = lm(Profit ~ Type * Bettor * Turnover * Won * Cancelled, smp2) %>% extractAIC,
m03 = lm(Profit ~ Type * Bettor * Turnover * Won * Rebates, smp2) %>% extractAIC,
m04 = lm(Profit ~ Type * Bettor * Turnover * Cancelled * Rebates, smp2) %>% extractAIC,
m05 = lm(Profit ~ Type * Bettor * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m06 = lm(Profit ~ Type * Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m07 = lm(Profit ~ Bettor * Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m08 = lm(Profit ~ Type * Bettor * Turnover * Won, smp2) %>% extractAIC,
m09 = lm(Profit ~ Type * Bettor * Turnover * Rebates, smp2) %>% extractAIC,
m10 = lm(Profit ~ Type * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m11 = lm(Profit ~ Type * Bettor * Turnover * Cancelled, smp2) %>% extractAIC,
m12 = lm(Profit ~ Type * Bettor * Won * Rebates, smp2) %>% extractAIC,
m13 = lm(Profit ~ Type * Bettor * Won * Cancelled, smp2) %>% extractAIC,
m14 = lm(Profit ~ Type * Turnover * Won * Rebates, smp2) %>% extractAIC,
m15 = lm(Profit ~ Type * Turnover * Cancelled * Rebates, smp2) %>% extractAIC,
m16 = lm(Profit ~ Type * Turnover * Won * Rebates, smp2) %>% extractAIC,
m17 = lm(Profit ~ Type * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m18 = lm(Profit ~ Bettor * Turnover * Won * Cancelled, smp2) %>% extractAIC,
m19 = lm(Profit ~ Bettor * Turnover * Won * Rebates, smp2) %>% extractAIC,
m20 = lm(Profit ~ Bettor * Turnover * Cancelled * Rebates, smp2) %>% extractAIC,
m21 = lm(Profit ~ Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC,
m22 = lm(Profit ~ Turnover * Won * Cancelled * Rebates, smp2) %>% extractAIC) %>%
ldply %>%
as_tibble %>%
dplyr::rename(df = V1, AIC = V2)
## save files, easier to read.
microbenchmark(
save(md, file = '文艺数据库/md.rda'),
write_rds(md, '文艺数据库/md.rds'),
saveRDS(md, file = '文艺数据库/md.rds'))
#Unit: microseconds
# expr min lq mean median uq max neval
# save(md, "文艺数据库/md.rda") 114.666 130.9080 135.2061 134.3990 137.111 174.759 100
# write_rds(md, "文艺数据库/md.rds") 111.098 120.6370 126.8601 125.1935 129.534 178.582 100
# saveRDS(md, "文艺数据库/md.rds") 143.649 160.3135 178.6935 183.2730 186.673 358.803 100
```
1) $m00 = lm(Profit \sim Date * Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
2) $m01 = lm(Profit \sim Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
3) $m02 = lm(Profit \sim Type * Bettor * Turnover * Won * Cancelled, smp2)$
4) $m03 = lm(Profit \sim Type * Bettor * Turnover * Won * Rebates, smp2)$
5) $m04 = lm(Profit \sim Type * Bettor * Turnover * Cancelled * Rebates, smp2)$
6) $m05 = lm(Profit \sim Type * Bettor * Won * Cancelled * Rebates, smp2)$
7) $m06 = lm(Profit \sim Type * Turnover * Won * Cancelled * Rebates, smp2)$
8) $m07 = lm(Profit \sim Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
9) $m08 = lm(Profit \sim Type * Bettor * Turnover * Won, smp2)$
10) $m09 = lm(Profit \sim Type * Bettor * Turnover * Rebates, smp2)$
11) $m10 = lm(Profit \sim Type * Won * Cancelled * Rebates, smp2)$
12) $m11 = lm(Profit \sim Type * Bettor * Turnover * Cancelled, smp2)$
13) $m12 = lm(Profit \sim Type * Bettor * Won * Rebates, smp2)$
14) $m13 = lm(Profit \sim Type * Bettor * Won * Cancelled, smp2)$
15) $m14 = lm(Profit \sim Type * Turnover * Won * Rebates, smp2)$
16) $m15 = lm(Profit \sim Type * Turnover * Cancelled * Rebates, smp2)$
17) $m16 = lm(Profit \sim Type * Turnover * Won * Rebates, smp2)$
18) $m17 = lm(Profit \sim Type * Won * Cancelled * Rebates, smp2)$
19) $m18 = lm(Profit \sim Bettor * Turnover * Won * Cancelled, smp2)$
20) $m19 = lm(Profit \sim Bettor * Turnover * Won * Rebates, smp2)$
21) $m20 = lm(Profit \sim Bettor * Turnover * Cancelled * Rebates, smp2)$
22) $m21 = lm(Profit \sim Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
23) $m22 = lm(Profit \sim Turnover * Won * Cancelled * Rebates, smp2)$
<span style='color:Orange'>*方程3.1:多元相互式模型*</span>
以上模型使用$lm()$函数,从模型$m00 \sim m22$,[How to Make Beautiful Tables in R](https://rfortherestofus.com/2019/11/how-to-make-beautiful-tables-in-r/)有很多桌表程序包,以下咱们比较下**最优模型**。
<br>
### formattable
<br>
```{r, results = 'asis', warning = FALSE}
md <- read_rds('文艺数据库/md.rds')
md2 <- md
## https://www.colorhexa.com/color-names
md2 %>%
formattable(
list(
AIC = formatter('span', style = x ~ formattable::style(
color = ifelse(rank(x) <= 3, 'darkgoldenrod', 'grey')),
x ~ paste0(round(x, 2),
' (rank: ', sprintf('%1.f', rank(x)), ')')))) %>%
mutate(df = color_tile('#2a52be', 'white')(df)) #colbalt
```
<span style='color:Orange'>*方程3.1.1:最优多元相互式模型AIC比较*</span>
<br>
### kableExtra
<br>
```{r, results = 'asis', warning = FALSE}
## https://www.colorhexa.com/color-names
md2 %>%
mutate(
df = color_tile('#2a52be', 'white')(df), #colbalt
AIC = ifelse(
rank(AIC) <= 3,
cell_spec(
paste0(round(AIC, 2), ' (rank: ', sprintf('%1.f', rank(AIC)), ')'),
'html', color = 'darkgoldenrod', bold = T),
cell_spec(
paste0(round(AIC, 2), ' (rank: ', sprintf('%1.f', rank(AIC)), ')'),
'html', color = 'grey', italic = T))) %>%
kbl('html', caption = '最优模型', escape = F, align = c('c', 'r', 'r')) %>%
kable_styling(
bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material() %>%
scroll_box(height = '400px')
```
<span style='color:Orange'>*方程3.1.2:最优多元相互式模型AIC比较*</span>
<br>
以下模型乃前三榜,分别是$m00$所有因素,包括时间序列参数因素;$m07$忽略彩种因素;$m22$只包括`投注金额`、`中奖金额`、`撤单金额`和`返点金额`因素。
1) $m00 = lm(Profit \sim Date * Type * Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
8) $m07 = lm(Profit \sim Bettor * Turnover * Won * Cancelled * Rebates, smp2)$
23) $m22 = lm(Profit \sim Turnover * Won * Cancelled * Rebates, smp2)$
<span style='color:Orange'>*方程3.2.1:多元相互式模型*</span>
<span style='color:Red'>**备注**:以上最优模型加入时间变量,不过之后章节的时间序列模型,也得个别分析**$m00$**和**$m07$**,因为已经把时间变量加入分析,再加上时间序列的话,不晓得是否变质呢?</span>
<br>
<br>
## 多元多项式模型
<br>
### 多元正交与原始多项式模型
<br>
#### 多元多项式基本模型
<br>
- [关于r:拟合由`leaps :: regsubsets`选择的多项式回归模型](https://www.codenong.com/51223897)有举例,还介绍了`leaps`程序包。
- [lm()中的poly(): raw和正交之間的差異](https://www.itdaan.com/tw/c0fe14f3fda89205497a506bf9e9c119)
- [R实现Polynomial regression](https://www.jianshu.com/p/8e6cc12d3036)
- [多项式回归(Polynomial regression)及线性检验](https://www.bioinfo-scrounger.com/archives/polynomial-regression)
- [How to interpret coefficients from a polynomial model fit?](https://stats.stackexchange.com/a/95952/68357)
- [poly() in lm(): difference between raw vs. orthogonal](https://stackoverflow.com/a/30000214/3806250)
- [Fitting Polynomial Regression in R](https://www.r-bloggers.com/2015/09/fitting-polynomial-regression-in-r)^[Section**How to fit a polynomial regression** in [Fitting Polynomial Regression in R](https://www.r-bloggers.com/2015/09/fitting-polynomial-regression-in-r) ]
- [Raw or orthogonal polynomial regression?](https://stats.stackexchange.com/questions/258307/raw-or-orthogonal-polynomial-regression)
- [Multivariate polynomials in R (`polynom` package)](https://cran.r-project.org/web/packages/multipol/vignettes/multipol.pdf)^[[Multivariate polynomials in R (`polynom` package)](https://cran.r-project.org/web/packages/multipol/vignettes/multipol.pdf)可供R使用者使用多元非线性模型]
- [Multivariate Polynomial Regression in R (Prediction)](https://stackoverflow.com/a/50261058/3806250)
- [Polynomial regression with multiple independent variables in R](https://stackoverflow.com/questions/45013550/polynomial-regression-with-multiple-independent-variables-in-r)
![<span style='color:Orange'>*图像3.2.1:多项式线型模型*</span> [*Fitting Polynomial Regression in R*](https://www.r-bloggers.com/2015/09/fitting-polynomial-regression-in-r)](文艺坊图库/How to fit a polynomial regression 2.png)
<span style='color:Red'>**备注**:[lm() breaks when using poly() with predictors set up as factors](https://stackoverflow.com/a/61410867/3806250)讲述`poly`无法分析多元`factor`而只能分析虚拟变量(0或1)。</span>
$$
Y = \beta_{0} + \beta_{1}X_{1} + \beta_{11}X^{2} + \beta_{111}X^{3}
$$
<span style='color:Orange'>*方程3.1.2:多元多项式线型模型*</span>
<br>
##### 多元多项相互式正交模型
<br>
```{r, results = 'asis', eval = FALSE, warning = FALSE}
## https://stackoverflow.com/a/24133767/3806250
num <- 2:5
mprf_list <- llply(num, function(i) {
mprf = list(
#p00 = lm(Profit ~
# poly(Date, degree = i, raw = FALSE) *
# poly(Bettor, degree = i, raw = FALSE) *
# poly(Turnover, degree = i, raw = FALSE) *
# poly(Won, degree = i, raw = FALSE) *
# poly(Cancelled, degree = i, raw = FALSE) *
# poly(Rebates, degree = i, raw = FALSE), smp2) %>% extractAIC,
{p01 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p01'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p01, paste0('文艺数据库/mprf', i, '_p01.rds'))},
{p02 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p02'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p02, paste0('文艺数据库/mprf', i, '_p02.rds'))},
{p03 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p03'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p03, paste0('文艺数据库/mprf', i, '_p03.rds'))},
{p04 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p04'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p04, paste0('文艺数据库/mprf', i, '_p04.rds'))},
{p05 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p05'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p05, paste0('文艺数据库/mprf', i, '_p05.rds'))},
{p06 = lm(Profit ~
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p06'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p06, paste0('文艺数据库/mprf', i, '_p06.rds'))},
{p07 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p07'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p07, paste0('文艺数据库/mprf', i, '_p07.rds'))},
{p08 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p08'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p08, paste0('文艺数据库/mprf', i, '_p08.rds'))},
{p09 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p09'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p09, paste0('文艺数据库/mprf', i, '_p09.rds'))},
{p10 = lm(Profit ~
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p10'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p10, paste0('文艺数据库/mprf', i, '_p10.rds'))},
{p11 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p11'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p11, paste0('文艺数据库/mprf', i, '_p11.rds'))},
{p12 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p12'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p12, paste0('文艺数据库/mprf', i, '_p12.rds'))},
{p13 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p13'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p13, paste0('文艺数据库/mprf', i, '_p13.rds'))},
{p14 = lm(Profit ~
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p14'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p14, paste0('文艺数据库/mprf', i, '_p14.rds'))},
{p15 = lm(Profit ~
poly(Turnover, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p15'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p15, paste0('文艺数据库/mprf', i, '_p15.rds'))},
{p16 = lm(Profit ~
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p16'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p16, paste0('文艺数据库/mprf', i, '_p16.rds'))},
{p17 = lm(Profit ~
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p17'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p17, paste0('文艺数据库/mprf', i, '_p17.rds'))},
{p18 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p18'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p18, paste0('文艺数据库/mprf', i, '_p18.rds'))},
{p19 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p19'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p19, paste0('文艺数据库/mprf', i, '_p19.rds'))},
{p20 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p20'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p20, paste0('文艺数据库/mprf', i, '_p20.rds'))},
{p21 = lm(Profit ~
poly(Bettor, degree = i, raw = FALSE) *
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p21'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p21, paste0('文艺数据库/mprf', i, '_p21.rds'))},
{p22 = lm(Profit ~
poly(Turnover, degree = i, raw = FALSE) *
poly(Won, degree = i, raw = FALSE) *
poly(Cancelled, degree = i, raw = FALSE) *
poly(Rebates, degree = i, raw = FALSE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprf_p22'), degree = i, raw = FALSE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p22, paste0('文艺数据库/mprf', i, '_p22.rds'))}
) %>%
ldply %>%
as_tibble
## save files, easier to read.
#write_rds(mprf, paste0('文艺数据库/mprf', i, '.rds'))
})
```
<br>
##### 多元多项相互式原始模型
<br>
```{r, results = 'asis', eval = FALSE, warning = FALSE}
## https://stackoverflow.com/a/24133767/3806250
num <- 2:5
mprt_list <- llply(num, function(i) {
mprt = list(
#p00 = lm(Profit ~
# poly(Date, degree = i, raw = TRUE) *
# poly(Bettor, degree = i, raw = TRUE) *
# poly(Turnover, degree = i, raw = TRUE) *
# poly(Won, degree = i, raw = TRUE) *
# poly(Cancelled, degree = i, raw = TRUE) *
# poly(Rebates, degree = i, raw = TRUE), smp2) %>% extractAIC,
{p01 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p01'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p01, paste0('文艺数据库/mprt', i, '_p01.rds'))},
{p02 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p02'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p02, paste0('文艺数据库/mprt', i, '_p02.rds'))},
{p03 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p03'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p03, paste0('文艺数据库/mprt', i, '_p03.rds'))},
{p04 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p04'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p04, paste0('文艺数据库/mprt', i, '_p04.rds'))},
{p05 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p05'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p05, paste0('文艺数据库/mprt', i, '_p05.rds'))},
{p06 = lm(Profit ~
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p06'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p06, paste0('文艺数据库/mprt', i, '_p06.rds'))},
{p07 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p07'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p07, paste0('文艺数据库/mprt', i, '_p07.rds'))},
{p08 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p08'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p08, paste0('文艺数据库/mprt', i, '_p08.rds'))},
{p09 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p09'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p09, paste0('文艺数据库/mprt', i, '_p09.rds'))},
{p10 = lm(Profit ~
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p10'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p10, paste0('文艺数据库/mprt', i, '_p10.rds'))},
{p11 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p11'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p11, paste0('文艺数据库/mprt', i, '_p11.rds'))},
{p12 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p12'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p12, paste0('文艺数据库/mprt', i, '_p12.rds'))},
{p13 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p13'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p13, paste0('文艺数据库/mprt', i, '_p13.rds'))},
{p14 = lm(Profit ~
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p14'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p14, paste0('文艺数据库/mprt', i, '_p14.rds'))},
{p15 = lm(Profit ~
poly(Turnover, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p15'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p15, paste0('文艺数据库/mprt', i, '_p15.rds'))},
{p16 = lm(Profit ~
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p16'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p16, paste0('文艺数据库/mprt', i, '_p16.rds'))},
{p17 = lm(Profit ~
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p17'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p17, paste0('文艺数据库/mprt', i, '_p17.rds'))},
{p18 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p18'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p18, paste0('文艺数据库/mprt', i, '_p18.rds'))},
{p19 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p19'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p19, paste0('文艺数据库/mprt', i, '_p19.rds'))},
{p20 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Cancelled, degree = i, raw = TRUE) *
poly(Rebates, degree = i, raw = TRUE), smp2) %>%
extractAIC %>%
as_tibble %>%
t %>% as_tibble %>%
dplyr::rename(df = V1, AIC = V2) %>%
mutate(.md = paste0('mprt_p20'), degree = i, raw = TRUE) %>%
dplyr::select(.md, degree, df, AIC);
write_rds(p20, paste0('文艺数据库/mprt', i, '_p20.rds'))},
{p21 = lm(Profit ~
poly(Bettor, degree = i, raw = TRUE) *
poly(Turnover, degree = i, raw = TRUE) *
poly(Won, degree = i, raw = TRUE) *