data.simulator: Generate simulated meta-analysis data for testing purposes.

Description Usage Arguments Value Examples

View source: R/data.simulator.r

Description

Creates a raw data frame with specified number of trials, arms per trial, and features dependent on the type of response variable. This raw data can then be passed through to the data.prep and net.tab() functions for modeling purposes. The number of patients per trial are generated uniformly between the minimum and maximum numbers specified. Note that the resultant network is not guaranteed to be connected, and this criteria should be verified before model fitting.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data.simulator(
  nstudies,
  response,
  ntreatments,
  seed,
  min.patients,
  max.patients,
  event_p,
  exp_rate,
  cont_mean,
  cont_var,
  cont_error,
  pt_rate,
  count_mean,
  min_time,
  max_time
)

Arguments

nstudies

The number of studies in the simulated data set. Must be specified.

response

The type of response variable in each study; one of ("rate", "binary", "continuous", "rate2"), similar to net.tab() "rate" data includes number of events, sample size, and person-time at risk. Number of events for treatment i are generated from a Poisson distribution with mean from the ith element of count_mean, and person-time at risk from an exponential distribution with mean pt.rate. "binary" data includes number of events and sample size. The number of events are generated from a binomial distribution with treatment-dependent probability and sample size equal to the number of patients in each arm/trial. "rate2" data includes number of events, sample size, and median follow-up time. The number of events are generated from a binomial distribution with treatment-dependent probability as in the binomial case, and follow-up time generated from a Uniform(min_time, max_time) distribution for all treatments. "continuous" data includes mean response metric, sample size, and response metric standard error. Values for treatment i are simulated from Normal(cont_mean, cont_var) with corresponding standard errors generated uniformly from 0 to cont_error.

ntreatments

The total number of possible unique treatments in the network, which are randomly sampled and assigned to treatment arms. Must be specified.

seed

The seed value of the function for reproducibility (optional parameter).

min.patients

The minimum number of patients per trial. Must be specified.

max.patients

The maximum number of patients per trial. Must be specified.

event_p

The probability vector of an event occurring per individual, used for binary and rate2 data. Default is 0.5, and elements must be greater than 0 and less than or equal to 1. The vector length must be equal to the number of treatments, in which the ith element is the probability of outcome for treatment i.

exp_rate

The mean of the exponential distribution for follow-up times for rate2 data, parameterized as 1/lambda. Default is 0.01. Specified as a scalar; the follow-up times are assumed to be equal for both arms of the same trial.

cont_mean

The mean of the response variable for 'continuous' response data. Default is 0. Specified as a vector with length equal to the number of treatments, in which the ith element is the mean for treatment i.

cont_var

The standard error of the response variable for 'continuous' response data. Default is 1. Specified as a vector with length equal to the number of treatments, in which the ith element is the variance for treatment i.

cont_error

The maximum standard error of the response metric for each trial. Default is 1. Specified as a vector with length equal to the number of treatments, in which the ith element is the error for treatment i.

pt_rate

The mean of the exponential distribution for time-at-risk per person for 'rate' data, parametrized as 1/lambda. Default is 0.01. Specified as a scalar; the follow-up times per patient are generated to be the same for each arm within the same trial, and then get scaled by the number of patients in each arm.

count_mean

The mean of the Poisson distribution used to generate count data for 'rate' response data. Counts are generated by multiplying the rate parameter by the time-at-risk per person. Specified as a vector equal to the length of unique treatments.

min_time

The minimum of the uniform distribution which will be used to generate follow-up times for 'rate2' data.

max_time

The maximum of the uniform distribution which will be used to generate follow-up times for 'rate2' data.

Value

Data frame with studies, arms, sample sizes, and the parameters dependent on the selected response.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
data.simulator(nstudies=30, response="binary", ntreatments=5, seed=20,
min.patients=100, max.patients=500, 
event_p=c(0.05, 0.10, 0.15, 0.07, 0.09))

data.simulator(nstudies=12, response="continuous", 
ntreatments=6, seed=13, min.patients=30, max.patients=200)

data.simulator(nstudies=40, response="rate", ntreatments=5, seed=30,
min.patients=1000, max.patients=1200, 
pt_rate = 1000*0.5, count_mean = c(45, 35, 47, 40, 42))

data.simulator(nstudies=20, response="rate2", ntreatments=6, seed=13,
min.patients=40, max.patients=500, min_time=3, max_time=5,
event_p = c(0.21, 0.5, 0.2, 0.3, 0.5, 0.55))

## End(Not run)

augustinewigle/StanNet documentation built on July 21, 2020, 12:13 a.m.