Dear R users:

Recently, I learn to use penalized logistic regression. Two packages
(penalized and glmnet) have the function of lasso.
So I write these code. However, I got different results of coef. Can someone
kindly explain.

# lasso using penalized
library(penalized)
pena.fit2<-penalized(HRLNM,penalized=~CN+NoSus,lambda1=1,model="logistic",standardize=TRUE)
pena.fit2
coef(pena.fit2)
opt<-optL1(HRLNM,penalized=~CN+NoSus,fold=5)
opt$lambda
coef(opt$fullfit)
prof<-profL1(HRLNM,penalized=~CN+NoSus,fold=opt$fold,steps=20)
plot(prof$lambda, prof$cvl, type="l")
plotpath(prof$fullfit)
pena.fit2<-penalized(HRLNM,penalized=~CN+NoSus,lambda1=opt$lambda,model="logistic",standardize=TRUE,steps=20)
plotpath(pena.fit2)
pena.fit2<-penalized(HRLNM,penalized=~CN+NoSus,lambda1=opt$lambda,model="logistic",standardize=TRUE)
coef(pena.fit2)


#lasso using gamnet
library(glmnet)
factors<-matrix(c(CN,NoSus),ncol=2)
colnames(factors)<-c("CN","NoSus")
glmn.fit2<-glmnet(x=factors,y=HRLNM,family="binomial")
cvglmnet<-cv.glmnet(x=factors,y=HRLNM,family="binomial",nfolds=5)
plot(cvglmnet)
cvglmnet$lambda.min
which(cvglmnet$lambda==cvglmnet$lambda.min)
glmn.fit2<-glmnet(x=factors,y=HRLNM,family="binomial",lambda=cvglmnet$lambda.min)
coef(glmn.fit2)



Thanks a lot

btw: how to calculate the C.I. of coefs?


*Yao Zhu*
*Department of Urology
Fudan University Shanghai Cancer Center
Shanghai, China*

	[[alternative HTML version deleted]]

