[R] lars with weights do not match with lm output

From: Young Cho <young.stat_at_gmail.com>
Date: Thu, 13 Mar 2008 08:40:19 -0700

I got my posting bounced and sorry if I accidentally post twice. 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)

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

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

(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 miss and how to correctly do lasso with weights? Thanks a lot for any advice.


        [[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 - 20:01:27 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 - 20:30:22 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.

list of date sections of archive