Why is rxGlm not returning the same results as glm?

By default you will not get the same results from 'rxGlm' as you do from 'glm'.

You actually need to set the arguments 'dropFirst' to TRUE and 'dropMain' to FALSE as well to reproduce the results from glm, because 
RevoScaleR will use SAS contrasts by default rather than R's default contrasts.

 

Here is some sample data and code I used in testing this issue that illustrates how to get the two functions to produce matching results:

basictestdata <- data.frame( 
 Factor1 = as.factor(c(1,1,1,1,2,2,2,2)), 
 Factor2 = as.factor(c(1,1,2,2,1,1,2,2)), 
 Discount = c(1,2,1,2,1,2,1,2), 
 Exposure = c(24000, 40000, 7000, 14000, 7500, 15000, 2000, 5600), 
 PurePrem = c(46,32,73,58,48,25,220,30))

GLM.1 <- glm(PurePrem ~ Factor1 * Factor2 - 1, 
 family = tweedie(var.power = 1.5, link.power = 0), 
 data = basictestdata, weights = Exposure 
 , offset = log(Discount))

rxGlm.1 <- rxGlm(PurePrem ~ Factor1 * Factor2 - 1 + offset(log(Discount)), 
 family = rxTweedie(var.power = 1.5, link.power = 0), 
 data = basictestdata, fweights = "Exposure", dropFirst = TRUE, dropMain = FALSE)

coef(GLM.1) 
coef(rxGlm.1)
Eigenschappen

Artikel-id: 3104215 - Laatst bijgewerkt: 29 okt. 2015 - Revisie: 1

Feedback