Skip to content

Commit ed63fa7

Browse files
Added PDF of book chapter, and updated Readme.
1 parent edc20dd commit ed63fa7

5 files changed

+14
-13
lines changed

Overview_IntroductionNIMBLE.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: "Introduction to NIMBLE"
3+
subtitle: "Material from the book <br> [Bayesian Analysis of Capture-Recapture Data with Hidden Markov Models: Theory and Case Studies in R](https://oliviergimenez.github.io/banana-book/)"
34
author: "Olivier Gimenez, Valentin Lauret & Maud Quéroué"
45
date: "18/03/2022"
56
output:
@@ -11,8 +12,7 @@ output:
1112
## What is NIMBLE
1213

1314
```{r nimblelogo, message = FALSE, echo = FALSE, fig.align="center", out.width="50%", fig.cap = "Logo of the NIMBLE R package designed by Luke Larson."}
14-
setwd("C:/Users/queroue/Desktop/nimble-workshop")
15-
knitr::include_graphics(here::here("img","nimble-icon.png"))
15+
knitr::include_graphics("img/nimble-icon.png")
1616
```
1717

1818
NIMBLE stands for **N**umerical **I**nference for statistical **M**odels using **B**ayesian and **L**ikelihood **E**stimation. Briefly speaking, NIMBLE is an R package that implements for you MCMC algorithms to generate samples from the posterior distribution of model parameters. Freed from the burden of coding your own MCMC algorithms, you only have to specify a likelihood and priors to apply the Bayes theorem. To do so, NIMBLE uses a syntax very similar to the R syntax, which should make your life easier. This so-called BUGS language is also used by other programs like WinBUGS, OpenBUGS, and JAGS.
@@ -28,7 +28,6 @@ To run NIMBLE, you will need to:
2828
4. Pick initial values for parameters to be estimated (for each chain).
2929
5. Provide MCMC details namely the number of chains, the length of the burn-in period and the number of iterations following burn-in.
3030

31-
3231
First things first, let's not forget to load the `nimble` package ad the other packages useful for this workshop:
3332
```{r, message = FALSE}
3433
library(nimble)
@@ -567,15 +566,15 @@ survival$calculate()
567566
# this is dbinom(x = 19, size = 57, prob = 0.5, log = TRUE)
568567
```
569568

570-
The ability in NIMBLE to access the nodes of your model and to evaluate the model likelihood can help you in identifying bugs in your code. For example, if we provide a negative initial value to `theta`, `survival$calculate()` returns `NA`.
569+
The ability in NIMBLE to access the nodes of your model and to evaluate the model likelihood can help you in identifying bugs in your code. For example, if we provide a negative initial value for `theta`, `survival$calculate()` returns `NA`:
571570
```{r, warning = FALSE}
572571
survival <- nimbleModel(code = model,
573572
data = my.data,
574573
inits = list(theta = -0.5))
575574
survival$calculate()
576575
```
577576

578-
Other example : if there are more survived than released :
577+
As another example, if we convey in the data the information that more animals survived than were released, we'll get an infinity value for the log-likelood:
579578
```{r, warning = FALSE, message = FALSE}
580579
my.data <- list(survived = 61, released = 57)
581580
initial.values <- list(theta = 0.5)
@@ -585,7 +584,8 @@ survival <- nimbleModel(code = model,
585584
inits = initial.values)
586585
survival$calculate()
587586
```
588-
Then, to check the model is correctly initialized and without bug in the code, we can check that `model$calculate()` returns a number and not `NA` or `-Inf`.
587+
588+
As a check that the model is correctly initialized and that your code is without bugs, the call to `model$calculate()` should return a number and not `NA` or `-Inf`.
589589

590590
```{r, echo = FALSE}
591591
my.data <- list(survived = 19, released = 57)

Overview_IntroductionNIMBLE.pdf

38.4 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# NIMBLE workshop
22

33
Material for a workshop on NIMBLE:
4-
+ Slides are at <https://oliviergimenez.github.io/nimble-workshop/#1>
5-
+ R codes at <https://github.com/oliviergimenez/nimble-workshop/blob/master/Rcodes_NimbleGDR.R>
6-
+ Document with codes and information at <https://github.com/oliviergimenez/nimble-workshop/blob/master/Overview_IntroductionNIMBLE.pdf>
4+
+ Slides: <https://oliviergimenez.github.io/nimble-workshop/#1>
5+
+ PDF of the slides: <https://github.com/oliviergimenez/nimble-workshop/blob/master/IntroductionNIMBLE.pdf>
6+
+ R codes: <https://github.com/oliviergimenez/nimble-workshop/blob/master/Rcodes_NimbleGDR.R>
7+
+ NIMBLE book chapter: <https://github.com/oliviergimenez/nimble-workshop/blob/master/Overview_IntroductionNIMBLE.pdf>

index.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ background-color: white
8484

8585
+ Choosing and coding MCMC samplers
8686

87-
+ Material from [a book in progress](https://oliviergimenez.github.io/banana-book/)
87+
+ Material from [a book in progress](https://oliviergimenez.github.io/banana-book/), NIMBLE chapter is [here](https://github.com/oliviergimenez/nimble-workshop/blob/master/Overview_IntroductionNIMBLE.pdf)
8888

8989
+ [R codes on GitHub](https://github.com/oliviergimenez/nimble-workshop/blob/master/Rcodes_NimbleGDR.R) for easier manipulation
9090

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# <p>Introduction to NIMBLE<br />
1616
<img src="img/nimble-icon.png" style="width:3in" /></p>
1717
### Olivier Gimenez, Maud Quéroué, Valentin Lauret
18-
### last updated: 2022-03-16
18+
### last updated: 2022-03-19
1919

2020
---
2121

@@ -79,7 +79,7 @@
7979

8080
+ Choosing and coding MCMC samplers
8181

82-
+ Material from [a book in progress](https://oliviergimenez.github.io/banana-book/)
82+
+ Material from [a book in progress](https://oliviergimenez.github.io/banana-book/), NIMBLE chapter is [here](https://github.com/oliviergimenez/nimble-workshop/blob/master/Overview_IntroductionNIMBLE.pdf)
8383

8484
+ [R codes on GitHub](https://github.com/oliviergimenez/nimble-workshop/blob/master/Rcodes_NimbleGDR.R) for easier manipulation
8585

@@ -257,7 +257,7 @@
257257

258258
```
259259
$theta
260-
[1] 0.04221461
260+
[1] 0.8410788
261261
```
262262

263263
---

0 commit comments

Comments
 (0)