Last updated on 2025-12-20 06:50:30 CET.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 0.13.0 | 8.05 | 175.89 | 183.94 | OK | |
| r-devel-linux-x86_64-debian-gcc | 0.13.1 | 5.63 | 97.92 | 103.55 | ERROR | |
| r-devel-linux-x86_64-fedora-clang | 0.13.1 | 15.00 | 281.19 | 296.19 | OK | |
| r-devel-linux-x86_64-fedora-gcc | 0.13.1 | 16.00 | 267.34 | 283.34 | OK | |
| r-devel-windows-x86_64 | 0.13.1 | 10.00 | 153.00 | 163.00 | OK | |
| r-patched-linux-x86_64 | 0.13.1 | 10.28 | 152.00 | 162.28 | OK | |
| r-release-linux-x86_64 | 0.13.1 | 9.02 | 151.81 | 160.83 | OK | |
| r-release-macos-arm64 | 0.13.1 | 2.00 | 53.00 | 55.00 | OK | |
| r-release-macos-x86_64 | 0.13.1 | 6.00 | 130.00 | 136.00 | OK | |
| r-release-windows-x86_64 | 0.13.1 | 11.00 | 147.00 | 158.00 | OK | |
| r-oldrel-macos-arm64 | 0.13.1 | 2.00 | 51.00 | 53.00 | OK | |
| r-oldrel-macos-x86_64 | 0.13.1 | 6.00 | 184.00 | 190.00 | OK | |
| r-oldrel-windows-x86_64 | 0.13.1 | 15.00 | 189.00 | 204.00 | OK |
Version: 0.13.1
Check: examples
Result: ERROR
Running examples in ‘modelbased-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: estimate_slopes
> ### Title: Estimate Marginal Effects
> ### Aliases: estimate_slopes
>
> ### ** Examples
>
> ## Don't show:
> if (all(insight::check_if_installed(c("marginaleffects", "emmeans", "effectsize", "mgcv", "ggplot2", "see"), quietly = TRUE))) withAutoprint({ # examplesIf
+ ## End(Don't show)
+ library(ggplot2)
+ # Get an idea of the data
+ ggplot(iris, aes(x = Petal.Length, y = Sepal.Width)) +
+ geom_point(aes(color = Species)) +
+ geom_smooth(color = "black", se = FALSE) +
+ geom_smooth(aes(color = Species), linetype = "dotted", se = FALSE) +
+ geom_smooth(aes(color = Species), method = "lm", se = FALSE)
+
+ # Model it
+ model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
+ # Compute the marginal effect of Petal.Length at each level of Species
+ slopes <- estimate_slopes(model, trend = "Petal.Length", by = "Species")
+ slopes
+
+ # What is the *average* slope of Petal.Length? This can be calculated by
+ # taking the average of the slopes across all Species, using `comparison`.
+ # We pass a function to `comparison` that calculates the mean of the slopes.
+ estimate_slopes(
+ model,
+ trend = "Petal.Length",
+ by = "Species",
+ comparison = ~I(mean(x))
+ )
+
+ ## Not run:
+ ##D # Plot it
+ ##D plot(slopes)
+ ##D standardize(slopes)
+ ##D
+ ##D model <- mgcv::gam(Sepal.Width ~ s(Petal.Length), data = iris)
+ ##D slopes <- estimate_slopes(model, by = "Petal.Length", length = 50)
+ ##D summary(slopes)
+ ##D plot(slopes)
+ ##D
+ ##D model <- mgcv::gam(Sepal.Width ~ s(Petal.Length, by = Species), data = iris)
+ ##D slopes <- estimate_slopes(model,
+ ##D trend = "Petal.Length",
+ ##D by = c("Petal.Length", "Species"), length = 20
+ ##D )
+ ##D summary(slopes)
+ ##D plot(slopes)
+ ##D
+ ##D # marginal effects, grouped by Species, at different values of Petal.Length
+ ##D estimate_slopes(model,
+ ##D trend = "Petal.Length",
+ ##D by = c("Petal.Length", "Species"), length = 10
+ ##D )
+ ##D
+ ##D # marginal effects at different values of Petal.Length
+ ##D estimate_slopes(model, trend = "Petal.Length", by = "Petal.Length", length = 10)
+ ##D
+ ##D # marginal effects at very specific values of Petal.Length
+ ##D estimate_slopes(model, trend = "Petal.Length", by = "Petal.Length=c(1, 3, 5)")
+ ##D
+ ##D # average marginal effects of Petal.Length,
+ ##D # just for the trend within a certain range
+ ##D estimate_slopes(model, trend = "Petal.Length=seq(2, 4, 0.01)")
+ ## End(Not run)
+ ## Don't show:
+ }) # examplesIf
> library(ggplot2)
> ggplot(iris, aes(x = Petal.Length, y = Sepal.Width)) + geom_point(aes(color = Species)) +
+ geom_smooth(color = "black", se = FALSE) + geom_smooth(aes(color = Species),
+ linetype = "dotted", se = FALSE) + geom_smooth(aes(color = Species), method = "lm",
+ se = FALSE)
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
> model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
> slopes <- estimate_slopes(model, trend = "Petal.Length", by = "Species")
Error in `[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp) :
attempt access index 10/10 in VECTOR_ELT
Calls: withAutoprint ... eval -> eval -> estimate_slopes -> get_marginaltrends
Execution halted
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
estimate_contrasts 7.38 0.551 13.633
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 0.13.1
Check: tests
Result: ERROR
Running ‘testthat.R’ [38s/20s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> #
> # * https://r-pkgs.org/tests.html
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
> library(testthat)
> library(modelbased)
>
> test_check("modelbased")
Starting 2 test processes.
Saving _problems/test-attributes_estimatefun-108.R
Saving _problems/test-estimate_slopes-10.R
Saving _problems/test-estimate_slopes-63.R
Saving _problems/test-estimate_slopes-124.R
> test-multivariate_response.R: Confidence intervals are not yet supported for models of class `mlm`.
> test-multivariate_response.R: Confidence intervals are not yet supported for models of class `mlm`.
Saving _problems/test-transform_response-65.R
Saving _problems/test-visualisation_recipe-151.R
[ FAIL 6 | WARN 0 | SKIP 54 | PASS 194 ]
══ Skipped tests (54) ══════════════════════════════════════════════════════════
• .Platform$OS.type == "windows" is not TRUE (1):
'test-estimate_predicted.R:58:3'
• On CRAN (45): 'test-backtransform_invlink.R:1:1', 'test-betareg.R:1:1',
'test-bias_correction.R:1:1', 'test-brms-marginaleffects.R:1:1',
'test-brms.R:1:1', 'test-equivalence.R:1:1',
'test-estimate_contrasts-average.R:1:1', 'test-estimate_contrasts.R:1:1',
'test-estimate_contrasts_bookexamples.R:1:1',
'test-estimate_contrasts_counterfactual.R:1:1',
'test-estimate_contrasts_effectsize.R:1:1',
'test-estimate_contrasts_inequality.R:1:1',
'test-estimate_contrasts_methods.R:1:1', 'test-estimate_filter.R:1:1',
'test-estimate_means-average.R:1:1', 'test-estimate_means.R:1:1',
'test-estimate_means_ci.R:1:1', 'test-estimate_means_counterfactuals.R:1:1',
'test-estimate_means_dotargs.R:1:1',
'test-estimate_means_marginalization.R:1:1',
'test-estimate_means_mixed.R:1:1', 'test-estimate_grouplevel.R:54:3',
'test-estimate_grouplevel.R:72:3', 'test-estimate_grouplevel.R:93:3',
'test-estimate_grouplevel.R:123:3', 'test-estimate_grouplevel.R:150:5',
'test-estimate_grouplevel.R:182:3', 'test-estimate_grouplevel.R:261:3',
'test-estimate_grouplevel.R:308:3', 'test-estimate_slopes.R:129:1',
'test-g_computation.R:1:1', 'test-get_marginaltrends.R:1:1',
'test-glmmTMB.R:1:1', 'test-joint_test.R:1:1', 'test-keep_iterations.R:1:1',
'test-maihda.R:1:1', 'test-mice.R:1:1', 'test-ordinal.R:1:1',
'test-plot-grouplevel.R:1:1', 'test-predict-dpar.R:1:1',
'test-standardize.R:1:1', 'test-summary_estimate_slopes.R:3:1',
'test-transform_response.R:3:1', 'test-vcov.R:1:1', 'test-zeroinfl.R:1:1'
• On Linux (8): 'test-plot-facet.R:1:1', 'test-plot-flexible_numeric.R:1:1',
'test-plot-ordinal.R:1:1', 'test-plot-slopes.R:1:1', 'test-plot.R:1:1',
'test-print.R:1:1', 'test-residualize_over_grid.R:1:1',
'test-scoping_issues.R:1:1'
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-attributes_estimatefun.R:108:3'): attributes_means, slopes ─────
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 13/13 in VECTOR_ELT
Backtrace:
▆
1. ├─base::suppressMessages(...) at test-attributes_estimatefun.R:108:3
2. │ └─base::withCallingHandlers(...)
3. └─modelbased::estimate_slopes(model, "Sepal.Width", backend = "marginaleffects")
4. └─modelbased::get_marginaltrends(...)
5. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
6. │ └─base::withCallingHandlers(...)
7. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
8. ├─marginaleffects (local) `<fn>`(...)
9. │ └─base::eval.parent(call_attr)
10. │ └─base::eval(expr, p)
11. │ └─base::eval(expr, p)
12. ├─marginaleffects::slopes(...)
13. │ └─base::eval.parent(call_attr_c)
14. │ └─base::eval(expr, p)
15. │ └─base::eval(expr, p)
16. └─marginaleffects::comparisons(...)
17. ├─base::do.call("get_comparisons", args)
18. └─marginaleffects:::get_comparisons(...)
19. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
20. └─data.table:::`[.data.table`(...)
── Error ('test-estimate_slopes.R:10:3'): estimate_slopes ──────────────────────
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 13/13 in VECTOR_ELT
Backtrace:
▆
1. ├─base::suppressMessages(estimate_slopes(model, backend = "marginaleffects")) at test-estimate_slopes.R:10:3
2. │ └─base::withCallingHandlers(...)
3. └─modelbased::estimate_slopes(model, backend = "marginaleffects")
4. └─modelbased::get_marginaltrends(...)
5. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
6. │ └─base::withCallingHandlers(...)
7. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
8. ├─marginaleffects (local) `<fn>`(...)
9. │ └─base::eval.parent(call_attr)
10. │ └─base::eval(expr, p)
11. │ └─base::eval(expr, p)
12. ├─marginaleffects::slopes(...)
13. │ └─base::eval.parent(call_attr_c)
14. │ └─base::eval(expr, p)
15. │ └─base::eval(expr, p)
16. └─marginaleffects::comparisons(...)
17. ├─base::do.call("get_comparisons", args)
18. └─marginaleffects:::get_comparisons(...)
19. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
20. └─data.table:::`[.data.table`(...)
── Error ('test-estimate_slopes.R:63:3'): estimate_slopes, johnson-neyman p-adjust ──
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 10/10 in VECTOR_ELT
Backtrace:
▆
1. └─modelbased::estimate_slopes(model, "Petal.Width", by = "Petal.Length") at test-estimate_slopes.R:63:3
2. └─modelbased::get_marginaltrends(...)
3. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
4. │ └─base::withCallingHandlers(...)
5. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
6. ├─marginaleffects (local) `<fn>`(...)
7. │ └─base::eval.parent(call_attr)
8. │ └─base::eval(expr, p)
9. │ └─base::eval(expr, p)
10. ├─marginaleffects::slopes(...)
11. │ └─base::eval.parent(call_attr_c)
12. │ └─base::eval(expr, p)
13. │ └─base::eval(expr, p)
14. └─marginaleffects::comparisons(...)
15. ├─base::do.call("get_comparisons", args)
16. └─marginaleffects:::get_comparisons(...)
17. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
18. └─data.table:::`[.data.table`(...)
── Error ('test-estimate_slopes.R:124:3'): estimate_slopes, custom comparison ──
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 10/10 in VECTOR_ELT
Backtrace:
▆
1. ├─modelbased::estimate_contrasts(...) at test-estimate_slopes.R:124:3
2. └─modelbased:::estimate_contrasts.default(...)
3. └─modelbased::get_marginalcontrasts(...)
4. └─modelbased::estimate_slopes(...)
5. └─modelbased::get_marginaltrends(...)
6. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
7. │ └─base::withCallingHandlers(...)
8. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
9. ├─marginaleffects (local) `<fn>`(...)
10. │ └─base::eval.parent(call_attr)
11. │ └─base::eval(expr, p)
12. │ └─base::eval(expr, p)
13. ├─marginaleffects::slopes(...)
14. │ └─base::eval.parent(call_attr_c)
15. │ └─base::eval(expr, p)
16. │ └─base::eval(expr, p)
17. └─marginaleffects::comparisons(...)
18. ├─base::do.call("get_comparisons", args)
19. └─marginaleffects:::get_comparisons(...)
20. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
21. └─data.table:::`[.data.table`(...)
── Error ('test-transform_response.R:65:3'): estimate_slopes, transform ────────
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 10/10 in VECTOR_ELT
Backtrace:
▆
1. └─modelbased::estimate_slopes(mod, trend = "Sepal.Width", by = "Species") at test-transform_response.R:65:3
2. └─modelbased::get_marginaltrends(...)
3. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
4. │ └─base::withCallingHandlers(...)
5. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
6. ├─marginaleffects (local) `<fn>`(...)
7. │ └─base::eval.parent(call_attr)
8. │ └─base::eval(expr, p)
9. │ └─base::eval(expr, p)
10. ├─marginaleffects::slopes(...)
11. │ └─base::eval.parent(call_attr_c)
12. │ └─base::eval(expr, p)
13. │ └─base::eval(expr, p)
14. └─marginaleffects::comparisons(...)
15. ├─base::do.call("get_comparisons", args)
16. └─marginaleffects:::get_comparisons(...)
17. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
18. └─data.table:::`[.data.table`(...)
── Error ('test-visualisation_recipe.R:151:3'): visualization_recipe ───────────
Error in ``[.data.table`(out, , `:=`(tmp_idx, seq_len(.N)), by = tmp)`: attempt access index 15/15 in VECTOR_ELT
Backtrace:
▆
1. └─modelbased::estimate_slopes(model, trend = "Sepal.Width") at test-visualisation_recipe.R:151:3
2. └─modelbased::get_marginaltrends(...)
3. ├─base::suppressWarnings(do.call(marginaleffects::avg_slopes, fun_args))
4. │ └─base::withCallingHandlers(...)
5. ├─base::do.call(marginaleffects::avg_slopes, fun_args)
6. ├─marginaleffects (local) `<fn>`(...)
7. │ └─base::eval.parent(call_attr)
8. │ └─base::eval(expr, p)
9. │ └─base::eval(expr, p)
10. ├─marginaleffects::slopes(...)
11. │ └─base::eval.parent(call_attr_c)
12. │ └─base::eval(expr, p)
13. │ └─base::eval(expr, p)
14. └─marginaleffects::comparisons(...)
15. ├─base::do.call("get_comparisons", args)
16. └─marginaleffects:::get_comparisons(...)
17. ├─out[, `:=`(tmp_idx, seq_len(.N)), by = tmp]
18. └─data.table:::`[.data.table`(...)
[ FAIL 6 | WARN 0 | SKIP 54 | PASS 194 ]
Error:
! Test failures.
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc