trevb11 / ASD3-Coding

Commentary on ASD3 Coding Related Project
1 stars 2 forks source link

For Loop Over cv.glmnet Models #2

Open trevb11 opened 9 months ago

trevb11 commented 9 months ago

In the main branch code of this repository, the very last for loop

input.columns <- subset.with.autism.cols %>% select(-one_of(columns_to_exclude)) output.column <- one_hotted_data[["K2Q35A_1"]]

glm.model.list <- list() for(test_fold in 1:n.folds){ folded_data <- OneFold(input.columns, n.folds, test_fold) train.set <- folded_data[i = Set == "train"] train.inputs <- train.set[,input.columns] train.output <- train.set[,output.column] my.model.for.fold.k <- cv.glmnet(as.matrix(train.inputs), train.output) glm.model.list[[test_fold]] <- my.model.for.fold.k }

is returning the error

Error in [.data.table(train.set, , input.columns) : j (the 2nd argument inside [...]) is a single symbol but column name 'input.columns' is not found. Perhaps you intended DT[, ..input.columns]. This difference to data.frame is deliberate and explained in FAQ 1.1.

I intended for it to generate the models and store them in glm.model.list for each test_fold. I'm not sure what to try at this point.

tdhock commented 9 months ago

the error message says to try ..input.columns, did you try that?