10章 GLM

10.1 応答変数,説明変数,線形予測子

10.2 ロジスティック回帰

10.3 ポアソン回帰

In [4]:
options(repr.plot.width=4, repr.plot.height=4)
In [5]:
x <- seq(0, 15, 1)
freq <- dpois(x, lambda=5)
plot(x, freq, type="b", lwd=2)

式 10.6

$$ P(x) = \frac{\lambda^{x}}{x !}e^{-\lambda} $$

10.4 ロジスティック回帰の例

In [6]:
d <- read.csv("../samplecode/Rで学ぶ統計学入門図版作成用/table10-2.csv")
head(d)
dosedeadlive
1.00 1
1.30 1
1.70 1
2.20 1
2.40 1
2.80 1
In [7]:
str(d)
'data.frame':	17 obs. of  3 variables:
 $ dose: num  1 1.3 1.7 2.2 2.4 2.8 3.1 3.5 3.7 4.2 ...
 $ dead: int  0 0 0 0 0 0 1 1 0 0 ...
 $ live: int  1 1 1 1 1 1 0 0 1 1 ...
In [10]:
with(plot(dose, dead), data = d)

pp.147--148

データに live 列があるので,1-dead は必要ないはず. 実際,p.148 の出力例はlive列を使っている.

In [12]:
result <- glm(cbind(dead, live) ~ dose, family = binomial(logit), data = d)
summary(result)
Call:
glm(formula = cbind(dead, live) ~ dose, family = binomial(logit), 
    data = d)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.7000  -0.4663  -0.1727   0.5642   1.6872  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)  
(Intercept)  -5.6500     2.6630  -2.122   0.0339 *
dose          1.4524     0.6528   2.225   0.0261 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 23.508  on 16  degrees of freedom
Residual deviance: 13.564  on 15  degrees of freedom
AIC: 17.564

Number of Fisher Scoring iterations: 5
In [20]:
coef(result)
(Intercept)
-5.64999003540222
dose
1.45236254100564
In [21]:
names(coef(result))
  1. '(Intercept)'
  2. 'dose'
In [22]:
d.predicted <- data.frame(dose = seq(1, 6, 0.01))
d.predicted$dead <- with(
    1 / (1 + exp(-(coef(result)["(Intercept)"] + coef(result)["dose"] * dose))), 
    data=d.predicted)
summary(d.predicted)
      dose           dead        
 Min.   :1.00   Min.   :0.01481  
 1st Qu.:2.25   1st Qu.:0.08454  
 Median :3.50   Median :0.36199  
 Mean   :3.50   Mean   :0.42631  
 3rd Qu.:4.75   3rd Qu.:0.77708  
 Max.   :6.00   Max.   :0.95539  
In [23]:
with(data=d, plot(dose, dead))
with(data=d.predicted, lines(dose, dead))

10.5 ポアソン回帰の例

In [24]:
d2 <- read.csv("../samplecode/Rで学ぶ統計学入門図版作成用/table10-3.csv")
head(d2)
wtflw
17.31
18.52
20.50
21.23
20.80
21.51
In [25]:
str(d2)
'data.frame':	42 obs. of  2 variables:
 $ wt : num  17.3 18.5 20.5 21.2 20.8 21.5 22.1 22.7 22.6 23.3 ...
 $ flw: int  1 2 0 3 0 1 1 0 3 1 ...
In [26]:
summary(d2)
       wt             flw       
 Min.   :17.30   Min.   :0.000  
 1st Qu.:23.52   1st Qu.:2.000  
 Median :28.00   Median :4.000  
 Mean   :27.88   Mean   :3.952  
 3rd Qu.:31.73   3rd Qu.:6.000  
 Max.   :36.80   Max.   :9.000  
In [27]:
with(plot(wt, flw), data=d2)
In [28]:
result2 <- glm(flw ~ wt, family = poisson, data=d2)
summary(result2)
Call:
glm(formula = flw ~ wt, family = poisson, data = d2)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-2.15981  -0.90205  -0.04287   0.72827   1.60420  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -1.04344    0.47066  -2.217   0.0266 *  
wt           0.08327    0.01540   5.408 6.38e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 72.866  on 41  degrees of freedom
Residual deviance: 42.115  on 40  degrees of freedom
AIC: 169.69

