powered by
A function provides simulated outcomes as well as covariates under the framework of GLM. All covariates (except for intercept) are normally distributed.
glm.generator(beta, samplesize, rho = 0, dist, sd.gaussian = NULL, ov = NULL)
x: a matrix containing continuous covariates. The first column should contain all ones corresponding to the intercept.
y: a vector containing outcomes.
The underlying true coefficient for each covariates in the model (including the intercept).
The sample size.
The correlation coefficient among covariates.
A specified distribution. It can be "gaussian", "poisson",and "binomial".
The standard deviation for the outcome from Gaussian distribution.
The dispersion parameter for the outcome from Negative Binomial distribution.
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