library(targets)
library(tidymodels)

Specifications for the ridge model

```{targets specRidgeResponse, tar_simple = TRUE} linear_reg( penalty = tune(), mixture = 0 #Changed from 1 to 0 ) |> set_engine("glmnet")

## Grid search to determine the best value for the penaly parameter (i.e. amount of regularization)

```{targets gridRidgeResponse, tar_simple = TRUE }
  dials::grid_regular(dials::penalty(),
    levels = 100
  )

Recipe for the model

Preprocessing steps include normalization, a Yeo-Johnson transformation for variables with many zero values and principal components analysis for the variables that are highly correlated.

Predictors used here are restricted to those that can be derived from just a medication infusion device and physiolgical monitoring device. Clinical predictors (age, gender, medical conditions etc) were not included.

```{targets recRidgeResponse, tar_simple = TRUE } recipe(sbp_post ~ sbp_pre + nitro_diff_mcg + total_nitro + n_nitro + nitro_time + sbp_pre_mean_60 + sbp_pre_sd_60 + pain_score + lag_nitro_diff + lag_sbp_diff, data = trainingResponse ) |> step_YeoJohnson( n_nitro, nitro_time, total_nitro, sbp_pre_sd_60, pain_score ) |> step_normalize( all_numeric_predictors() )|> step_pca( sbp_pre_mean_60, sbp_pre ) |> step_interact(terms = ~lag_nitro_diff:lag_sbp_diff) #This is the interaction term

## Run the model using 5-fold cross-validation

```{targets workflowRidgeResponse, tar_simple = TRUE}
workflow()|>
    add_recipe(recRidgeResponse)|>
    add_model(specRidgeResponse)

{targets tuningRidgeResponse, tar_simple = TRUE} tune_grid( workflowRidgeResponse, resamples = foldsFiveResponse, grid = gridRidgeResponse )



awconway/eicu_nitro documentation built on Feb. 21, 2022, 4:35 p.m.