Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Why is rxGlm not returning the same results as glm?


View products that this article applies to.

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)

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 3104215
Revision : 1
Created on : 1/7/2017
Published on : 10/29/2015
Exists online : False
Views : 62