Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull out Dispersion parameter in R

Tags:

parameters

r

    Call:
glm(formula = Y1 ~ 0 + x1 + x2 + x3 + x4 + x5, family = quasibinomial(link = cauchit))

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.5415   0.2132   0.3988   0.6614   1.8426  

Coefficients:
   Estimate Std. Error t value Pr(>|t|)    
x1  -0.7280     0.3509  -2.075  0.03884 *  
x2  -0.9108     0.3491  -2.609  0.00951 ** 
x3   0.2377     0.1592   1.494  0.13629    
x4  -0.2106     0.1573  -1.339  0.18151    
x5   3.6982     0.8658   4.271 2.57e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasibinomial family taken to be 0.8782731)

    Null deviance: 443.61  on 320  degrees of freedom
Residual deviance: 270.17  on 315  degrees of freedom
AIC: NA

Number of Fisher Scoring iterations: 12

Here is the output from glm in R. Do you know a way to pull out Dispersion parameter which is 0.8782731 in this case, instead of just copy and paste. Thanks.

like image 430
huadaixia Avatar asked Apr 30 '14 19:04

huadaixia


People also ask

How do you calculate dispersion parameters?

The dispersion parameter φ is traditionally estimated by the maximum likelihood or method of moments approaches. Notably, when the sample variance exceeds the sample mean these methods give fairly good estimates for φ.

How do you check for over dispersion in R?

Over dispersion can be detected by dividing the residual deviance by the degrees of freedom. If this quotient is much greater than one, the negative binomial distribution should be used. There is no hard cut off of “much larger than one”, but a rule of thumb is 1.10 or greater is considered large.

What is the dispersion parameter in GLM?

Dispersion parameter Dispersion (variability/scatter/spread) simply indicates whether a distribution is wide or narrow. The GLM function can use a dispersion parameter to model the variability. However, for likelihood-based model, the dispersion parameter is always fixed to 1.

How is the dispersion parameter estimated in the function GLM NB?

By default, however, dispersion will be estimated by the summary() method, presumably leading to the value of 1271 you report. The underlying variance function would then be VAR[y] = 1271 * mu + 12.71 * mu^2 > Fitting a quasipoisson model also yields a large dispersion parameter > (1300).


1 Answers

You can extract it from the output of summary:

data(iris)
mod <- glm((Petal.Length > 5) ~ Sepal.Width, data=iris)
summary(mod)
# 
# Call:
# glm(formula = (Petal.Length > 5) ~ Sepal.Width, data = iris)
# 
# Deviance Residuals: 
#     Min       1Q   Median       3Q      Max  
# -0.3176  -0.2856  -0.2714   0.7073   0.7464  
# 
# Coefficients:
#             Estimate Std. Error t value Pr(>|t|)
# (Intercept)  0.38887    0.26220   1.483    0.140
# Sepal.Width -0.03561    0.08491  -0.419    0.676
# 
# (Dispersion parameter for gaussian family taken to be 0.2040818)
# 
#     Null deviance: 30.240  on 149  degrees of freedom
# Residual deviance: 30.204  on 148  degrees of freedom
# AIC: 191.28
# 
# Number of Fisher Scoring iterations: 2
summary(mod)$dispersion
# [1] 0.2040818

The str function in R is often helpful to solve these sorts of questions. For instance, I looked at str(summary(mod)) to answer the question.

like image 50
josliber Avatar answered Sep 19 '22 12:09

josliber