Hi Jiim, Thanks . I want to do the following:

1. each time I need to drop one column, say first column 1 from matrix   X.
2 then take out row 1 of the remainning  matrix and that row becomes
response (y)
3. do lasso regression on remaining X to y.
4. store the coefficients

Similarly, in next run

 1.  I need to drop 2nd column,  from matrix   X.
2 then take out row 2 of the remainning  matrix and that row becomes
response (y)
3. do lasso regression on remaining X ( in example: X2to y.)
4. store the coefficients


repeat
On Sat, Jun 13, 2009 at 7:19 PM, jim holtman <jholtman@gmail.com> wrote:

> It is not exactly clear what you want to iterate on.  What is going to be
> changing each time through the loop?
>
>   On Sat, Jun 13, 2009 at 10:09 AM, Alex Roy <alexroy2008@gmail.com>wrote:
>
>>  Dear all,
>>              I want to do the following process as a loop ( to run
>> automatically with dimension of X, here 50). How can I do that? Your
>> cooments will be highly appreciable.
>>
>> Alex
>>
>>
>> *# Code:*
>>
>> library(lars)
>> library(chemometrics)
>>
>>  X<-matrix(rnorm(2500),ncol=50)
>>  dim(X)
>> # [1] 50 50
>> X1<-X[,2:dim(X)[2]] # I have taken out first column
>>  dim(X1)
>> #[1] 50 49
>>  X2<-X1[2:dim(X1)[1],] # new X2 is constructed
>>  dim(X2)
>> #[1] 49 49
>>  y<-as.matrix(X1[1,]) # Now first row of the X1 acts  a response vector
>> dim(y)
>> # [1] 49  1
>>
>> # application of LASSO regression where y is response and X2 is a design
>> matrix
>>
>> data1<-data.frame(y,X2=I(X2))
>>
>> lasso_res=lassoCV(y~X2,data=data1,K=10,fraction=seq(0.1,1,by=0.1),use.Gram=FALSE)
>> # to get optimum value of Cross Validation
>> lasso_coef=lassocoef(y~X2,data=data1,sopt=lasso_res$sopt,use.Gram=FALSE)
>> #
>> to get the coefficients
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

	[[alternative HTML version deleted]]


