From 225fc4df952c6a8b5af449b661a7972d1cc359f8 Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Fri, 14 Jun 2024 13:58:35 +0100 Subject: [PATCH 1/5] INLA vignette --- _pkgdown.yml | 1 + vignettes/INLA.Rmd | 160 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 vignettes/INLA.Rmd diff --git a/_pkgdown.yml b/_pkgdown.yml index 0f638bd6..5062428e 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -17,6 +17,7 @@ articles: contents: - details - stan + - INLA - title: Clusters navbar: Clusters diff --git a/vignettes/INLA.Rmd b/vignettes/INLA.Rmd new file mode 100644 index 00000000..75e81d31 --- /dev/null +++ b/vignettes/INLA.Rmd @@ -0,0 +1,160 @@ +--- +title: "Using INLA on Windows" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using INLA on Windows} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +[INLA](https://www.r-inla.org) is an R package for Bayesian inference for Latent +Gaussian Models. There are a few challenges in getting started:- + +* It is not on CRAN, because the building process is non-standard... +* ...because at present building from source on windows does not work, +* INLA do provide working binaries, but no retro-building. When there + is a new INLA release, one binary is made for the current latest + minor version of R (4.4 at present). No binaries of new INLA for old R, + or old INLA for new R. +* If you follow the install instructions on an older version of R such + as 4.3, R knows there is a newer INLA source version + and tries to install it from source. Which does not go well. + +For reference, the error you get attempting to install INLA from source +(whether you intended to install from source or not), looks something +like this, which I got for R 4.3 this morning:- + +``` +> install.packages("INLA", + repos = c(getOption("repos"), + INLA = "https://inla.r-inla-download.org/R/stable"), + dep = TRUE) + +There is a binary version available but the source version is later: + binary source needs_compilation +INLA 24.05.01-1 24.05.10 FALSE + +installing the source package ‘INLA’ + +trying URL 'https://inla.r-inla-download.org/R/stable/src/contrib/INLA_24.05.10.tar.gz' +Content type 'application/x-gzip' length 61448956 bytes (58.6 MB) +downloaded 58.6 MB + +* installing *binary* package 'INLA' ... +C:\WINDOWS\cp.exe: invalid option -- ) +Try `C:\WINDOWS\cp.exe --help' for more information. +ERROR: installing binary package failed +* removing 'E:/Rlib/INLA' +Warning in install.packages : + installation of package ‘INLA’ had non-zero exit status +``` + +The latest binary release turns out to be `24.05.01-1` - but +it knows there is a more recent source available and tries to build it. +The easiest fix is to force `type = "binary"` in `install.packages`, +and settle for the `24.05.01-1` binary. + +See [this issue](https://github.com/hrue/r-inla/issues/99) for the +discussion, leading to the options below. Begin by asking yourself +three questions:- + + 1. Do I want to install locally, or provision with Hipercow + 2. Do I want to use the latest version of INLA, or an older one. + 3. And you do know what your R version is? Should you upgrade? + +# Local installations + +## Latest available version of INLA for your R version + +``` +install.packages("INLA", + repos = c(getOption("repos"), + INLA = "https://inla.r-inla-download.org/R/stable"), + dep = TRUE, type = "binary") +``` + +This works. Right now, if you do this from within R 4.4, you will +get version `24.05.10`, whereas for R 4.3, you will get `24.05.01-1`. +The exact version you get will be the most recent version you +find in [here for R 4.4](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.4/) +or [here for R 4.3](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/)., +or other folders for even older R. + +If you are not on the latest version of R, you likely will not be +able to get the latest version of INLA, because the INLA team only +make new releases for the latest R version. Therefore, if you really +need the latest INLA, you must be on the latest version of R. + +## Specific version of INLA, where available. + +So `install.packages` does not allow us to choose a version, and +`remotes::install_version` only works when `type="source"`, which +you may recall me mentioning once or twice, cannot succeed for +reasons. + +If you want a specific version of INLA, you are limited to the binaries the +INLA team have made for your R version. So look in +[here for R 4.4](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.4/) +or [here for R 4.3](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/) +for example, and find your desired version. For R 4.3, `INLA_23.09.09.zip` looks nice. + +Download the zip, and use `R CMD INSTALL INLA_23.09.09.zip` - or to do this all in +R, you could try:- + + +``` +tmpdir <- tempdir() +version <- "23.09.09" +file <- sprintf("INLA_%s.zip", version) +url <- sprintf("https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/%s", file) +tmpfile <- path.file(tmpdir, file) +curl::curl_download(url, tmpfile) +install.packages(tmpfile) +unlink(tmpfile) +``` + +# Hipercow provisioning + +## Latest version of INLA for latest R version. + +The current latest R version is 4.4. If you are using that version, then +you can either use the `provision.R` or the `pkgdepends` method. + +For `pkgdepends` method, you can can write in `pkgdepends.txt` :- + +``` +repo::https://inla.r-inla-download.org/R/stable +INLA +``` + +For the `provision.R` method, you instead write `provision.R` and paste +the code to install the package, which is the same as the local install:- + +``` +install.packages("INLA", + repos = c(getOption("repos"), + INLA = "https://inla.r-inla-download.org/R/stable"), + dep = TRUE, type = "binary") +``` + +Then `hipercow_provision()` will work in the usual way. + +## Latest version of INLA for older R version + +Here, the `provision.R` method above will work as before, but if you +prefer `pkgdepends`, you will have to be **specific** about +the version you want to install, and it **must** be the most recent +version for your R version. So for R 4.3, your `pkgdepends.txt` +would have to say:- + +``` +repo::https://inla.r-inla-download.org/R/stable +INLA@24.05.01-01 +``` + +because that is the latest version we see [here](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/). + +## Specific version of INLA, where available. + +See the instructions above for a local installation, and put your +script in `provision.R` and use `hipercow_provision()`. From b9c01e67f3445b42987f91894a0ab469d3a2b515 Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Fri, 14 Jun 2024 14:12:30 +0100 Subject: [PATCH 2/5] Update vignettes/INLA.Rmd Co-authored-by: Rich FitzJohn --- vignettes/INLA.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/INLA.Rmd b/vignettes/INLA.Rmd index 75e81d31..3cd2951e 100644 --- a/vignettes/INLA.Rmd +++ b/vignettes/INLA.Rmd @@ -90,7 +90,7 @@ need the latest INLA, you must be on the latest version of R. So `install.packages` does not allow us to choose a version, and `remotes::install_version` only works when `type="source"`, which you may recall me mentioning once or twice, cannot succeed for -reasons. +*reasons*. If you want a specific version of INLA, you are limited to the binaries the INLA team have made for your R version. So look in From 190937a5c39298614249b5d7e2e1e1045cdb9f2e Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Fri, 14 Jun 2024 14:13:55 +0100 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Rich FitzJohn --- vignettes/INLA.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vignettes/INLA.Rmd b/vignettes/INLA.Rmd index 3cd2951e..4b8c137e 100644 --- a/vignettes/INLA.Rmd +++ b/vignettes/INLA.Rmd @@ -77,7 +77,7 @@ This works. Right now, if you do this from within R 4.4, you will get version `24.05.10`, whereas for R 4.3, you will get `24.05.01-1`. The exact version you get will be the most recent version you find in [here for R 4.4](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.4/) -or [here for R 4.3](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/)., +or [here for R 4.3](https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/), or other folders for even older R. If you are not on the latest version of R, you likely will not be @@ -127,7 +127,7 @@ repo::https://inla.r-inla-download.org/R/stable INLA ``` -For the `provision.R` method, you instead write `provision.R` and paste +For the `script` method, you instead write `provision.R` and paste the code to install the package, which is the same as the local install:- ``` @@ -137,7 +137,7 @@ install.packages("INLA", dep = TRUE, type = "binary") ``` -Then `hipercow_provision()` will work in the usual way. +Then `hipercow_provision()` will work in the usual way. See `vignette("packages")` for more details. ## Latest version of INLA for older R version From 86693951e6d7db2d2fb0061834c6fdb7a2b2698f Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Fri, 14 Jun 2024 14:16:55 +0100 Subject: [PATCH 4/5] Couple more 'script' changes --- vignettes/INLA.Rmd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vignettes/INLA.Rmd b/vignettes/INLA.Rmd index 4b8c137e..c0e3c278 100644 --- a/vignettes/INLA.Rmd +++ b/vignettes/INLA.Rmd @@ -118,9 +118,9 @@ unlink(tmpfile) ## Latest version of INLA for latest R version. The current latest R version is 4.4. If you are using that version, then -you can either use the `provision.R` or the `pkgdepends` method. +you can either use the `script` or the `pkgdepends` method. -For `pkgdepends` method, you can can write in `pkgdepends.txt` :- +For `pkgdepends`, in your hipercow root you can write in `pkgdepends.txt` :- ``` repo::https://inla.r-inla-download.org/R/stable @@ -128,7 +128,7 @@ INLA ``` For the `script` method, you instead write `provision.R` and paste -the code to install the package, which is the same as the local install:- +this code to install the package, which is the same as the local install:- ``` install.packages("INLA", @@ -141,7 +141,7 @@ Then `hipercow_provision()` will work in the usual way. See `vignette("packages" ## Latest version of INLA for older R version -Here, the `provision.R` method above will work as before, but if you +Here, the `script` method above will work as before, but if you prefer `pkgdepends`, you will have to be **specific** about the version you want to install, and it **must** be the most recent version for your R version. So for R 4.3, your `pkgdepends.txt` @@ -156,5 +156,6 @@ because that is the latest version we see [here](https://inla.r-inla-download.or ## Specific version of INLA, where available. -See the instructions above for a local installation, and put your -script in `provision.R` and use `hipercow_provision()`. +See the instructions above for a local installation, put the +code in `provision.R` to use the `script` method with +`hipercow_provision()`. From 375a6a7c6b8df6fe6eb32a2cce70bb5326124fbb Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Fri, 14 Jun 2024 14:17:10 +0100 Subject: [PATCH 5/5] Bump version --- DESCRIPTION | 2 +- drivers/windows/DESCRIPTION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9af454b5..596df618 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: hipercow Title: High Performance Computing -Version: 1.0.23 +Version: 1.0.24 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Wes", "Hinsley", role = "aut"), diff --git a/drivers/windows/DESCRIPTION b/drivers/windows/DESCRIPTION index a491a546..ff414789 100644 --- a/drivers/windows/DESCRIPTION +++ b/drivers/windows/DESCRIPTION @@ -1,6 +1,6 @@ Package: hipercow.windows Title: DIDE HPC Support for Windows -Version: 1.0.23 +Version: 1.0.24 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Wes", "Hinsley", role = "aut"),