Description Usage Format Details Source References Examples
Data from Fair (1978). Although Fair used a tobit model with the data, the outcome measure can be modeled as a count. In fact, Greene (2003) modeled it as Poisson, but given the amount of overdispersion in the data, employing a negative binomial model is an appropriate strategy. The data is stored in the affairs data set. Naffairs is the response variable, indicating the number of affairs reported by the participant in the past year.
1 |
A data frame with 601 observations on the following 18 variables.
naffairs
number of affairs within last year
kids
1=have children;0= no children
vryunhap
(1/0) very unhappily married
unhap
(1/0) unhappily married
avgmarr
(1/0) average married
hapavg
(1/0) happily married
vryhap
(1/0) very happily married
antirel
(1/0) anti religious
notrel
(1/0) not religious
slghtrel
(1/0) slightly religious
smerel
(1/0) somewhat religious
vryrel
(1/0) very religious
yrsmarr1
(1/0) >0.75 yrs
yrsmarr2
(1/0) >1.5 yrs
yrsmarr3
(1/0) >4.0 yrs
yrsmarr4
(1/0) >7.0 yrs
yrsmarr5
(1/0) >10.0 yrs
yrsmarr6
(1/0) >15.0 yrs
rwm5yr is saved as a data frame. Count models use naffairs as response variable. 0 counts are included.
Fair, R. (1978). A Theory of Extramarital Affairs, Journal of Political Economy, 86: 45-61. Greene, W.H. (2003). Econometric Analysis, Fifth Edition, New York: Macmillan.
Hilbe, Joseph M (2011), Negative Binomial Regression, Cambridge University Press Hilbe, Joseph M (2009), Logistic regression Models, Chapman & Hall/CRC
1 2 3 4 5 6 7 8 9 10 11 | data(affairs)
glmaffp <- glm(naffairs ~ kids + yrsmarr2 + yrsmarr3 + yrsmarr4 + yrsmarr5,
family = poisson, data = affairs)
summary(glmaffp)
exp(coef(glmaffp))
require(MASS)
glmaffnb <- glm.nb(naffairs ~ kids + yrsmarr2 + yrsmarr3 + yrsmarr4 + yrsmarr5,
data=affairs)
summary(glmaffnb)
exp(coef(glmaffnb))
|
Loading required package: msme
Loading required package: MASS
Loading required package: lattice
Loading required package: sandwich
Call:
glm(formula = naffairs ~ kids + yrsmarr2 + yrsmarr3 + yrsmarr4 +
yrsmarr5, family = poisson, data = affairs)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.9668 -1.9364 -1.5412 -0.9274 7.0799
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.34038 0.09182 3.707 0.00021 ***
kids 0.28809 0.09371 3.074 0.00211 **
yrsmarr2 -1.18431 0.17058 -6.943 3.84e-12 ***
yrsmarr3 -0.45650 0.10536 -4.333 1.47e-05 ***
yrsmarr4 -0.11823 0.09896 -1.195 0.23220
yrsmarr5 0.03119 0.09912 0.315 0.75303
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 2925.5 on 600 degrees of freedom
Residual deviance: 2797.0 on 595 degrees of freedom
AIC: 3303
Number of Fisher Scoring iterations: 7
(Intercept) kids yrsmarr2 yrsmarr3 yrsmarr4 yrsmarr5
1.4054793 1.3338755 0.3059569 0.6334955 0.8884915 1.0316802
Call:
glm.nb(formula = naffairs ~ kids + yrsmarr2 + yrsmarr3 + yrsmarr4 +
yrsmarr5, data = affairs, init.theta = 0.1188516427, link = log)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.8253 -0.8155 -0.7611 -0.6002 1.9331
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.33180 0.31247 1.062 0.28830
kids 0.27309 0.31104 0.878 0.37995
yrsmarr2 -1.19445 0.42962 -2.780 0.00543 **
yrsmarr3 -0.38936 0.35449 -1.098 0.27205
yrsmarr4 -0.08137 0.38166 -0.213 0.83116
yrsmarr5 0.07220 0.40464 0.178 0.85838
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for Negative Binomial(0.1189) family taken to be 1)
Null deviance: 344.44 on 600 degrees of freedom
Residual deviance: 332.40 on 595 degrees of freedom
AIC: 1504.6
Number of Fisher Scoring iterations: 1
Theta: 0.1189
Std. Err.: 0.0127
2 x log-likelihood: -1490.6260
(Intercept) kids yrsmarr2 yrsmarr3 yrsmarr4 yrsmarr5
1.3934701 1.3140193 0.3028717 0.6774934 0.9218498 1.0748732
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.