title: Error while using Adaptive Lasso Function with Boot
body: <p>I currently have the below code. The function works when running outside of the boot() function, but when using the boot() function, it provides the error </p>
  
  <blockquote>
    <p>Error in t.star[r, ] &lt;- res[[r]] :    number of items to replace is
    not a multiple of replacement length.</p>
  </blockquote>
  
  <p>When I use the boot() function, lower values of R allow the function to run properly. Is there something I need to add to my function to ensure that I do not continue to receive this error?</p>
  
  <pre><code>
      alassoOLS_ydot_n10_fn &lt;- function(data,index){ #index is the bootstrap sample index
        x &lt;- data[index,-1]
        y &lt;- data[index,1]
        cv.out &lt;- cv.glmnet(x,y,alpha=1,nfolds=10, penalty.factor = 1 / abs(best_ridge_coef.ydot.n10)) #alpha=1, lasso
        bestlam &lt;- cv.out$lambda.min #the best lambda chosen by CV
        lasso.mod &lt;- glmnet(x,y,alpha=1,lambda=bestlam, penalty.factor = 1 / abs(best_ridge_coef.ydot.n10))
        coef &lt;- as.vector(coef(lasso.mod))[-1]
        coef_nonzero &lt;- coef != 0
        ls.obj &lt;- lm(y ~x[, coef_nonzero, drop = FALSE])
        ls_coef &lt;- (ls.obj$coefficients)[-1]
        return(ls_coef)
      }
  
  boot(ydot_matrix_n10,alassoOLS_ydot_n10_fn,R=500)
  
  </code></pre>