@@ -21,38 +21,9 @@ require(SuperLearner)
21
21
2 . Define the learners that you want to use in superlearner training
22
22
23
23
``` {r}
24
- #Logistic Regression
25
- SL.glm.DCDR <- function(...){
26
- SL.glm(...)
27
- }
28
-
29
- #4 degree GAM
30
- SL.gam4.DCDR <- function(...){
31
- SL.gam(..., deg.gam=4)
32
- }
33
-
34
- #6 degree GAM
35
- SL.gam6.DCDR <- function(...){
36
- SL.gam(..., deg.gam=6)
37
- }
38
-
39
- #Neural Network
40
- SL.nnet.DCDR <- function(...){
41
- SL.nnet(..., size=4)
42
- }
43
-
44
- #Random forest
45
- SL.randomForest.DCDR <- function(...){
46
- SL.randomForest(..., ntree=500, nodesize=20)
47
- }
48
-
49
- #Empirical mean
50
- SL.mean.DCDR <- function(...){
51
- SL.mean(...)
52
- }
53
-
24
+ # learners can be defined from `Superlearner::SL.library()`
25
+ learners = c("SL.glm","SL.glmnet", "SL.xgboost")
54
26
55
- learners <- c("SL.glm.DCDR", "SL.gam4.DCDR", "SL.gam6.DCDR", "SL.nnet.DCDR", "SL.randomForest.DCDR", "SL.mean.DCDR")
56
27
```
57
28
58
29
3 . Defining the data you want to use
@@ -67,11 +38,11 @@ df = data
67
38
exposure="statin"
68
39
outcome="Y"
69
40
70
- covarsT <- c("age", "ldl_log", "risk_score") # covariate for exposure
71
- covarsO <- c("age", "ldl_log", "risk_score") # covariate for outcome
41
+ covarsT <- c("age", "ldl_log", "risk_score") # covariate for exposure model
42
+ covarsO <- c("age", "ldl_log", "risk_score") # covariate for outcome model
72
43
73
- # Here `V=5' indicates the number of cross-validation folds that is applied in the superlearner training.
74
- control <- SuperLearner.CV.control(V=5)
44
+ # Controls parameters to be used in cross-validation in the superlearner training. Similar as `Superlearner::cvControl()`
45
+ control <- SuperLearner.CV.control(V=5)
75
46
76
47
## Wrapper functions
77
48
0 commit comments