Simulate Data from logistic mixed model or poisson-normal model

Description

This function will simulate the data for the logistic mixed model: logit(y_ij)=mu+sigma* theta_i or the poisson-normal model: log(y_ij)=mu+sigma* theta_i where theta_i is N(0,1) in either case.

Usage

1
sim.data.fun(num_subs = NULL, obs_per_sub = NULL, true.mu = NULL, true.sigma = NULL,family="binomial", set.seed = NULL)

Arguments

num_subs

Index of i (number of subjects); default is NULL

obs_per_sub

Vector of length num_subs; Index of j (number of observations per subject); default is NULL

true.mu

True value of mu; default is NULL

true.sigma

True value of sigma; default is NULL

family

Exponential family from which to generate top level of hierarchy; default is "binomial"

set.seed

Random seed start value for reproducibility; default is NULL

Details

The user must enter values for num_subs, obs_per_sub, true.mu and true.sigma or the function will produce an error. The set.seed argument is optional.

Value

y

a matrix of generated y_ij of dimension num_subs* max(obs_per_sub)

y.i

a vector of the sums over j of y_ij; this will have length num_subs

n.i

a vector of the number of observations for each subject; this should exactly match obs_per_sub

Author(s)

Lindsey Dietz