[R] lasso constraint

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue Mar 27 19:54:03 CEST 2012


On Tue, Mar 27, 2012 at 10:35 AM, yx78 <yangxu78 at gmail.com> wrote:
> In the package lasso2, there is a Prostate Data. To find coefficients in the
> prostate cancer example we could impose L1 constraint on the parameters.
> code is:
> data(Prostate)
>  p.mean <- apply(Prostate, 5,mean)
>  pros <- sweep(Prostate, 5, p.mean, "-")
>  p.std <- apply(pros, 5, var)
>  pros <- sweep(pros, 5, sqrt(p.std),"/")
>  pros[, "lpsa"] <- Prostate[, "lpsa"]
> l1ce(lpsa ~  . , pros, bound = 0.44)
> I can't figure out what dose 0.44 come from. On the paper it said it was
> from  generalized cross-validation and it is the optimal choice.

Yes, this is exactly how the "optimal" value for bound would be found.

Using the lasso2 package, you'll likely have to do a grid search over
possible values for `bound` in a cross validation setting and you pick
the one that fits the model best on the held out data over all your CV

If I were you, I'd use the glmnet package since it can calculate the
entire regularization path w/o having to do a grid search over the
bound (or lamda), making cross validation easier.

If you're confused about how you might use cross validation to find
the optimal value of the parameter(s) of the model you are building,
then it's time to pull yourself away from the keyboaRd and start doing
some reading, or (as Bert will likely tell you) consult your local


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list