Learn R Programming

wgeesel (version 1.5)

data_sim: Simulate longitudinal data

Description

The function generate correlated normal, Bernoulli or Poisson longitudinal data.

Usage

data_sim(id, rho, phi, x, beta, x_mis, para, corstr, family, lag_level)

Arguments

id

subject id

rho

with-in cluster correlation.

phi

scale parameter in the variance covariance matrix.

x

covariate associated with the response.

beta

coefficients associated with x.

x_mis

covariates associated with missing model.

para

coefficients associated with x_mis.

corstr

a character string specifies the working correlation structure. The following are permitted: "independence", "exchangeable","ar1".

family

a description of the error distribution and link function to be used in the model. This is a character string naming a family function. The following are permitted: "gaussian", "binary", "poisson".

lag_level

specify how many lags of response y will affect missing probability.

Value

data

simulated dataset

prob_miss

missing percentage of the response y

Details

Generate normal, poisson and binary longitudinal data based on the specified variance-covariance matrix.

Examples

Run this code
# NOT RUN {
n=500
id=rep(1:n,each=3)
rho=1
phi=1
x=cbind(1,rnorm(length(id)))
beta=c(1,1)
x_mis=cbind(1,rnorm(length(id)))
para=c(1,1,1)
data_sim(id,rho,phi,x,beta,x_mis,para,"independent","gaussian",lag_level = 1)
# }

Run the code above in your browser using DataLab