I fitted a Poisson model using svyglm in R. The null and residual deviances from the svyglm model are as expected. For the degrees of freedom however, I get confusing results. With a sample size of n=4526 and 7 parameters in the model (including the intercept), I expected a null degrees of freedom of 4526-1 = 4525, and a residual degrees of freedom of 4526-7 = 4519. This is exactly what I got with the glm model. The svyglm gives me the expected degrees of freedom for the null (4525) but not the residual. Could someone please explain what is happening here?

For simplicity, I am stripping down the output to the most critical elements:

#OUTPUT FROM SVYGLM. Degrees of Freedom: 4525 Total (i.e. Null); 33 Residual (1138 observations deleted due to missingness) Null Deviance: 1189 Residual Deviance: 770.7 AIC: NA

#OUTPUT FROM GLM. Degrees of Freedom: 4525 Total (i.e. Null); 4519 Residual (9433 observations deleted due to missingness) Null Deviance: 1339 Residual Deviance: 945.7 AIC: 1404

The respective codes used were:

svyglm(rhs, design = svyobject, family=quasipoisson(), rescale= TRUE)
glm(formula = rhs, family = poisson(), data = s)

Where rhs represents the equation ever_ecig ~ relevel(as.factor(current_shisha), ref = "0") + relevel(as.factor(saw_smoking), ref = "0") + relevel(as.factor(current_cigarette), ref = "0") + relevel(as.factor(enjoy), ref = "0") + relevel(as.factor(favor_ban_indoor), ref = "0") + relevel(as.factor(susceptible), ref = "0")

  • $\begingroup$ I don't know the answer, but when I'm investigating issues with things like svyglm, I set the weights to 1, and make each case it's own id. Then the results should be identical. Then I can start changing things back, and this (sometimes) identifies the issue. $\endgroup$ Commented May 26, 2022 at 20:33

1 Answer 1


You don't say anything about your survey design. The residual df for a svyglm object is the design df plus one, minus the number of parameters estimated. From the code

    g$df.residual <- degf(design) + 1 - length(coef(g)[!is.na(coef(g))])

The design df is (number of PSUs minus number of strata) for the subpopulation being analysed, if design information is given.

If replicate weights are given instead, the design df is one less than the column rank of the matrix of replicate weights.

From the help page for svyglm: If df.resid is not specified the df for the null model is computed by degf and the residual df computed by subtraction. This is recommended by Korn and Graubard and is correct for PSU-level covariates but is potentially very conservative for individual-level covariates.

  • $\begingroup$ Many thanks for your detailed response. Greatly appreciated. $\endgroup$
    – Ter
    Commented May 28, 2022 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.