fit_saw_cv: Return cross-validated model

Description Usage Arguments

View source: R/post_saw.R

Description

Find optimal threshold parameter using k-fold cross validation and return model fitted using this threshold.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
fit_saw_cv(
  y,
  X,
  Z = NULL,
  time_effect = FALSE,
  n_folds = 4,
  grid_size = 20,
  prefer_sparsity = TRUE,
  sparsity_level = 0.5,
  max_threshold = 10,
  parallel = FALSE,
  n_cores = NULL,
  return_info = FALSE
)

Arguments

y

Matrix of labels. Has dimension T x N.

X

List of feature matrices. The pth entry corresponds to the design matrix of the pth covariate and has dimension T x N.

Z

Instruments corresponding to the argument X. If NULL all X variables are their own instrument.

time_effect

Boolean indicating if a time effect is to be estimated.

n_folds

Number of folds to use in cross validation step. Default 4. It makes sense that n_folds is multiple of n_cores.

grid_size

Number of s_thresh candidates.

prefer_sparsity

Boolean indicating whether the cross-validation. procedure should place a naive penalty on non-sparse solutions.

parallel

Boolean indicating if code is parallelized over folds.

n_cores

How many cores to use for paralellization. Default to number of available logical cores. It makes sense that n_folds is multiple of n_cores.

return_info

Return additional info on model fit.


timmens/sawr documentation built on Aug. 30, 2021, 8:09 a.m.