Last data update: 2014.03.03

R: ships
shipsR Documentation

ships

Description

Data set used in McCullagh & Nelder (1989), Hardin & Hilbe (2003), and other sources. The data contains values on the number of reported accidents for ships belonging to a company over a given time period. When a ship was constructed is also recorded.

Usage

data(ships)

Format

A data frame with 40 observations on the following 7 variables.

accident

number of shipping accidents

op

1=ship operated 1975-1979;0=1965-74

co.65.69

ship was in construction 1965-1969 (1/0)

co.70.74

ship was in construction 1970-1974 (1/0)

co.75.79

ship was in construction 1975-1979 (1/0)

service

months in service

ship

ship identification : 1-5

Details

ships is saved as a data frame. Count models use accident as the response variable, with log(service) as the offset. ship can be used as a panel identifier.

Source

McCullagh and Nelder, 1989.

References

Hilbe, Joseph M (2007, 2011), Negative Binomial Regression, Cambridge University Press Hilbe, Joseph M (2009), Logistic Regression Models, Chapman & Hall/CRC Hardin, JW and JM Hilbe (2001, 2007), Generalized Linear Models and Extensions, Stata Press McCullagh, P.A, and J. Nelder (1989), Generalized Linear Models, Chapman & Hall

Examples

data(ships)
glmshp <- glm(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
              family=poisson, data=ships)
summary(glmshp)
exp(coef(glmshp))
library(MASS)
glmshnb <- glm.nb(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
                   data=ships)
summary(glmshnb)
exp(coef(glmshnb))
## Not run: 
library(gee)
shipgee <- gee(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
              data=ships, family=poisson, corstr="exchangeable", id=ship)
summary(shipgee)

## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(COUNT)
Loading required package: msme
Loading required package: MASS
Loading required package: lattice
Loading required package: sandwich
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/COUNT/ships.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ships
> ### Title: ships
> ### Aliases: ships
> ### Keywords: datasets
> 
> ### ** Examples
> 
> data(ships)
> glmshp <- glm(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
+               family=poisson, data=ships)
> summary(glmshp)

Call:
glm(formula = accident ~ op + co.70.74 + co.75.79 + offset(log(service)), 
    family = poisson, data = ships)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.3433  -0.8383  -0.4082   1.0174   3.9196  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -6.5567     0.0883 -74.254  < 2e-16 ***
op            0.4667     0.1181   3.953 7.72e-05 ***
co.70.74      0.6001     0.1213   4.946 7.57e-07 ***
co.75.79      0.2338     0.1941   1.205    0.228    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 146.33  on 33  degrees of freedom
Residual deviance:  89.51  on 30  degrees of freedom
  (6 observations deleted due to missingness)
AIC: 195.38

Number of Fisher Scoring iterations: 5

> exp(coef(glmshp))
(Intercept)          op    co.70.74    co.75.79 
0.001420603 1.594723252 1.822341449 1.263439379 
> library(MASS)
> glmshnb <- glm.nb(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
+                    data=ships)
> summary(glmshnb)

Call:
glm.nb(formula = accident ~ op + co.70.74 + co.75.79 + offset(log(service)), 
    data = ships, init.theta = 4.432394106, link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.9662  -0.8278  -0.4183   0.2531   2.8818  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -6.2096     0.2264 -27.425   <2e-16 ***
op            0.3338     0.2678   1.247   0.2125    
co.70.74      0.5848     0.2670   2.190   0.0285 *  
co.75.79      0.0581     0.3817   0.152   0.8790    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for Negative Binomial(4.4324) family taken to be 1)

    Null deviance: 43.749  on 33  degrees of freedom
Residual deviance: 37.191  on 30  degrees of freedom
  (6 observations deleted due to missingness)
AIC: 173.8

Number of Fisher Scoring iterations: 1


              Theta:  4.43 
          Std. Err.:  2.20 

 2 x log-likelihood:  -163.80 
> exp(coef(glmshnb))
(Intercept)          op    co.70.74    co.75.79 
0.002010134 1.396312812 1.794574129 1.059820297 
> ## Not run: 
> ##D library(gee)
> ##D shipgee <- gee(accident ~ op + co.70.74 + co.75.79 + offset(log(service)),
> ##D               data=ships, family=poisson, corstr="exchangeable", id=ship)
> ##D summary(shipgee)
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>