-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodeling.R
More file actions
75 lines (53 loc) · 1.62 KB
/
modeling.R
File metadata and controls
75 lines (53 loc) · 1.62 KB
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
# Modeling of the TRP, KYN, KYN/TRP, PHE, TYR and PHE/TYR as a function
# of inflammatory, CoV-related and psychometric explanatory variables in
# the SIMMUN/STIGMA cohort
#
# Ramerkable over-fitting in LASSO!
# tools -------
library(plyr)
library(tidyverse)
library(trafo)
library(rlang)
library(lmqc)
library(MASS)
library(glmnet)
library(ranger)
library(party)
library(caret)
library(caretExtra)
library(exda)
library(ggrepel)
library(ggtext)
library(doParallel)
library(furrr)
library(soucer)
train <- caret::train
explore <- exda::explore
reduce <- purrr::reduce
c('./tools/tools.R') %>%
source_all(message = TRUE, crash = TRUE)
# Analysis globals ------
insert_msg('Analysis globals')
mod_globals <- list()
## analysis table with normalized numeric variables
mod_globals$analysis_tbl <- stigma$analysis_tbl %>%
map_dfc(function(x) if(is.numeric(x)) scale(x)[, 1] else x)
## full and null model formulas
mod_globals$full_formulas <- stigma$responses %>%
map(~paste(.x,
paste(stigma$expl_lexicon$variable, collapse = ' + '),
sep = ' ~ ')) %>%
map(as.formula)
mod_globals$null_formulas <- stigma$responses %>%
map(~paste(.x, '~ 1')) %>%
map(as.formula)
# Analysis scripts ------
insert_msg('Analysis scripts')
c('./modeling scripts/elimination.R'#,
#'./modeling scripts/glmnet.R',
#'./modeling scripts/ranger.R',
#'./modeling scripts/cforest.R'
) %>%
source_all(message = TRUE, crash = TRUE)
# END ------
insert_tail()