R Under development (unstable) (2026-10-21 r90730) -- "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/local/clang23/bin/../include/c++/v1/__utility/swap.h:43:11: runtime error: load of value 10, which is not a valid value for type '__libcpp_remove_reference_t' (aka 'bool') #0 0x7f721746140d in CppAD::ADFun::swap(CppAD::ADFun&) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x6140d) #1 0x7f72174f656a in CppAD::ADFun::ADFun(CppAD::ADFun&&) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0xf656a) #2 0x7f72174f5611 in AdTape::AdTape(AdTape&&) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0xf5611) #3 0x7f72174f9828 in adlaplace_make_ad_shard(AdTape&&) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0xf9828) #4 0x7f721759038f in packs_to_ad_fun(std::__1::vector>&&, unsigned long, unsigned long, ad_shard* (*)(AdTape&&)) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x19038f) #5 0x7f7217591c93 in get_ad_pack_raw_obs_h(SEXPREC*, Rcpp::Vector<19, Rcpp::PreserveStorage> const&, std::__1::basic_string, std::__1::allocator> const&) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x191c93) #6 0x7f7217419738 in get_ad_pack_raw_obs(SEXPREC*, Rcpp::Vector<19, Rcpp::PreserveStorage>, std::__1::basic_string, std::__1::allocator>) (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x19738) #7 0x7f721740769c in _adlaplace_get_ad_pack_raw_obs (/data/localhost/ripley/R/packages/tests-clang-UBSAN/adlaplace.Rcheck/adlaplace/libs/adlaplace.so+0x769c) #8 0x55f932921a22 in R_doDotCall (/data/localhost/ripley/R/R-clang/bin/exec/R+0x90a22) #9 0x55f93296d44a in bcEval_loop eval.c #10 0x55f93295b85b in bcEval eval.c #11 0x55f93295b014 in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xca014) #12 0x55f9329730e8 in R_execClosure eval.c #13 0x55f932975eda in R_execMethod (/data/localhost/ripley/R/R-clang/bin/exec/R+0xe4eda) #14 0x7f721f67d6ba in R_dispatchGeneric (/data/localhost/ripley/R/R-clang/library/methods/libs/methods.so+0x16ba) #15 0x55f9329c2469 in do_standardGeneric (/data/localhost/ripley/R/R-clang/bin/exec/R+0x131469) #16 0x55f9329619b2 in bcEval_loop eval.c #17 0x55f93295b85b in bcEval eval.c #18 0x55f93295b014 in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xca014) #19 0x55f9329730e8 in R_execClosure eval.c #20 0x55f9329725da in applyClosure_core eval.c #21 0x55f93295bf26 in Rf_applyClosure (/data/localhost/ripley/R/R-clang/bin/exec/R+0xcaf26) #22 0x55f93295b467 in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xca467) #23 0x55f932978437 in do_set (/data/localhost/ripley/R/R-clang/bin/exec/R+0xe7437) #24 0x55f93295b23f in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xca23f) #25 0x55f9329a87d7 in Rf_ReplIteration (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1177d7) #26 0x55f9329aa2ce in run_Rmainloop (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1192ce) #27 0x55f9329aa33a in Rf_mainloop (/data/localhost/ripley/R/R-clang/bin/exec/R+0x11933a) #28 0x55f932892db7 in main (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1db7) #29 0x7f721f90b680 in __libc_start_call_main (/lib64/libc.so.6+0x3680) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c) #30 0x7f721f90b797 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3797) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c) #31 0x55f932892cd4 in _start (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1cd4) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/clang23/bin/../include/c++/v1/__utility/swap.h:43:11 > 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" > > > > > ### *