diff --git a/dummy-vars-playground.R b/dummy-vars-playground.R index 3cdb681..7740ebe 100644 --- a/dummy-vars-playground.R +++ b/dummy-vars-playground.R @@ -8,17 +8,17 @@ rm(seqs) load(here("notebooks/data/nback_seqs.Rd")) -f <- as.formula("correct ~ n + stimulus + sl") +f <- as.formula("correct ~ n + vl + sl") -set.seed(42) +set.seed(654321) # 1. dummy vars # INPUTS : seqs # OUTPUTS: seqs.dmy -seqs <- seqs %>% filter(!is.na(correct) & !is.na(rt)) +seqs <- seqs %>% + drop_na(rt, correct, tl,sl) -# train.indices <- createDataPartition(seqs[[toString(f[[2]])]], p = .8, list =FALSE) @@ -45,22 +45,24 @@ ctrl <- trainControl(method="cv", number=5, classProbs=T, - sampling = "up", + verbose = T, +# sampling = "up", savePredictions = T, summaryFunction=twoClassSummary) # glmnet tune tune <- expand.grid(alpha = 0:1, lambda = seq(0, 0.01, length = 100)) +max_components <- n_distinct(attr(terms(f),"term.labels")) # pls tune -tune <- expand.grid(ncomp=1:20) +tune <- expand.grid(ncomp=1:max_components) model <- train(seqs.train.x, seqs.train.y, method = "pls", family = "binomial", metric = "ROC", - preProc = c("center", "scale"), + preProc = c("zv","center", "scale"), tuneGrid = tune, trControl = ctrl) @@ -72,6 +74,8 @@ confusionMatrix(seqs.test.y, seqs.test.observed_y) +plot(varImp(model, scale = F)) + library(pROC) roc(seqs.test.observed_y, @@ -86,6 +90,7 @@ print.auc.x = 55, lty = 1, of = "se", + boot.n = 200, ci = T)