Learn R Programming

abms (version 0.1)

gen_base_NegBinomial_reg: 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)

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.

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.

Examples

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

Run the code above in your browser using DataLab