dispersion <- function(y, mu, w, df, family) {
sumw = sum(w)
dev.resid.values = family$dev.resids(y, mu, w)
if (family$family %in% c("poisson", "binomial")) {dispersion = 1}
else if (sumw > 0) {dispersion = sum(resid) / (sumw-df)}
else {dispersion = 1}
return(dispersion)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.