Learn R Programming

islasso (version 1.6.0)

simulXy: Simulate Model Matrix and Response Vector

Description

Generates synthetic covariates and response vector from a specified distribution for simulation studies or method validation.

Usage

simulXy(
  n,
  p,
  interc = 0,
  beta,
  family = gaussian(),
  prop = 0.1,
  lim.b = c(-3, 3),
  sigma = 1,
  size = 1,
  rho = 0,
  scale.data = TRUE,
  seed = NULL,
  X = NULL,
  dispersion = 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

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 if beta is missing; proportion of non-zero coefficients in p. Default is 0.1.

lim.b

Numeric vector of length 2. Range for coefficients if beta is 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 is 0.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab