spadd.presmth.Legr.cv: Choose tuning parameters for fitting the desparsified lasso...

View source: R/spaddinf.R

spadd.presmth.Legr.cvR Documentation

Choose tuning parameters for fitting the desparsified lasso presmoothing estimator with Legendre polynomials

Description

Choose tuning parameters for fitting the desparsified lasso presmoothing estimator with Legendre polynomials

Usage

spadd.presmth.Legr.cv(
  X,
  Y,
  d.pre,
  K = 1,
  n.lambda,
  n.eta,
  n.folds,
  plot = FALSE
)

Arguments

X

the design matrix

Y

the response vector

d.pre

the number of intervals in which to divide the support of each covariate

K

the order of the Legendre polynomials. E.g. K=0 fits piecwise constant, K=1 fits piecewise linear functions.

n.lambda

the number of candidate lambda values

n.eta

the number of candidate eta values

n.folds

the number of crossvalidation folds

plota

logical indicating whether crossvalidation output should be plotted

Value

a list with the chosen values of the tuning parameters

Examples

data <- data_gen(n = 200,q = 50,r = .9)

spadd.presmth.Legr.cv.out <- spadd.presmth.Legr.cv(X = data$X,
                                                   Y = data$Y,
                                                   d.pre = 10,
                                                   n.lambda = 25,
                                                   n.eta = 25,
                                                   n.folds = 5,
                                                   plot = TRUE)

spadd.presmth.Legr.out <- spadd.presmth.Legr(X = data$X,
                                             Y = data$Y,
                                             d.pre = 10,
                                             lambda = spadd.presmth.Legr.cv.out$cv.lambda,
                                             eta = spadd.presmth.Legr.cv.out$cv.eta,
                                             n.foi = 6)

plot_presmth_Legr(x = spadd.presmth.Legr.out,
                  true.functions = list( f = data$f,
                                         X = data$X))

gregorkb/spaddinf documentation built on Oct. 29, 2024, 3:17 p.m.