Nothing
#' @tags pkg-sandwich
if (requireNamespace("sandwich") && requireNamespace("future.apply")) {
library(futurize)
library(sandwich)
fcns <- tryCatch({
futurize::futurize_supported_functions("sandwich")
}, error = identity)
print(fcns)
stopifnot(is.character(fcns), length(fcns) > 0L)
options(future.rng.onMisuse = "error")
plan(multisession, workers = 2L)
RNGkind("L'Ecuyer-CMRG")
fm <- lm(dist ~ speed, data = cars)
## Truth (sequential lapply)
## Since the non-parallel version uses a different set of RNG seeds
## than the parallel versions, we will not get numerically identical
## results
#set.seed(42)
#vcov_truth <- sandwich::vcovBS(fm, R = 5L)
## futurize()
set.seed(42)
vcov <- sandwich::vcovBS(fm, R = 5L) |> futurize()
stopifnot(
is.matrix(vcov),
all(dim(vcov) == c(2, 2))
)
## vcovJK()
set.seed(42)
vcov_jk <- sandwich::vcovJK(fm) |> futurize()
stopifnot(
is.matrix(vcov_jk),
all(dim(vcov_jk) == c(2, 2))
)
plan(sequential)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.