From: Young Cho <young.stat_at_gmail.com>

Date: Thu, 13 Mar 2008 08:30:41 -0700

X$z = X$z / sum(X$z) # this is not necessary. fit1 = lars(as.matrix(X[,2:6])*matrix(sqrt(X[,7]),10,5),as.matrix (X[,1])*sqrt(X[,7]))

fit2 = lm(y~.-z,data=X,weights=z)

coef(fit1,mode='fraction',s=1)

fit2

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 13 Mar 2008 - 15:52:16 GMT

Date: Thu, 13 Mar 2008 08:30:41 -0700

I have been looking at 'lars' pkg and got puzzled by the behavior of
function 'lars'. I want to do weighted lasso regression and can't get a
match from lars output with lm output. Here is an example:

y = rnorm(10) x = matrix(runif(50),nrow=10) X = data.frame(y,x) z = runif(10) X = data.frame(y,x,z)

X$z = X$z / sum(X$z) # this is not necessary. fit1 = lars(as.matrix(X[,2:6])*matrix(sqrt(X[,7]),10,5),as.matrix (X[,1])*sqrt(X[,7]))

fit2 = lm(y~.-z,data=X,weights=z)

coef(fit1,mode='fraction',s=1)

fit2

I got this:

> coef(fit1,mode='fraction',s=1)

X1 X2 X3 X4 X5
-2.8603082 -0.8303739 0.1064474 3.6563283 2.8342368

*> fit2
*

Call:

lm(formula = y ~ . - z, data = X, weights = z)

Coefficients:

(Intercept) X1 X2 X3 X4
X5

-0.4227 -2.4817 -0.7105 -0.2611 2.6908 2.0295

Shouldn't they match? If not, what did I do wrong and how to correctly do lasso with weights? Thanks a lot.

Young

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 13 Mar 2008 - 15:52:16 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Thu 13 Mar 2008 - 16:30:21 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*