-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.R
69 lines (56 loc) · 1.31 KB
/
utils.R
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
library(compositions)
# Load environment variables from the .env file
dotenv::load_dot_env()
data_dir <- Sys.getenv("DATA_DIR")
output_dir <- Sys.getenv("OUTPUT_DIR")
seed_val <- Sys.getenv("SEED")
boot_data_file <- file.path(data_dir, "bootstrap_data_28_10_24.rds")
mri_data_file <- file.path(data_dir, "mri_data.csv")
# Constants
short_sleep_hours <- 6
hrs_in_day <- 24
mins_in_day <- 1440
mins_in_hour <- 60
sub_steps <- 4
sub_step_mins <- mins_in_hour / sub_steps
ncpus <- as.integer(Sys.getenv("NCPUS"))
bootstrap_iterations <- as.integer(Sys.getenv("BOOT_ITRS"))
maxit <- as.integer(Sys.getenv("MAXIT"))
## Define SBP
sbp <- matrix(
c(
1, 1, -1, -1,
1, -1, 0, 0,
0, 0, 1, -1
),
ncol = 4, byrow = TRUE
)
v <- gsi.buildilrBase(t(sbp))
## strip unneccessary model components
strip_glm <- function(cm) {
cm$y <- c()
cm$model <- c()
cm$residuals <- c()
cm$fitted.values <- c()
cm$effects <- c()
cm$qr$qr <- c()
cm$linear.predictors <- c()
cm$weights <- c()
cm$prior.weights <- c()
cm$data <- c()
cm$family$variance <- c()
cm$family$dev.resids <- c()
cm$family$aic <- c()
cm$family$validmu <- c()
cm$family$simulate <- c()
return(cm)
}
save_plot <- function(plot, file_path) {
ggsave(
file_path,
plot = plot,
device = "svg",
width = 10,
height = 12
)
}