I am using the ranger package in caret to develop a random forest model to predict the risk of dying.
I am more interested in the model doing well at predicting those who end up dying, rather than being good at predicting those who live.
Therefore, I am trying to add a case.weights statement to my model, but I am dumbfounded as to how to to implement it, as I am very new to R.
So far, my code looks like this:
set.seed(40) control.data <- trainControl(method= "cv", numer=5, sampling ="up", verboseIter = TRUE, classProbs = TRUE) rfGrid <- expand.grid( .mtry = 2:6, .splitrule = "gini", .min.node.size = c(250,500)) fit.dataup <- train(mort_30 ~ C_SEX+V_AGE+Hemoglobin,Thrombocytes+Leukocytes+CRP, data = data.train, method = "ranger", max.depth = 5, num.trees= 1000, trControl = control.data, tuneGrid = rfGrid, importance = "impurity", verbose = TRUE)
I have tried using both 'case.weights' and 'weights' in my train(), but no matter how I write it up, I cant get it to work.
Which syntax do I have to use? Let's say I want the "dead" cases to be weighted 2:1 to my "alive cases".
Thank you so much in advance!