将rxGlm转换为GLM时出错 [英] Error converting rxGlm to 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屋!