I am getting very different results for a negative binomial model between R and SAS. Can you please suggest as to why is this happening? I am not able to add a csv file used as the data.
R script:
NB_Total<- glm.nb(Total_Crashes~Ln_AADT + offset(Ln_LaneMiles), weight = LANEMILES,
data=SPF_data_test)
summary(NB_Total)
R model estimates:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.962671 0.018471 -322.8 <2e-16 ***
Ln_AADT 0.738122 0.002503 294.9 <2e-16 ***
SAS script:
proc genmod data=V1 ;
weight lanemiles;
model Total_Crashes=ln_aadt /dist=NEGBIN link=log type3 offset=Ln_LaneMiles; run;
SAS model estimates:
Parameter Estimate Standard Error Pr > ChiSq
Intercept -10.3805 0.1657 <.0001
Ln_AADT 0.7443 0.0212 <.0001
Update: I checked with and without the weight factor on both R and SAS. Without the weight factor (i.e. only Ln_AADT as the covariate and Ln_LaneMiles as the offset), the results are identical (i.e. the parameter coefficients and standard errors are the same on both, and the inverse of the dispersion parameter on R is equal to the dispersion on SAS). However, the difference in results is happening when I am adding the weight factor. I could not find any documentation yet that explains how R includes the weight in the estimation.
and in the other I seeTotal_Crashes~Ln_AADT; isaccthe same asTotal_Crashes`? Also, those results don't look very different to me, especially w/o standard errors to provide a context of what "very different" might be from an estimation point of view. If you could expand on what the models are, in mathematical formulation, that might help too. – jbowman Jun 07 '22 at 03:01Coefficients: Estimate Std. Error z value Pr(>|z|)
– Meg Jun 07 '22 at 04:22(Intercept) -5.962671 0.018471 -322.8 <2e-16 *** Ln_AADT 0.738122 0.002503 294.9 <2e-16 ***
glmfunction they're prior weights - the scale (aka dispersion, unfortunately) parameter is divided by an observation weight at each occurrence in the likelihood formula (see MASS, Ch. 7, p 183). Note the scale parameter will be fixed at 1 for negative binomial models. Weights are defined the same way in the documentation of SAS'sGENMOD. Do you get a discrepancy using a different model - say a Poisson? or without using an offset? on on different data? fixing the dispersion parameter? – Scortchi - Reinstate Monica Jun 13 '22 at 23:43