File: bootstrap_model-emmeans.R

package info (click to toggle)
r-cran-parameters 0.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,852 kB
  • sloc: sh: 16; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#' @keywords emmeans_methods
emm_basis.bootstrap_model <- function(object, trms, xlev, grid, ...) {
  insight::check_if_installed("emmeans")

  model <- attr(object, "original_model")
  emb <- emmeans::emm_basis(model, trms, xlev, grid, ...)

  if (ncol(object) != ncol(emb$V) || !all(colnames(object) == colnames(emb$V))) {
    insight::format_error(
      "Oops! Cannot create the reference grid. Please open an issue at {.url https://github.com/easystats/parameters/issues}."
    )
  }

  emb$post.beta <- as.matrix(object)
  emb$misc$is_boot <- TRUE
  emb
}

#' @keywords emmeans_methods
recover_data.bootstrap_model <- function(object, ...) {
  insight::check_if_installed("emmeans")
  model <- attr(object, "original_model")
  emmeans::recover_data(model, ...)
}


#' @keywords emmeans_methods
emm_basis.bootstrap_parameters <- function(object, trms, xlev, grid, ...) {
  insight::check_if_installed("emmeans")
  model <- attr(object, "boot_samples")
  emmeans::emm_basis(model, trms, xlev, grid, ...)
}

#' @keywords emmeans_methods
recover_data.bootstrap_parameters <- function(object, ...) {
  insight::check_if_installed("emmeans")
  model <- attr(object, "boot_samples")
  emmeans::recover_data(model, ...)
}