Get a `tof_model`'s processed outcome variable matrix (for glmnet)
Source:R/modeling_helpers.R
tof_get_model_y.Rd
Get a `tof_model`'s processed outcome variable matrix (for glmnet)
Examples
feature_tibble <-
dplyr::tibble(
sample = as.character(1:100),
cd45 = runif(n = 100),
pstat5 = runif(n = 100),
cd34 = runif(n = 100),
outcome = (3 * cd45) + (4 * pstat5) + rnorm(100),
class =
as.factor(
dplyr::if_else(outcome > median(outcome), "class1", "class2")
),
multiclass =
as.factor(
c(rep("class1", 30), rep("class2", 30), rep("class3", 40))
),
event = c(rep(0, times = 30), rep(1, times = 70)),
time_to_event = rnorm(n = 100, mean = 10, sd = 2)
)
split_data <- tof_split_data(feature_tibble, split_method = "simple")
# train a regression model
regression_model <-
tof_train_model(
split_data = split_data,
predictor_cols = c(cd45, pstat5, cd34),
response_col = outcome,
model_type = "linear"
)
tof_get_model_y(regression_model)
#> [1] 2.18131337 2.71618791 3.41674410 2.19873696 4.60698357 3.45640330
#> [7] 4.52318725 7.12326360 1.08002714 4.24891165 2.49004649 3.04399719
#> [13] 2.57156276 3.38719275 2.30103202 4.55961844 0.93419244 4.11649387
#> [19] 4.92509667 5.25459536 5.74593523 0.70379981 5.28839839 3.65071043
#> [25] 2.63893940 4.17427446 4.02775621 5.50829798 2.01307916 5.23982856
#> [31] 5.40369864 3.09613212 4.16664916 2.80717349 4.49222674 2.69676189
#> [37] 4.22035488 4.78183453 4.12370897 4.50140322 5.45155291 3.65110189
#> [43] 2.06150909 2.08495268 3.27449472 2.88067453 4.41080465 0.49146365
#> [49] 4.30077930 3.67331846 2.76116875 2.50709995 2.92769019 4.32836041
#> [55] 5.08454992 2.45103350 1.94416598 5.38053521 1.51757669 3.99013660
#> [61] 5.04894469 1.20700151 0.06217509 5.05942445 2.35217156 3.43782027
#> [67] 0.48607583 1.84190021 1.48363474 1.85867812 3.09439600 3.60260380
#> [73] 3.86377993 3.30276080 4.49705065 0.73738319 4.53241270 4.40932752
#> [79] 5.04466729 5.54501484 0.85021428 4.53628988 1.60027551 4.47834839
#> [85] 4.67356897 -0.39676503 3.75801020 2.75284593 4.95718501 6.19950991
#> [91] 5.28985884 2.10256261 0.90173267 4.31308665 2.30004056 3.91640613
#> [97] 2.11186677 2.58497399 3.09276303 6.90309895