Number of Fisher Scoring iterations: 5
In [30]:
d2.predicted <- data.frame(wt = seq(20, 40, 0.1))
d2.predicted$flw <- with(exp(coef(result2)["(Intercept)"] + coef(result2)["wt"] * wt), data=d2.predicted)
head(d.predicted)
dosedead
1.00 0.01480861
1.01 0.01502199
1.02 0.01523841
1.03 0.01545790
1.04 0.01568049
1.05 0.01590625
In [33]:
with(plot(flw ~ wt), data=d2)
with(lines(flw ~ wt), data=d2.predicted)
In [35]:
str(summary(result2))
List of 17
 $ call          : language glm(formula = flw ~ wt, family = poisson, data = d2)
 $ terms         :Classes 'terms', 'formula'  language flw ~ wt
  .. ..- attr(*, "variables")= language list(flw, wt)
  .. ..- attr(*, "factors")= int [1:2, 1] 0 1
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:2] "flw" "wt"
  .. .. .. ..$ : chr "wt"
  .. ..- attr(*, "term.labels")= chr "wt"
  .. ..- attr(*, "order")= int 1
  .. ..- attr(*, "intercept")= int 1
  .. ..- attr(*, "response")= int 1
  .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  .. ..- attr(*, "predvars")= language list(flw, wt)
  .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
  .. .. ..- attr(*, "names")= chr [1:2] "flw" "wt"
 $ family        :List of 12
  ..$ family    : chr "poisson"
  ..$ link      : chr "log"
  ..$ linkfun   :function (mu)  
  ..$ linkinv   :function (eta)  
  ..$ variance  :function (mu)  
  ..$ dev.resids:function (y, mu, wt)  
  ..$ aic       :function (y, n, mu, wt, dev)  
  ..$ mu.eta    :function (eta)  
  ..$ initialize:  expression({     if (any(y < 0))          stop("negative values not allowed for the 'Poisson' family")     n <- rep.int(1, nobs)     mustart <- y + 0.1 })
  ..$ validmu   :function (mu)  
  ..$ valideta  :function (eta)  
  ..$ simulate  :function (object, nsim)  
  ..- attr(*, "class")= chr "family"
 $ deviance      : num 42.1
 $ aic           : num 170
 $ contrasts     : NULL
 $ df.residual   : int 40
 $ null.deviance : num 72.9
 $ df.null       : int 41
 $ iter          : int 5
 $ deviance.resid: Named num [1:42] -0.425 0.268 -1.971 0.614 -1.996 ...
  ..- attr(*, "names")= chr [1:42] "1" "2" "3" "4" ...
 $ coefficients  : num [1:2, 1:4] -1.0434 0.0833 0.4707 0.0154 -2.217 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "(Intercept)" "wt"
  .. ..$ : chr [1:4] "Estimate" "Std. Error" "z value" "Pr(>|z|)"
 $ aliased       : Named logi [1:2] FALSE FALSE
  ..- attr(*, "names")= chr [1:2] "(Intercept)" "wt"
 $ dispersion    : num 1
 $ df            : int [1:3] 2 40 2
 $ cov.unscaled  : num [1:2, 1:2] 0.221523 -0.007149 -0.007149 0.000237
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "(Intercept)" "wt"
  .. ..$ : chr [1:2] "(Intercept)" "wt"
 $ cov.scaled    : num [1:2, 1:2] 0.221523 -0.007149 -0.007149 0.000237
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "(Intercept)" "wt"
  .. ..$ : chr [1:2] "(Intercept)" "wt"
 - attr(*, "class")= chr "summary.glm"

過分散

In [37]:
summary(result2)$deviance / summary(result2)$`df.residual`
1.05288216598768

10.6 尤度

