将rxGlm转换为GLM时出错 [英] Error converting rxGlm to GLM

查看:153
本文介绍了将rxGlm转换为GLM时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将rxGlm模型转换为普通glm模型时遇到问题.每次尝试隐藏模型时,都会出现相同的错误:

I'm having a problem converting rxGlm models to normal glm models. Every time I try and covert my models I get the same error:

Error in qr.lm(object) : lm object does not have a proper 'qr' component.
Rank zero or should not have used lm(.., qr=FALSE).

这是一个简单的例子:

cols <- colnames(iris)
vars <- cols[!cols %in% "Sepal.Length"]
form1 <- as.formula(paste("Sepal.Length ~", paste(vars, collapse = "+")))

rx_version <- rxGlm(formula = form1,
                    data = iris,
                    family = gaussian(link = 'log'),
                    computeAIC = TRUE)

# here is the equivalent model with base R
R_version <- glm(formula = form1,
                 data = iris,
                 family = gaussian(link = 'log'))


summary(as.glm(rx_version)) #this always gives the above error

我似乎找不到在rxGlm公式中指定的"qr"分量(我假设这与矩阵分解有关).

I cant seem to find this "qr" component (I'm assuming this is related to matrix decomposition) to specify in rxGlm formula.

还有其他人处理吗?

推荐答案

rxGlm对象没有qr组件,并且转换为glm对象也不会创建一个.这是有意为之的,因为计算模型矩阵的QR分解需要将完整的数据集存储在内存中,这将不利于使用rx *函数的目的.

rxGlm objects don't have a qr component, and converting to a glm object won't create one. This is intentional, as computing the QR decomposition of the model matrix requires the full dataset to be in memory which would defeat the purpose of using the rx* functions.

as.glm实际上意味着更多用于支持通过PMML进行模型导入/导出.您想要执行的大多数操作都可以使用rxGlm对象完成,而无需进行转换.例如,rxGlm将系数std误差作为拟合的一部分进行计算,而之后无需qr分量.

as.glm is really meant more for supporting model import/export via PMML. Most of the things that you'd want to do can be done with the rxGlm object, without converting. Eg rxGlm computes the coefficient std errors as part of the fit, without requiring a qr component afterwards.

这篇关于将rxGlm转换为GLM时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