search for: predict_matrix

Displaying 2 results from an estimated 2 matches for "predict_matrix".

2013 Jul 06
1
problem with BootCV for coxph in pec after feature selection with glmnet (lasso)
...values are missing in newdata!? Here are the relevant sections of the code: trainSet <- na.omit (dataset) #creat Y (survival matrix) for glmnet surv_obj <- Surv(trainSet$time,trainSet$status) ## tranform categorical variables into binary variables with dummy for trainSet predict_matrix <- model.matrix(~ ., data=trainSet, contrasts.arg = lapply (trainSet[,sapply(trainSet, is.factor)], contrasts, contrasts=FALSE)) ## remove the statu/time variables from the predictor matrix (x) for glmnet predict_matrix <- subset (predict_matrix, sele...
2013 Sep 13
1
Creating dummy vars with contrasts - why does the returned identity matrix contain all levels (and not n-1 levels) ?
Hello, I have a problem with creating an identity matrix for glmnet by using the contrasts function. I have a factor with 4 levels. When I create dummy variables I think there should be n-1 variables (in this case 3) - so that the contrasts would be against the baseline level. This is also what is written in the help file for 'contrasts'. The problem is that the function