I am trying to write a function to do Lasso regression on my data:
mylasso<-function(data,k){
gcvs<-rep(0,k)
for (i in 1:k){
temp.lasso<-gl1ce(as.formula(paste("y ~
",paste(colnames(data)[-1],collapse='+'))),
data=data.frame(data),family=binomial(),bound=i/k)
gcvs[k]<-gcv(temp.lasso)[2]
}
return(gcvs)
}
as I execute my function with some data, I get these messages:
Warning messages:
1: `x' and `y' have different environments; x's is used in:
merge.formula(formula,
sweep.out)
...
But as I execute commands within this simple function line by line, no
warnings are produced. I suspect the data argument should be treated
specially but don't know how to. Can anybody give me a solution or hint?
Thanks a lot,
Mike
[[alternative HTML version deleted]]