Learn R Programming

abms (version 0.2)

gen_base_binomial_reg: Logistic Regression Data generator

Description

It generates N observations of the Binomial distribution with parameters ni (the i-th's individual sizes) and p (the success probability), where the coefficients are indexed on p via the logistic function.

Usage

gen_base_binomial_reg(N, beta, Covariates, ni = rep(1, N))

Value

The function return a table with the sample of size N from the Binomial distribution indexed with the predictors indicated in the Covariates argument, the ni, the number of failures (ni - y), and the predictors for each individual .

Arguments

N

The number of observations that will be generated. It must be a positive integer.

beta

A vector of coefficients including the intercept. It can be a matrix.

Covariates

A data.frame object with the predictors (without intercept) for which we want to test if they are relevant to the response variable. It can also be a (\(n x p\)) matrix.

ni

A vector of size \(n\) that represent the i-th individual size (the size parameter of the binomial distribution). It can also be a (\(n x 1\)) matrix. For default, all individual size are fixed at 1.

Examples

Run this code
N<-200    #Number of extractions
beta<-c(1, 0, 2, 0, 3, 2)    #Coefficient vector
p<-length(beta)
aux_cov<-rnorm((p-1)*N, 0,1)
Covariates<-data.frame(matrix(aux_cov, ncol=p-1, nrow=N))   #Generating the Covariates data.frame
colnames(Covariates)<-c("X1", "X2", "X3", "X4", "X5")
base<-gen_base_binomial_reg(N, beta, Covariates, ni=rep(1, N))    #Generating the data
base

Run the code above in your browser using DataLab