缩短R-revoScaleR rxGLM()中函数调用的长度

缩短R-revoScaleR rxGLM()中函数调用的长度,r,glm,revoscaler,R,Glm,Revoscaler,目前,我正在使用R在大型数据集上创建一些GLM模型。由于它的大小,我在revoScaleR包中使用了rxGlm()函数——它比基本的glm()函数运行得快得多 我将所有的函数调用都保存在一个R脚本中,以便以后可以重现我的工作—审计跟踪,等等 我的函数调用非常长,因为我有很多因素(~50)。它们看起来都是这样的: rxGlm_C <- rxGlm(Dependent.Variable ~ 1 + Factor 1 +

目前,我正在使用R在大型数据集上创建一些GLM模型。由于它的大小,我在revoScaleR包中使用了rxGlm()函数——它比基本的glm()函数运行得快得多

我将所有的函数调用都保存在一个R脚本中,以便以后可以重现我的工作—审计跟踪,等等

我的函数调用非常长,因为我有很多因素(~50)。它们看起来都是这样的:

rxGlm_C <- rxGlm(Dependent.Variable ~
               1 +
               Factor 1 +
               Factor 2 +
               Factor 3 +
                     ...........
               Factor N,
             family = tweedie(var.power = 1.5, link.power = 0),
             data = myDataFrame,
             pweights = "Weight.Variable",
)

rxGlm_C有两种情况。如果您使用的是
myDataFrame
中的所有变量,那么您只需编写

rxGlm(Dependent.Variable ~ .,
      family = tweedie(var.power = 1.5, link.power = 0),
      data = myDataFrame, pweights = "Weight.Variable")
对于完整的模型,然后,比如

rxGlm(Dependent.Variable ~ . - Factor13,
      family = tweedie(var.power = 1.5, link.power = 0),
      data = myDataFrame, pweights = "Weight.Variable")
删除
因子13

如果你没有使用所有的变量,那么你可以保存完整的公式,比如

frml <- y ~ Factor1 + Factor2 + Facto3
但是请注意,在这种情况下,
表示“与
frml
中相同的右侧”,而不是前一个选项中的“所有变量”


另外,如果是后一个选项,您可以使用
paste
formula

帮助构建完整公式,谢谢。对于后一个选项,我可以使用如下语法:update(frml,~.-Factor2)?(导致y~因子1)@Alan,是的,绝对是。我应该补充一点,当使用
update
时,点不再表示“所有变量”。相反,它是:与
frml
中相同的右侧,然后您可以添加或减去任何变量。
update(frml, ~ . - Factor3)
# y ~ Factor1 + Factor2