
Last chance! 50% off unlimited learning
Sale ends in
Simulate a data set with binary response following the logistic regression model.
gen.binomial.data(n, p, rho = 0, kappa = 5, beta.type = 1, seed = 2021)
A list containing the simulated data.
the covariate matrix, of dimension n
x p
.
the response, of length n
.
the true coefficients, of length p
.
Sample size.
Number of covariates.
The parameter defining the AR(1) correlation matrix.
The number of nonzero coefficients.
Numeric indicator for choosing the beta type. For
beta.type = 1
, the true coefficient vector has kappa
components being 1,
roughly equally distributed between 1 to p
. For beta.type = 2
,
the first kappa
values are 1, and the rest are 0. For beta.type = 3
,
the first kappa
values are equally-spaced values from 10 to 0.5, and
the rest are 0. For beta.type = 4
, the first kappa
values are
the first kappa
values in c(-10, -6, -2, 2, 6, 10), and the rest are
0. For beta.type = 5
, the first kappa
values are 1, and the
rest decay exponentially to 0 with base 0.5.
The seed for reproducibility. Default is 2021.
bin_data <- gen.binomial.data(n = 200, p = 20, seed = 2021)
head(bin_data$X)
head(bin_data$y)
head(bin_data$beta)
Run the code above in your browser using DataLab