Skip to contents

Simulate a sparse quantile-regression problem

Usage

simulate_quantile_data(
  n = 200,
  p = 40,
  active = 1:5,
  beta = c(2, 1.5, -1.5, 1, -1),
  tau = 0.5,
  rho = 0.7,
  correlation = c("toeplitz", "block"),
  block_size = 5L,
  error = c("gaussian", "student", "laplace", "heteroskedastic"),
  error_df = 3,
  heteroskedastic_strength = 0.75,
  seed = NULL
)

Arguments

n

Number of observations.

p

Number of predictors.

active

Indices of active predictors.

beta

Coefficients for the active predictors. Recycled as needed.

tau

Quantile level whose conditional linear predictor is controlled.

rho

Toeplitz correlation parameter for the predictors.

correlation

Correlation structure. One of "toeplitz" or "block".

block_size

Block size used when correlation = "block".

error

Error distribution. One of "gaussian", "student", "laplace", or "heteroskedastic".

error_df

Degrees of freedom when error = "student".

heteroskedastic_strength

Positive scale multiplier used when error = "heteroskedastic".

seed

Optional random seed.

Value

A list containing x, y, beta, active, tau, and the simulation settings used to generate the data.

Examples

sim <- simulate_quantile_data(seed = 42)
str(sim, max.level = 1)
#> List of 9
#>  $ x          : num [1:200, 1:40] 0.906 -0.457 0.911 1.373 -0.415 ...
#>   ..- attr(*, "dimnames")=List of 2
#>  $ y          : num [1:200] -1.356 -0.868 1.324 5.481 -1.908 ...
#>  $ beta       : num [1:40] 2 1.5 -1.5 1 -1 0 0 0 0 0 ...
#>  $ active     : chr [1:5] "x1" "x2" "x3" "x4" ...
#>  $ tau        : num 0.5
#>  $ rho        : num 0.7
#>  $ correlation: chr "toeplitz"
#>  $ block_size : int 5
#>  $ error      : chr "gaussian"