
Simulate Model Matrix and Response Vector
simulXy.RdGenerates synthetic covariates and response vector from a specified distribution for simulation studies or method validation.
Arguments
- n
Integer. Number of observations.
- p
Integer. Total number of covariates in the model matrix.
- interc
Numeric. Intercept to include in the linear predictor. Default is
0.- beta
Numeric vector of length
p. Regression coefficients in the linear predictor.- family
Distribution and link function. Allowed:
gaussian(),binomial(),poisson()and ,Gamma(). Can be a string, function, or family object.- prop
Numeric in
[0,1]. Used only ifbetais missing; proportion of non-zero coefficients inp. Default is0.1.- lim.b
Numeric vector of length 2. Range for coefficients if
betais missing. Default:c(-3, 3).- sigma
Standard deviation of Gaussian response. Default is
1.- size
Integer. Number of trials for binomial response. Default is
1.- rho
Numeric. Correlation coefficient for generating covariates. Used to create AR(1)-type covariance:
rho^|i-j|. Default is0.- scale.data
Logical. Whether to scale columns of the model matrix. Default is
TRUE.- seed
Optional. Integer seed for reproducibility.
- X
Optional. Custom model matrix. If supplied, it overrides the internally generated
X.- dispersion
Dispersion parameter of Gamma response. Default is
0.1.
Value
A list with components:
- X
Model matrix of dimension
n x p- y
Simulated response vector
- beta
True regression coefficients used
- eta
Linear predictor
Author
Gianluca Sottile gianluca.sottile@unipa.it
Examples
n <- 100; p <- 100
beta <- c(runif(10, -3, 3), rep(0, p - 10))
sim <- simulXy(n = n, p = p, beta = beta, seed = 1234)
o <- islasso(y ~ ., data = sim$data, family = gaussian())
summary(o, pval = 0.05)
#>
#> Call:
#> islasso(formula = y ~ ., family = gaussian(), data = sim$data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -2.0207 -0.5354 -0.1112 0.5046 2.0074
#>
#> Estimate Std. Error Df z value Pr(>|z|)
#> (Intercept) -0.1159 0.1144 1.000 -1.013 0.31097
#> X1 -0.5340 0.1295 1.000 -4.125 3.71e-05 ***
#> X2 1.3127 0.1331 1.000 9.861 < 2e-16 ***
#> X3 -1.9439 0.1324 1.000 -14.677 < 2e-16 ***
#> X4 -0.7204 0.1402 1.000 -5.137 2.79e-07 ***
#> X5 1.1275 0.1313 1.000 8.589 < 2e-16 ***
#> X6 1.9117 0.1363 1.000 14.029 < 2e-16 ***
#> X7 -0.9386 0.1307 1.000 -7.181 6.94e-13 ***
#> X8 -2.1288 0.1376 1.000 -15.467 < 2e-16 ***
#> X9 0.4326 0.1361 0.997 3.178 0.00148 **
#> X20 -0.2560 0.1267 0.929 -2.021 0.04328 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for gaussian family taken to be 1.308101)
#>
#> Null deviance: 1928.071 on 99.00 degrees of freedom
#> Residual deviance: 77.121 on 58.96 degrees of freedom
#> AIC: 159.21
#> Lambda: 10.063
#>
#> Number of Newton-Raphson iterations: 102
#>