In [38]:
y <- c(0:9)
p <- dpois(y, lambda=2)
p
  1. 0.135335283236613
  2. 0.270670566473225
  3. 0.270670566473225
  4. 0.180447044315484
  5. 0.0902235221577418
  6. 0.0360894088630967
  7. 0.0120298029543656
  8. 0.00343708655839016
  9. 0.000859271639597541
  10. 0.000190949253243898
In [66]:
options(digits=4)

最低でも4桁出るようになっている

In [74]:
print(p)
 [1] 0.1353353 0.2706706 0.2706706 0.1804470 0.0902235 0.0360894 0.0120298
 [8] 0.0034371 0.0008593 0.0001909
In [84]:
logL <- function(x, d){sum(dpois(d, x, log=T))}
d <- rpois(50, lambda = 3.1)
lambdas <- seq(2, 5, 0.1)
In [86]:
plot(lambdas, sapply(lambdas, logL, d = d), type="l")

10.7 AIC

In [88]:
logLik(result)
'log Lik.' -6.782 (df=2)
In [90]:
-2 * logLik(result) + 2 * 2
'log Lik.' 17.56 (df=2)
In [89]:
logLik(result2)
'log Lik.' -82.85 (df=2)
In [91]:
-2 * logLik(result2) + 2 * 2
'log Lik.' 169.7 (df=2)

10.8 逸脱度,残差逸脱度,最大逸脱度

pp.158 付近の逸脱度の説明が曖昧な気がする(表と一致していない)

最小逸脱度: フルモデル

In [95]:
sum(log(dpois(d2$flw, lambda=d2$flw))) * -2
123.576423907449

最大逸脱度: ナルモデル

In [97]:
result2.null <- glm(flw ~ 1, family = poisson, data=d2)
summary(result2.null)
Call:
glm(formula = flw ~ 1, family = poisson, data = d2)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.8115  -1.0863   0.0239   0.9561   2.1719  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)   1.3743     0.0776    17.7   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 72.866  on 41  degrees of freedom
Residual deviance: 72.866  on 41  degrees of freedom
AIC: 198.4

Number of Fisher Scoring iterations: 5
In [98]:
logLik(result2.null)
'log Lik.' -98.22 (df=1)
In [101]:
-2 * logLik(result2.null)
'log Lik.' 196.4 (df=1)

ナル逸脱度: ナルモデルと最小逸脱度の差

残差逸脱度: glmの結果の逸脱度の最小逸脱度との差

In [102]:
result2
Call:  glm(formula = flw ~ wt, family = poisson, data = d2)

Coefficients:
(Intercept)           wt  
    -1.0434       0.0833  

Degrees of Freedom: 41 Total (i.e. Null);  40 Residual
Null Deviance:	    72.9 
Residual Deviance: 42.1 	AIC: 170
In [103]:
-2 * logLik(result2)
'log Lik.' 165.7 (df=2)
In [104]:
165.7 - 123.57
42.13

10.9 二つ以上の説明変数を持つときのモデル選択: ロジスティック回帰を事例に

In [1]:
d3 <- read.csv("../samplecode/Rで学ぶ統計学入門図版作成用/table10-5.csv")
head(d3)
dosesexy
110
110
110
110
110
110
In [2]:
str(d3)
'data.frame':	80 obs. of  3 variables:
 $ dose: int  1 1 1 1 1 1 1 1 1 1 ...
 $ sex : int  1 1 1 1 1 1 1 1 1 1 ...
 $ y   : int  0 0 0 0 0 0 0 1 1 1 ...
In [4]:
summary(d3)
      dose           sex            y         
 Min.   :1.00   Min.   :1.0   Min.   :0.0000  
 1st Qu.:1.75   1st Qu.:1.0   1st Qu.:0.0000  
 Median :2.50   Median :1.5   Median :0.0000  
 Mean   :2.50   Mean   :1.5   Mean   :0.4875  
 3rd Qu.:3.25   3rd Qu.:2.0   3rd Qu.:1.0000  
 Max.   :4.00   Max.   :2.0   Max.   :1.0000  
  • A: dose モデル
  • B: dose + sex モデル
  • C: dose + sex + dose:sex モデル
