gen.binomial.data: Simulate a binomial data set

View source: R/data.R

gen.binomial.dataR Documentation

Simulate a binomial data set

Description

Simulate a data set with binary response following the logistic regression model.

Usage

gen.binomial.data(n, p, rho = 0, kappa = 5, beta.type = 1, seed = 2021)

Arguments

n

Sample size.

p

Number of covariates.

rho

The parameter defining the AR(1) correlation matrix.

kappa

The number of nonzero coefficients.

beta.type

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.

seed

The seed for reproducibility. Default is 2021.

Value

A list containing the simulated data.

X

the covariate matrix, of dimension n x p.

y

the response, of length n.

beta

the true coefficients, of length p.

Examples

bin_data <- gen.binomial.data(n = 200, p = 20, seed = 2021)
head(bin_data$X)
head(bin_data$y)
head(bin_data$beta)


glmtlp documentation built on March 18, 2022, 7:59 p.m.