I try to run multiple linear regressions on large data sets. Basically biglm works fine. Now I try to find a convenient way to create my formula automatically, using a vector, containing my dependent variables and a string, containing the rest of my formula. Both strings together are my formula. This works fine for lm() but leads to an error using biglm()
reproduceable example:
library(biglm)
data<-data.frame(av=c(1,2,3,4,5,6,5,4,5,5),
uv1=c(1,2,5,5,4,56,3,4,5,6),
uv2=c(4,5,8,3,2,7,6,2,4,6),
weight=c(1.2,1,1,1,1,1,1,1,0,0))
dependent<-c('av')
independent<-'~ uv1 + uv2 -1'
formula<-paste(dependent[1],independent)
#this works fine
lm_standard<-lm(formula,data=data,weights=weight)
#and this works fine
lm_big1<-biglm(av~uv1+uv2-1,data=data,weights=~weight)
#and here comes the error
lm_big<-biglm(formula,data=data,weights=~weight)
Error: $ operator is invalid for atomic vectors
I don't use as.formula(), because I don't know how to add the -1 to the as.formula() object. My workaround for the as.formula() problem leads to the error message. Is it possible to a) use as.formula() with a missing intercept or b) paste the formula in a way, biglm() can understand?