Hello, This is a question motivated by curiosity, not a pressing problem. Any responses are much appreciated! In the following code, function reg1 calls glm with a formula object while reg2 uses a string. In both cases, glm works; however, in the second case, the add1 function fails with the following message: "Error in eval(predvars, data, env) : invalid 'envir' argument." Any insight into what is going on "under the hood"?
Many thanks, --Krishna x1 = rnorm(100) x2 = rnorm(100) x3 = rnorm(100) y = x1 + 2*x2 + 3*x3 + 0.05*rnorm(100) d = data.frame(y,x1,x2,x3) xset = paste("x",1:3,sep="") reg1<-function(dep,cand,data){ f = paste(dep,"~1",sep="") reg = glm(as.formula(f),family="gaussian",data) add = add1(reg,cand,test="F") } reg2<-function(dep,cand,data){ f = paste(dep,"~1",sep="") reg = glm(f,family="gaussian",data) add = add1(reg,cand,test="F") } r1 = reg1("y",xset,d) r2 = reg2("y",xset,d) [[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 and provide commented, minimal, self-contained, reproducible code.