Learn R Programming

ELCIC (version 0.2.1)

glm.generator: Cross-sectional data generation under GLM

Description

A function provides simulated outcomes as well as covariates under the framework of GLM. All covariates (except for intercept) are normally distributed.

Usage

glm.generator(beta, samplesize, rho = 0, dist, sd.gaussian = NULL, ov = NULL)

Value

x: a matrix containing continuous covariates. The first column should contain all ones corresponding to the intercept.

y: a vector containing outcomes.

Arguments

beta

The underlying true coefficient for each covariates in the model (including the intercept).

samplesize

The sample size.

rho

The correlation coefficient among covariates.

dist

A specified distribution. It can be "gaussian", "poisson",and "binomial".

sd.gaussian

The standard deviation for the outcome from Gaussian distribution.

ov

The dispersion parameter for the outcome from Negative Binomial distribution.

Examples

Run this code
beta<-c(0.5,0.5,0.5,0)
samplesize<-100
data<-glm.generator(beta=beta,samplesize=samplesize,rho=0.5,dist="poisson")

Run the code above in your browser using DataLab