gen_base_NegBinomial_reg: Negative Binomial Regression Data generator

View source: R/abms.R

gen_base_NegBinomial_regR Documentation

Negative Binomial Regression Data generator

Description

It generates N observations of the Negative binomial distribution with parameters r (number of success) and p (success probability), where the coefficients are indexed on p via the logistic function.

Usage

gen_base_NegBinomial_reg(N, beta, r, Covariates)

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.

r

The number of success parameter. It must be a positive integer.

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.

Value

The function return a sample of size N from the Negative binomial distribution indexed with the predictors indicated in the Covariates argument, and the predictors for each individual.

Examples

N<-10   #Number of extractions
beta<-c(0.5, -0.8,  1.0,  0,  0.4, -0.7)  #Coefficient vector
p<-length(beta)
r<-2    #Number of success parameter
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_NegBinomial_reg(N, beta, r, Covariates)    #Generating the data
base

abms documentation built on April 12, 2025, 1:31 a.m.