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]]


