Odd timing behavior with glmnet and n_lambda I'm using the glmnet package in R for a relatively large dataset (~50k observations, ~1000 predictors). I'm observing weird timing behavior for different values of the n_lambda parameter. Using cv.glmnet (5-fold CV done in parallel), smaller values of n_lambda correspond to larger execution times, as measured by 'elapsed' in system.time(). This is counter-intuitive to me because it seems that fewer values tried for the shrinkage parameter should correspond to shorter execution times. Am I missing something here?
Here's the function call:
system.time(cv.fit <- cv.glmnet(x=X, y=Y, 
                                type.measure="class",nfolds=5,
                                parallel=TRUE,standardize=FALSE,
                                nlambda=nlambda,family="multinomial"))

Here's the output:
[1] "Fitting the model..."
[1] "Number of lambda values: 10"
     user    system   elapsed 
    68544.863 2.764   31072.312 

[1] "Fitting the model..."
[1] "Number of lambda values: 100"
 user    system   elapsed 
 7061.27 4.360    24240.089 

[1] "Fitting the model..."
[1] "Number of lambda values: 500"
 user    system   elapsed 
 19164.12 26.773  8712.563 

 A: I cannot add a comment to your question so I will give it a shot with a guess. First of all, according to glmnet documentation, you have to add before your system call the following:
require(doMC)
registerDoMC(cores=4)

Secondly, you could try to run the same code without the parallel option. The result should be as intuition says, the larger the nlambda value the larger the execution time. With the parallel option, depending on the number of cores that you are using and according to the kernel time, which is increasing, it may happen that your program is spending more time with the parallel overhead that running the actual code. You should profile your code in order to investigate this (for example with Rprof)
Last, according to glmnet documentation:

A very small value of lambda.min.ratio will lead to a saturated fit
  in the nobs < nvars case. This is undefined for "binomial" and
  "multinomial" models, and glmnet will exit gracefully when the
  percentage deviance explained is almost 1

So even if you specify 100 lambda values, the code may be exiting before completing them all. I know that your dataset is not the nobs < nvars case, but maybe did you miss a "k" in the number of predictors?. Still you should take a closer look at the documentation regarding lambda.min, lambda.max and nlambda.