In [6]:
result3.A <- glm(cbind(y, 1 - y) ~ dose, family = binomial(logit), data = d3)
summary(result3.A)
Call:
glm(formula = cbind(y, 1 - y) ~ dose, family = binomial(logit), 
    data = d3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.9035  -0.9215  -0.5604   0.9744   1.9641  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -2.9068     0.7253  -4.008 6.13e-05 ***
dose          1.1350     0.2670   4.252 2.12e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 110.854  on 79  degrees of freedom
Residual deviance:  86.708  on 78  degrees of freedom
AIC: 90.708

Number of Fisher Scoring iterations: 3
In [7]:
result3.B <- glm(cbind(y, 1 - y) ~ dose + sex, family = binomial(logit), data = d3)
summary(result3.B)
Call:
glm(formula = cbind(y, 1 - y) ~ dose + sex, family = binomial(logit), 
    data = d3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.9054  -0.7505  -0.2851   0.8059   1.9775  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -0.4433     0.9753  -0.455   0.6495    
dose          1.3802     0.3208   4.302 1.69e-05 ***
sex          -2.0599     0.6488  -3.175   0.0015 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 110.854  on 79  degrees of freedom
Residual deviance:  74.236  on 77  degrees of freedom
AIC: 80.236

Number of Fisher Scoring iterations: 5
In [8]:
result3.C <- glm(cbind(y, 1 - y) ~ dose + sex + dose:sex, family = binomial(logit), data = d3)
summary(result3.C)
Call:
glm(formula = cbind(y, 1 - y) ~ dose + sex + dose:sex, family = binomial(logit), 
    data = d3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.9066  -0.7495  -0.2860   0.8070   1.9761  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.46567    2.48159  -0.188    0.851
dose         1.38960    1.00878   1.378    0.168
sex         -2.04388    1.75637  -1.164    0.245
dose:sex    -0.00629    0.64177  -0.010    0.992

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 110.854  on 79  degrees of freedom
Residual deviance:  74.236  on 76  degrees of freedom
AIC: 82.236

Number of Fisher Scoring iterations: 5
In [9]:
library(ggplot2)
Warning message:
"package 'ggplot2' was built under R version 3.3.3"
In [10]:
library(dplyr)
Warning message:
"package 'dplyr' was built under R version 3.3.3"
Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

グラフは,殺虫剤の濃度ごとの死亡率を性別別にプロットした方がいいのではないか

と思ったが,予測のときは濃度は連続値になっているので,無理か

本文では「死亡率」となっているが,「率」ではないような

In [26]:
d3 %>% group_by(dose, sex) %>% summarise(mortality=mean(y))
dosesexmortality
1 1 0.3
1 2 0.0
2 1 0.5
2 2 0.2
3 1 0.8
3 2 0.4
4 1 1.0
4 2 0.7
In [29]:
options(repr.plot.width=5)
In [45]:
d3 %>% group_by(dose, sex) %>% summarise(mortality=mean(y)) %>% ungroup() %>% 
    ggplot(aes(x = dose, y = mortality, group=sex, colour=factor(sex))) + 
        geom_point() + 
        scale_color_discrete(name="Sex", label=c("Male", "Female")) + 
        xlab("Dose") + ylab("Mortality")
In [55]:
d3.pred.A <- 
    data.frame(dose = seq(1, 4, 0.01)) %>% 
    mutate(y = 1 / (1 + exp(-(coef(result3.A)["(Intercept)"] + coef(result3.A)["dose"] * dose))))
head(d3.pred.A)
dosey
1.00 0.1453217
1.01 0.1467371
1.02 0.1481640
1.03 0.1496022
1.04 0.1510520
1.05 0.1525133
In [69]:
gp.d3 <- d3 %>% ggplot(aes(x=dose, y=y, group=sex, shape=factor(sex), colour=factor(sex))) + 
    geom_jitter(width=0, height=0.1) + 
    scale_shape_discrete(name = "Sex", labels = c("Male", "Female")) +
    scale_colour_manual(name = "Sex", labels = c("Male", "Female"), values = c("blue", "red")) +
    xlab("Dose")
gp.d3
In [70]:
gp.d3 + 
    geom_line(data=d3.pred.A, aes(x = dose, y = y), inherit.aes = FALSE)
In [62]:
d3.pred.B <- 
    data.frame(dose = seq(1, 4, 0.01)) %>% 
    mutate(yM = 1 / (1 + exp(-(coef(result3.B)["(Intercept)"] + 
                               coef(result3.B)["dose"] * dose + 
                               coef(result3.B)["sex"] * 1))), 
           yF = 1 / (1 + exp(-(coef(result3.B)["(Intercept)"] + 
                               coef(result3.B)["dose"] * dose + 
                               coef(result3.B)["sex"] * 2))))

head(d3.pred.B)
doseyMyF
1.00 0.2454642 0.03981687
1.01 0.2480295 0.04034792
1.02 0.2506128 0.04088575
1.03 0.2532138 0.04143044
1.04 0.2558327 0.04198207
1.05 0.2584693 0.04254072
In [72]:
gp.d3 + 
    geom_line(data=d3.pred.B, aes(x = dose, y = yM), inherit.aes = FALSE, colour="blue") + 
    geom_line(data=d3.pred.B, aes(x = dose, y = yF), inherit.aes = FALSE, colour="red")
In [63]:
d3.pred.C <- 
    data.frame(dose = seq(1, 4, 0.01)) %>% 
    mutate(yM = 1 / (1 + exp(-(coef(result3.C)["(Intercept)"] + 
                               coef(result3.C)["dose"] * dose + 
                               coef(result3.C)["sex"] * 1 + 
                               coef(result3.C)["dose:sex"] * 1 * dose))), 
           yF = 1 / (1 + exp(-(coef(result3.C)["(Intercept)"] + 
                               coef(result3.C)["dose"] * dose + 
                               coef(result3.C)["sex"] * 2 + 
                               coef(result3.C)["dose:sex"] * 2 * dose))))
head(d3.pred.C)
doseyMyF
1.00 0.2448573 0.04006360
1.01 0.2474241 0.04059655
1.02 0.2500089 0.04113628
1.03 0.2526117 0.04168288
1.04 0.2552323 0.04223642
1.05 0.2578707 0.04279699
In [73]:
gp.d3 + 
    geom_line(data=d3.pred.C, aes(x = dose, y = yM), inherit.aes = FALSE, colour="blue") + 
    geom_line(data=d3.pred.C, aes(x = dose, y = yF), inherit.aes = FALSE, colour="red")

10.10 GLMにおけるオフセットの利用

In [74]:
d4 <- read.csv("../samplecode/Rで学ぶ統計学入門図版作成用/table10-6.csv")
head(d4)
lightplantsw_area
35004 6.5
23002 7.3
7002 12.3
5000 4.3
29004 17.5
23003 13.1
In [75]:
summary(d4)
     light          plants          w_area      
 Min.   : 300   Min.   :0.000   Min.   : 3.300  
 1st Qu.: 800   1st Qu.:0.500   1st Qu.: 6.200  
 Median :1800   Median :2.000   Median : 8.100  
 Mean   :1807   Mean   :2.133   Mean   : 9.347  
 3rd Qu.:2650   3rd Qu.:4.000   3rd Qu.:12.700  
 Max.   :4000   Max.   :5.000   Max.   :17.500  
In [76]:
str(d4)
'data.frame':	15 obs. of  3 variables:
 $ light : int  3500 2300 700 500 2900 2300 1200 900 300 2500 ...
 $ plants: int  4 2 2 0 4 3 1 2 0 4 ...
 $ w_area: num  6.5 7.3 12.3 4.3 17.5 13.1 8.1 13.7 4.3 15.2 ...

スクリプト例,d$w_area とするか data=d としないとエラーになるはず

In [77]:
result4 <- glm(plants ~ light, offset = log(w_area), family = poisson, data=d4)
summary(result4)
Call:
glm(formula = plants ~ light, family = poisson, data = d4, offset = log(w_area))

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-1.12046  -0.68175  -0.00947   0.35440   0.72186  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept) -2.7152248  0.4910606  -5.529 3.21e-08 ***
light        0.0005273  0.0001735   3.040  0.00237 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 15.5631  on 14  degrees of freedom
Residual deviance:  5.6669  on 13  degrees of freedom
AIC: 41.043

Number of Fisher Scoring iterations: 4
In [79]:
d4.pred <- 
    data.frame(light=seq(0, 4000, 0.1)) %>% 
    mutate(density = exp(coef(result4)["(Intercept)"] + coef(result4)["light"] * light))
head(d4.pred)
lightdensity
0.0 0.06619007
0.1 0.06619356
0.2 0.06619705
0.3 0.06620055
0.4 0.06620404
0.5 0.06620753
In [102]:
ggplot() + 
    geom_point(data=d4, aes(x=light , y=plants / w_area)) + 
    geom_line(data=d4.pred, aes(x=light, y=density)) + 
    xlab("Light (lx)") + ylab(expression("Number of plants (cm"^{-2}*")"))
In [103]:
devtools::session_info()
Session info -------------------------------------------------------------------
Packages -----------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, mingw32             
 ui       RTerm                       
 language en                          
 collate  Japanese_Japan.932          
 tz       Asia/Tokyo                  
 date     2017-07-09                  

 package    * version    date       source                            
 assertthat   0.2.0      2017-04-11 CRAN (R 3.3.2)                    
 bindr        0.1        2016-11-13 CRAN (R 3.3.3)                    
 bindrcpp   * 0.1        2016-12-11 CRAN (R 3.3.3)                    
 Cairo        1.5-9      2015-09-26 CRAN (R 3.2.2)                    
 colorspace   1.3-2      2016-12-14 CRAN (R 3.3.3)                    
 crayon       1.3.2      2016-06-28 CRAN (R 3.3.1)                    
 devtools     1.12.0     2016-06-24 CRAN (R 3.3.1)                    
 digest       0.6.12     2017-01-27 CRAN (R 3.3.3)                    
 dplyr      * 0.7.0      2017-06-09 CRAN (R 3.3.3)                    
 evaluate     0.10       2016-10-11 CRAN (R 3.3.2)                    
 ggplot2    * 2.2.1      2016-12-30 CRAN (R 3.3.3)                    
 glue         1.0.0      2017-04-17 CRAN (R 3.3.3)                    
 gtable       0.2.0      2016-02-26 CRAN (R 3.2.5)                    
 IRdisplay    0.4.4      2016-08-02 CRAN (R 3.3.1)                    
 IRkernel     0.8.6.9000 2017-04-13 Github (IRkernel/IRkernel@29ae7df)
 jsonlite     1.4        2017-04-08 CRAN (R 3.3.3)                    
 labeling     0.3        2014-08-23 CRAN (R 3.2.1)                    
 lazyeval     0.2.0      2016-06-12 CRAN (R 3.2.5)                    
 magrittr     1.5        2014-11-22 CRAN (R 3.2.1)                    
 memoise      1.0.0      2016-01-29 CRAN (R 3.2.3)                    
 munsell      0.4.3      2016-02-13 CRAN (R 3.2.5)                    
 pbdZMQ       0.2-5      2016-12-18 CRAN (R 3.3.3)                    
 plyr         1.8.4      2016-06-08 CRAN (R 3.2.5)                    
 R6           2.2.1      2017-05-10 CRAN (R 3.3.3)                    
 Rcpp         0.12.11    2017-05-22 CRAN (R 3.3.3)                    
 repr         0.12.0     2017-04-07 CRAN (R 3.3.3)                    
 rlang        0.1.1      2017-05-18 CRAN (R 3.3.3)                    
 scales       0.4.1      2016-11-09 CRAN (R 3.3.2)                    
 stringi      1.1.5      2017-04-07 CRAN (R 3.3.3)                    
 stringr      1.2.0      2017-02-18 CRAN (R 3.3.3)                    
 tibble       1.3.3      2017-05-28 CRAN (R 3.3.3)                    
 uuid         0.1-2      2015-07-28 CRAN (R 3.3.1)                    
 withr        1.0.2      2016-06-20 CRAN (R 3.2.5)