Learn R Programming

QualityMeasure (version 2.0.1)

simulateData: Simulate data

Description

This function simulates some data.

Usage

simulateData(
  n.entity,
  n.obs,
  mu,
  sd = 1,
  r,
  beta1 = 0,
  data.type = "binary",
  dist = "normal"
)

Value

A dataframe of simulated data.

Arguments

n.entity

total number of entities to simulate

n.obs

average number of observations per entity; entity sample sizes are simulated from a Poisson distribution with mean given by n.obs OR a vector of length n.entity with entity sample sizes

mu

average probability of the outcome for binary data OR average outcome value for Normal data

sd

within-entity standard deviation for Normal data (default is 1).

r

median reliability

beta1

regression coefficient for covariate added to the linear predictor; default is 0. Note that for binary data, beta1 is on the log odds scale (e.g., beta1 = 0.4 corresponds to an odds ratio of about 1.5).

data.type

type of data to simulate. Valid options include: binary (default) and normal.

dist

specifies the distribution family to use to simulate provider performance. Valid options include: normal (default) and beta.

Author

Kenneth Nieser (nieser@stanford.edu)

Examples

Run this code
# number of accountable entities
n.entity = 100

# average number of patients or cases per accountable entity
n.obs = 50

# marginal probability of the outcome
mu = 0.1

# approximate reliability for entity with a median number of patients
r = 0.6

# parameter for risk-adjustment model (i.e., coefficient for x1)
beta1 = log(1.5)

df <- simulateData(n.entity = n.entity, n.obs = n.obs, mu = mu, r = r, beta1 = beta1)
head(df)

Run the code above in your browser using DataLab