Description Usage Arguments Value Author(s) See Also Examples
Simulate ecological data and samples of individuallevel data from an individuallevel logistic regression model, depending on given binary, categorical or normallydistributed covariates.
1 2 
N 
Vector of population sizes, one for each group. 
ctx 
A model formula containing names of grouplevel, or contextual, covariates on the righthand side. 
binary 
A model formula containing names of individuallevel binary covariates on the righthand side. 
data 
Data frame containing the grouplevel variables given in

m 
A data frame with 
S 
A data frame with 
cross 
A matrix of crossclassifications of individuals in the
area between categories of multiple binary or categorical covariates, defined in
the same way as in 
covnames 
Vector of names of the covariates, if 
ncats 
Numeric vector of the number of levels of the
covariates used in 
mu 
Regression intercept on the logit scale. 
alpha.c 
Vector of coefficients for the grouplevel
covariates in the underlying logistic regression, corresponding to
the columns of 
alpha 
Vector of coefficients for the individuallevel
binary covariates, corresponding to the columns of

beta 
Vector of coefficients for the individuallevel
continuous covariates, corresponding to the columns of 
sig 
Randomeffects standard deviation. 
strata 
A matrix with rows representing groups, and columns representing strata occupancy probabilities. 
pstrata 
A vector with one element for each stratum, giving
the assumed baseline outcome probabilities for the strata. The
logits of 
isam 
Number of individuals per group to retain in the individuallevel data. 
A list with components:
y 
The simulated aggregatelevel response, one for each group. 
idata 
A data frame containing the retained individuallevel
samples. The grouping indicator (with values 
C. H. Jackson chris.jackson@mrcbsu.cam.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13  N < rep(50, 20)
ctx < cbind(deprivation = rnorm(20), mean.income = rnorm(20))
phi < cbind(nonwhite = runif(20), smoke = runif(20))
sim.df < as.data.frame(cbind(ctx, phi))
mu < qlogis(0.05) ## Disease with approximate 5% prevalence
## Odds ratios for grouplevel deprivation and mean imcome
alpha.c < c(1.01, 1.02)
## Odds ratios for individuallevel ethnicity and smoking
alpha < c(1.5, 2)
sim.eco(N, ctx = ~ deprivation + mean.income, binary = ~ nonwhite +
smoke, data=sim.df, mu=mu, alpha.c=alpha.c, alpha=alpha)
sim.eco(N, ctx = ~ deprivation + mean.income, binary = ~ nonwhite +
smoke, data=sim.df, mu=mu, alpha.c=alpha.c, alpha=alpha, isam=3)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.