Simulate a sparse quantile-regression problem
Source:R/simulate_quantile_data.R
simulate_quantile_data.RdSimulate a sparse quantile-regression problem
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"