Skip to content

Commit

Permalink
import INLA instead of suggesting it
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Oct 3, 2024
1 parent 6135636 commit dadc289
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Imports:
assertthat,
digest,
dplyr,
INLA (>= 22.01.19),
lme4,
methods,
mvtnorm,
Expand All @@ -35,7 +36,6 @@ Imports:
tidyselect
Suggests:
ggplot2,
INLA (>= 22.01.19),
knitr,
MASS,
mgcv,
Expand Down
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ exportClasses(rawImputed)
exportMethods(aggregate_impute)
exportMethods(impute)
exportMethods(model_impute)
importClassesFrom(INLA,inla)
importClassesFrom(lme4,glmerMod)
importFrom(INLA,inla.hyperpar.sample)
importFrom(INLA,inla.posterior.sample)
importFrom(assertthat,assert_that)
importFrom(assertthat,has_name)
importFrom(assertthat,is.count)
Expand Down Expand Up @@ -43,7 +46,6 @@ importFrom(methods,setClassUnion)
importFrom(methods,setGeneric)
importFrom(methods,setIs)
importFrom(methods,setMethod)
importFrom(methods,setOldClass)
importFrom(methods,setValidity)
importFrom(methods,validObject)
importFrom(mvtnorm,rmvnorm)
Expand Down
4 changes: 1 addition & 3 deletions R/import_s3_classes.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#' @importFrom methods setOldClass
setOldClass("inla")

#' The `maybeInla` class
#'
#' A superclass holding either `NULL` or an object of the `inla` class.
Expand All @@ -9,6 +6,7 @@ setOldClass("inla")
setClassUnion("maybeInla", "NULL")

#' @importFrom methods getClassDef setIs
#' @importClassesFrom INLA inla
.onLoad <- function(...) {
if (requireNamespace("INLA", quietly = TRUE)) {
setIs("inla", "maybeInla", classDef = getClassDef("inla", package = "INLA"))
Expand Down
6 changes: 3 additions & 3 deletions R/impute_inla.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' @rdname impute
#' @importFrom assertthat assert_that is.count
#' @importFrom dplyr coalesce
#' @importFrom INLA inla.hyperpar.sample inla.posterior.sample
#' @importFrom methods new setMethod
#' @importFrom purrr map map_dfr map2_dfr pmap_dfr
#' @importFrom stats plogis qpois rgamma rnorm rpois setNames
Expand Down Expand Up @@ -59,16 +60,15 @@ setMethod(

ifelse(is.null(model$model.spde2.blc), "Predictor:%i", "APredictor:%i") |>
sprintf(missing_obs) -> missing_obs
assert_that(requireNamespace("INLA", quietly = TRUE))
assert_that(requireNamespace("sn", quietly = TRUE))
samples <- INLA::inla.posterior.sample(
samples <- inla.posterior.sample(
n = n_imp, result = model, seed = seed, num.threads = num_threads,
parallel.configs = parallel_configs
)
map(samples, "latent") |>
map(`[`, missing_obs, 1) |>
setNames(paste0("sim_", seq_len(n_imp))) -> latent
INLA::inla.hyperpar.sample(n = n_imp, result = model) |>
inla.hyperpar.sample(n = n_imp, result = model) |>
as.data.frame() -> hyperpar
if (
model$.args$family == "zeroinflatednbinomial0" &&
Expand Down
11 changes: 6 additions & 5 deletions checklist.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
description: Configuration file for checklist::check_pkg()
package: yes
allowed:
warnings: []
notes:
- motivation: INLA not on CRAN
warnings:
- motivation: INLA is required and not available on CRAN.
value: |-
checking CRAN incoming feasibility ... NOTE
checking CRAN incoming feasibility ... WARNING
Maintainer: 'Thierry Onkelinx <thierry.onkelinx@inbo.be>'
New submission
Suggests or Enhances not in mainstream repositories:
Strong dependencies not in mainstream repositories:
INLA
Availability using Additional_repositories specification:
INLA yes https://inla.r-inla-download.org/R/stable
notes: []
required:
- CITATION
- DESCRIPTION
Expand All @@ -22,6 +22,7 @@ required:
- codemeta
- documentation
- filename conventions
- folder conventions
- license
- lintr
- repository secret
Expand Down

0 comments on commit dadc289

Please sign in to comment.