RiemannL2sim: R6 class for a simulation of RiemannL2 models

RiemannL2simR Documentation

R6 class for a simulation of RiemannL2 models

Description

This class is created to set up a simulations scenario, simulate data from it, fit models, do cross-validation, predict quantities of interest, and summarize relevant statistics in an easy and transparent way.

Details

The methods depend on the magrittr %>% operator and dplyr::bind_rows. And, if messaging is desired, on the R-package telegram.

Public fields

model0

the underlying true model object.

newdata0_FDboost

the data used for sampling in FDboost format.

new_mf0

a clone of the mfGeometry of model0 with newdata0.

new_pred0_

predictions of model0 on newdata0.

sessionInfo

the result of sessionInfo() executed at initialization.

new_effect0

effects of model0 evaluated on newdata0.

new_fac0

tensor-product factorization of model0 on newdata0.

seed

the random seed used for the simulation.

n

a vecor of length three of the form c(n_sim = NA, n_obj = NA, n_grid = NA) containing the specified (average) sample sizes.

simdata

the simulated dataset.

cluster

the cluster id used for parallel computing.

family

the family object used.

mfboost_control

the list specified for controlling mboost in the model fits.

models

the fitted model objects.

runtime

the runtime of the model fits.

warnings

warnings produced during model fits.

cvrisk_control

a list of argument supplied to control the cross-validation.

cv_seeds

seeds used for cross-validation.

cvs

cross-validation objects.

runtime_cv

runtimes of the cross-validations.

warnings_cv

warnings produced during cross-validations.

preds_

predictions of model fits in internal geometry format.

poles_

poles predicted in internal geometry format.

effects

effects estimated on fitted models.

facs

factorized model fits.

simsum

first simulation summary.

bot

TGbot object of R package telegram used for automized notifications.

name

name of the simulation.

Methods

Public methods


Method new()

initialize simulation scenario.

Usage
RiemannL2sim$new(model0, newdata0 = NULL, name = NULL)
Arguments
model0

the model object with the underlying truth.

newdata0

new data to simulate from. The default NULL will take the data of model0.

name

character string, a name for the simulation scenario.


Method gridsampler()

function sampling from the evaluations of a single response observation

Usage
RiemannL2sim$gridsampler(x, size)
Arguments
x

vector to be subsampled from

size

average sample size


Method sample_topdown()

function for sampling observations

Usage
RiemannL2sim$sample_topdown(
  n_sim = 1,
  n_obj = 1,
  n_grid = 40,
  seed = NULL,
  sample_obj = sample,
  sample_grid = self$gridsampler
)
Arguments
n_sim, n_obj, n_grid

sample sizes

seed

random seed

sample_obj

function to sample from objects.

sample_grid

function to sample within objects.


Method sample_blockwise()

function for sampling observations in a blockwise strategy to preserve covariate composition.

Usage
RiemannL2sim$sample_blockwise(
  n_sim = 1,
  n_blocks = 1,
  n_grid = 40,
  seed = NULL,
  random_trafo = function(y_) y_,
  sample_grid = self$gridsampler
)
Arguments
n_sim, n_grid

sample sizes.

n_blocks

number of blocks in each sample.

seed

random seed. For the defaul NULL, the seed is randomly drawn.

random_trafo

function taking y_ an returning it after random transformations.

sample_grid

function to sample within objects.


Method parallel_setup()

initialize parallel computing

Usage
RiemannL2sim$parallel_setup(nc = detectCores())
Arguments
nc

number of cores.


Method parallel_stop()

end parallel computing

Usage
RiemannL2sim$parallel_stop()

Method fit()

fit simulated datasets

Usage
RiemannL2sim$fit(family = self$model0$family, ..., verbose = FALSE)
Arguments
family

mfFamily object used for fitting.

...

arguments supplied to mboost control argument.

verbose

logical, should live info be printed.


Method crossvalidate()

conduct cross-validations of fitted models.

Usage
RiemannL2sim$crossvalidate(
  type = "kfold",
  B = 5,
  ...,
  verbose = FALSE,
  seeds = NULL
)
Arguments
type

type of resampling (as for mboost).

B

number of resampling folds.

...

other arguments supplied to cvLong.

verbose

logical, should live info be printed?

seeds

vector of random seeds for cross-validation. For the default NULL, seeds are randomly drawn.


Method predict()

predict model0 and models and extract estimated effects.

Usage
RiemannL2sim$predict()

Method summarize()

generate simulation summary

Usage
RiemannL2sim$summarize()

Method notify()

send automated notifications via telegram using the R package telegram. For getting started see their package vignette.

Usage
RiemannL2sim$notify(token = bot_token("RBot"), id = user_id("me"), name = NULL)
Arguments
token

telegram bot token, see ?telegram::bot_token.

id

telegram user id, see ?telegram::user_id.

name

simulation name attached to the notification.


Method plot()

make first summary for first inspection of results.

Usage
RiemannL2sim$plot()

Method clone()

The objects of this class are cloneable with this method.

Usage
RiemannL2sim$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Almond-S/manifoldboost documentation built on June 23, 2022, 11:06 a.m.