R Under development (unstable) (2026-10-21 r90729) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu 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. Natural language support but running in an English locale 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. > pkgname <- "adlaplace" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('adlaplace') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("adlaplace") > ### * adlaplace > > flush(stderr()); flush(stdout()) > > ### Name: adlaplace > ### Title: Fit a hierarchical model by Laplace-approximate maximum > ### likelihood > ### Aliases: adlaplace > > ### ** Examples > > set.seed(1) > n <- 80 > g <- factor(sample(4, n, replace = TRUE)) > x <- rbinom(n, 1, 0.5) > eta <- 0.5 + 0.4 * x + rnorm(4, sd = 0.3)[g] > nb_sd <- 0.3 > z <- rgamma(n, nb_sd^(-2), nb_sd^(-2)) > dat <- data.frame(y = rpois(n, exp(eta) * z), x = x, g = g) > md <- model_data( + nbinom(y, lower = 1e-9, init = 0.15) ~ x + iid(g, init = 0.3), + data = dat + ) > config <- list( + transform_theta = TRUE, + obs_groups = obs_groups(md$term_data$A, num_shards = 5), + verbose = FALSE + ) > ap <- ad_pack(md, config) /usr/include/c++/16/bits/move.h:238:11: runtime error: load of value 190, which is not a valid value for type 'bool' #0 0x7ba8dfe1ca8a in CppAD::ADFun::swap(CppAD::ADFun&) [clone .cold] (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x1ca8a) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #1 0x7ba8dfebfe83 in AdTape::AdTape(AdTape&&) (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0xbfe83) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #2 0x7ba8e0076d7d in adlaplace_make_ad_shard(AdTape&&) (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x276d7d) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #3 0x7ba8e01f72a9 in packs_to_ad_fun(std::vector >&&, unsigned long, unsigned long, ad_shard* (*)(AdTape&&)) (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x3f72a9) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #4 0x7ba8e021f150 in get_ad_pack_raw_obs_h(SEXPREC*, Rcpp::Vector<19, Rcpp::PreserveStorage> const&, std::__cxx11::basic_string, std::allocator > const&) (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x41f150) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #5 0x7ba8dfe68498 in get_ad_pack_raw_obs(SEXPREC*, Rcpp::Vector<19, Rcpp::PreserveStorage>, std::__cxx11::basic_string, std::allocator >) (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x68498) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #6 0x7ba8dfe54f70 in _adlaplace_get_ad_pack_raw_obs (/data/localhost/ripley/R/packages/tests-gcc-SAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x54f70) (BuildId: d203d89d65f251caf962d2770bafefe647142e70) #7 0x00000075eaea in R_doDotCall /data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:760 #8 0x000000902e27 in bcEval_loop /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8704 #9 0x0000008da1db in bcEval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533 #10 0x00000087810a in Rf_eval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167 #11 0x0000008914fa in R_execClosure /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398 #12 0x000000899531 in R_execMethod /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2567 #13 0x7fa8ee396739 in R_dispatchGeneric /data/localhost/ripley/R/svn/R-devel/src/library/methods/src/methods_list_dispatch.c:1153 #14 0x000000ad6dfe in do_standardGeneric /data/localhost/ripley/R/svn/R-devel/src/main/objects.c:1348 #15 0x000000904559 in bcEval_loop /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8085 #16 0x0000008da1db in bcEval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533 #17 0x00000087810a in Rf_eval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167 #18 0x0000008914fa in R_execClosure /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398 #19 0x0000008951fd in applyClosure_core /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314 #20 0x0000008787b8 in Rf_applyClosure /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333 #21 0x0000008787b8 in Rf_eval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278 #22 0x0000008adb3e in do_set /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:3585 #23 0x000000878be6 in Rf_eval /data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1230 #24 0x000000a23af8 in Rf_ReplIteration /data/localhost/ripley/R/svn/R-devel/src/main/main.c:264 #25 0x000000a23af8 in R_ReplConsole /data/localhost/ripley/R/svn/R-devel/src/main/main.c:319 #26 0x000000a417ca in run_Rmainloop /data/localhost/ripley/R/svn/R-devel/src/main/main.c:1239 #27 0x000000a41862 in Rf_mainloop /data/localhost/ripley/R/svn/R-devel/src/main/main.c:1246 #28 0x00000041236f in main /data/localhost/ripley/R/svn/R-devel/src/main/Rmain.c:29 #29 0x7fa8f140a680 in __libc_start_call_main (/lib64/libc.so.6+0x3680) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c) #30 0x7fa8f140a797 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3797) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c) #31 0x000000412d34 in _start (/data/localhost/ripley/R/gcc-SAN3/bin/exec/R+0x412d34) (BuildId: 3fb2494ff6ab9a90c047428081e3f8f08e33a690) > cache <- new.env(parent = emptyenv()) > x0 <- md$term_data$info$parameters$init > outer_fn(x = x0, config = config, cache = cache, ad_pack = ap) [1] 153.8755 > outer_gr(x = x0, config = config, cache = cache, ad_pack = ap) [1] -25.3846648 -23.3412463 -0.4940207 -11.3119746 > > > > cleanEx() > nameEx("by_group") > ### * by_group > > flush(stderr()); flush(stdout()) > > ### Name: by_group > ### Title: By-Group Classes and Functions > ### Aliases: by_group > > ### ** Examples > > # Create with explicit levels > bg <- by_group(term = "group", levels = c("A", "B", "C")) > > # Create from data > dat <- data.frame(group = c("A", "B", "A", "C")) > bg <- by_group(term = "group", data = dat) > > > > cleanEx() > nameEx("fpoly-class") > ### * fpoly-class > > flush(stderr()); flush(stdout()) > > ### Name: fpoly-class > ### Title: Fixed Polynomial Model Term > ### Aliases: fpoly-class fpoly design,fpoly-method beta_info,fpoly-method > > ### ** Examples > > # Create a fixed polynomial term > fpoly_term <- fpoly(x = "temp", p = 3, ref_value = 15) > > > > cleanEx() > nameEx("gamm") > ### * gamm > > flush(stderr()); flush(stdout()) > > ### Name: gamm > ### Title: Example GAMM simulation data > ### Aliases: gamm dat > ### Keywords: datasets > > ### ** Examples > > data("gamm", package = "adlaplace") > exists("dat") [1] TRUE > nrow(dat) [1] 500 > > > > cleanEx() > nameEx("intercept-class") > ### * intercept-class > > flush(stderr()); flush(stdout()) > > ### Name: intercept-class > ### Title: intercept Model Term > ### Aliases: intercept-class intercept design,intercept-method > ### beta_info,intercept-method precision,intercept-method > ### random_info,intercept-method > > ### ** Examples > > # Create a intercept term > intercept_term <- intercept(init=2) > > > > cleanEx() > nameEx("iwp") > ### * iwp > > flush(stderr()); flush(stdout()) > > ### Name: iwp > ### Title: Integrated Wiener Process Term Constructor > ### Aliases: iwp > > ### ** Examples > > knots <- seq(0, 1, length.out = 5) > iwp_term <- iwp(x = "age", knots = knots) > iwp_term $age_iwp An object of class "iwp" Slot "name": [1] "age" Slot "label": [1] "age_iwp" Slot "formula": ~0 + age Slot "knots": [1] 0.00 0.25 0.50 0.75 1.00 Slot "ref_value": [1] 0 Slot "p.order": [1] 2 Slot "init": [1] 0.02 Slot "lower": [1] 1e-09 Slot "upper": [1] Inf Slot "parscale": [1] 1 Slot "log": [1] TRUE Slot "model_role": [1] random Levels: fixed random response Slot "density": [1] "random_diagonal" Slot "ad_kind": [1] "random" Slot "package": [1] "adlaplace" $age_rpoly An object of class "rpoly" Slot "sd": [1] Inf Slot "basis_scale": [1] 0.25 Slot "name": [1] "age" Slot "label": [1] "age_rpoly" Slot "formula": ~0 + age Slot "knots": numeric(0) Slot "ref_value": [1] 0 Slot "p.order": [1] 1 Slot "init": numeric(0) Slot "lower": numeric(0) Slot "upper": numeric(0) Slot "parscale": numeric(0) Slot "log": [1] TRUE Slot "model_role": [1] random Levels: fixed random response Slot "density": [1] "random_diagonal" Slot "ad_kind": [1] "random" Slot "package": [1] "adlaplace" > > > > cleanEx() > nameEx("linear-class") > ### * linear-class > > flush(stderr()); flush(stdout()) > > ### Name: linear-class > ### Title: Linear Model Term > ### Aliases: linear-class linear design,linear-method > ### beta_info,linear-method precision,linear-method > ### random_info,linear-method > > ### ** Examples > > # Create a linear term > linear_term <- linear(x = "temperature") > > > > cleanEx() > nameEx("london") > ### * london > > flush(stderr()); flush(stdout()) > > ### Name: london > ### Title: London daily mortality and PM10 (case-crossover example) > ### Aliases: london > ### Keywords: datasets > > ### ** Examples > > data("london", package = "adlaplace") > head(london) city date year month day dow all tmean rh pm10 1 London 2002-01-01 2002 Jan 1 Tue 199 -0.22500001 75.6783 71.70000 2 London 2002-01-02 2002 Jan 2 Wed 231 0.08749995 77.5250 40.20000 3 London 2002-01-03 2002 Jan 3 Thu 210 0.85000002 81.3250 41.80000 4 London 2002-01-04 2002 Jan 4 Fri 203 0.53750002 85.4500 50.40000 5 London 2002-01-05 2002 Jan 5 Sat 224 4.25000000 93.5250 49.36429 6 London 2002-01-06 2002 Jan 6 Sun 198 7.06874990 96.4000 31.10000 > > > > cleanEx() > nameEx("model_data") > ### * model_data > > flush(stderr()); flush(stdout()) > > ### Name: model_data > ### Title: Assemble model terms and per-shard 'density_data' objects > ### Aliases: model_data > > ### ** Examples > > set.seed(1) > dat <- data.frame( + y = rpois(30, 2), + x1 = rnorm(30), + x2 = runif(30) + ) > md <- model_data( + y ~ x1 + iwp(x2, p = 2, knots = seq(0, 1, length.out = 5)), + data = dat + ) > names(md$terms) [1] "gaussian_y" "linear_x1" "x2_iwp" "x2_rpoly" "intercept" > > > > cleanEx() > nameEx("obs_groups") > ### * obs_groups > > flush(stderr()); flush(stdout()) > > ### Name: obs_groups > ### Title: Partition observations into AD shards by sparsity pattern > ### Aliases: obs_groups > > ### ** Examples > > set.seed(1) > A <- matrix(rnorm(100), 20, 5) > G <- obs_groups(A, num_shards = 3) > G 20 x 3 sparse Matrix of class "ngCMatrix" [1,] | . . [2,] | . . [3,] . . | [4,] | . . [5,] . | . [6,] . | . [7,] . | . [8,] | . . [9,] . | . [10,] | . . [11,] | . . [12,] . | . [13,] . . | [14,] . | . [15,] . | . [16,] . . | [17,] . . | [18,] . . | [19,] | . . [20,] . . | > > > > cleanEx() > nameEx("outer_optim_wrappers") > ### * outer_optim_wrappers > > flush(stderr()); flush(stdout()) > > ### Name: outer_optim_wrappers > ### Title: Outer objective and gradient wrappers > ### Aliases: outer_optim_wrappers outer_fn outer_gr > > ### ** Examples > > set.seed(1) > n <- 80 > g <- factor(sample(4, n, replace = TRUE)) > x <- rbinom(n, 1, 0.5) > eta <- 0.5 + 0.4 * x + rnorm(4, sd = 0.3)[g] > nb_sd <- 0.3 > z <- rgamma(n, nb_sd^(-2), nb_sd^(-2)) > dat <- data.frame(y = rpois(n, exp(eta) * z), x = x, g = g) > md <- model_data( + nbinom(y, lower = 1e-9, init = 0.15) ~ x + iid(g, init = 0.3), + data = dat + ) > config <- list( + transform_theta = TRUE, + obs_groups = obs_groups(md$term_data$A, num_shards = 5), + verbose = FALSE + ) > ap <- ad_pack(md, config) > cache <- new.env(parent = emptyenv()) > x0 <- md$term_data$info$parameters$init > outer_fn(x = x0, config = config, cache = cache, ad_pack = ap) [1] 153.8755 > outer_gr(x = x0, config = config, cache = cache, ad_pack = ap) [1] -25.3846648 -23.3412463 -0.4940207 -11.3119746 > > > > > cleanEx() > nameEx("ref_align") > ### * ref_align > > flush(stderr()); flush(stdout()) > > ### Name: ref_align > ### Title: Align Reference Value to Nearest Knot > ### Aliases: ref_align > ### Keywords: internal > > ### ** Examples > > # Align reference value to nearest knot > knots <- c(10, 20, 30, 40, 50) > adlaplace::ref_align(23, knots) # Returns 20 [1] 20 > > > > > cleanEx() > nameEx("replace_vars") > ### * replace_vars > > flush(stderr()); flush(stdout()) > > ### Name: replace_vars > ### Title: Replace data-column names in model terms > ### Aliases: replace_vars replace_vars,model_term-method > ### replace_vars,dirichlet_multinom-method replace_vars,formula-method > ### replace_vars,list-method > > ### ** Examples > > terms <- collect_terms(nbinom(y) ~ fpoly(sqrt_pm, p = 1)) > replace_vars(terms, c(sqrt_pm = "sqrt_pm_s1")) $y_nbinom_sd An object of class "nbinom" Slot "name": [1] "y" Slot "label": [1] "y_nbinom_sd" Slot "formula": y ~ . Slot "knots": numeric(0) Slot "ref_value": numeric(0) Slot "p.order": [1] 1 Slot "init": [1] 0.02 Slot "lower": [1] 1e-09 Slot "upper": [1] Inf Slot "parscale": [1] 1 Slot "log": [1] TRUE Slot "model_role": [1] response Levels: fixed random response Slot "density": [1] "nbinom_obs" Slot "ad_kind": [1] "observations" Slot "package": [1] "adlaplace" $sqrt_pm_s1_fpoly An object of class "fpoly" Slot "init": [1] 0 Slot "lower": [1] -Inf Slot "upper": [1] Inf Slot "parscale": [1] 1 Slot "basis_scale": [1] 1 Slot "name": [1] "sqrt_pm_s1" Slot "label": [1] "sqrt_pm_s1_fpoly" Slot "formula": ~0 + sqrt_pm_s1 Slot "knots": numeric(0) Slot "ref_value": [1] 0 Slot "p.order": [1] 1 Slot "log": [1] TRUE Slot "model_role": [1] fixed Levels: fixed random response Slot "density": [1] NA Slot "ad_kind": [1] NA Slot "package": [1] "adlaplace" $intercept An object of class "intercept" Slot "sd": [1] Inf Slot "name": [1] "intercept" Slot "label": [1] "intercept" Slot "formula": . ~ 1 Slot "knots": numeric(0) Slot "ref_value": numeric(0) Slot "p.order": integer(0) Slot "init": [1] 0 Slot "lower": [1] -Inf Slot "upper": [1] Inf Slot "parscale": [1] 1 Slot "log": [1] TRUE Slot "model_role": [1] fixed Levels: fixed random response Slot "density": [1] NA Slot "ad_kind": [1] NA Slot "package": [1] "adlaplace" > > > > > ### *