1

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).

Here's a simple example:

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

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

Anyone else dealt with this?

  • Why do you want to convert it? – Niels Berglund Aug 24 '17 at 12:19
  • Can u specify the version of `RevoScaleR` – akrun Aug 24 '17 at 12:25
  • @NielsBerglund I wish to convert it in order to use it with the Broom package (it makes dealing with the coefficient outputs a lot easier especially for plotting) – Serban Dragne Aug 24 '17 at 12:46
  • @akrun its 9.0.1 – Serban Dragne Aug 24 '17 at 12:46
  • Perhaps you could update to 9.1 and then check if you still gets the same error – akrun Aug 24 '17 at 14:55
  • @akrun: You are still getting the same issue with 9.1. It seems to be an issue with some underlying conversion from rxLm/rxGlm to lm/glm when using some functions like summary, or tidy, etc. I can do a `glm_version <- as.glm(rx_version)` without an issue, but if I then do `summary(glm_version)` I get the same error as the OP. I do not know enough about RevoScaleR to understand what is going wrong. – Niels Berglund Aug 24 '17 at 17:04
  • @NielsBerglund Nice - you saved me having to bug the admin to update R :) – Serban Dragne Aug 24 '17 at 17:11
  • @NielsBerglund Thanks, I don't have the newest version on server. So, couldn't check it. – akrun Aug 24 '17 at 21:31

1 Answers1

1

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 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.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
  • Thanks again - I think Broom is invoking the Summary function which is where it all goes wrong. I think I can create a workaround though, but its nice to know its not an explicit bug. – Serban Dragne Aug 25 '17 at 14:27