Description Usage Arguments Details Value See Also Examples

Quickly create a dataframe of uncorrelated random variables which can be used as covariates. Values are drawn from the normal, uniform, beta, binomial, poisson or bernoulli distributions.

1 | ```
simCovariate(cov.list = NULL, ..., n, add.yr = TRUE)
``` |

`cov.list` |
A named list of covariates to be simulated and their required arguments. |

`...` |
additional arguments to be passed to |

`n` |
The number of samples to generate from each covariate. |

`add.yr` |
Logical, if |

`simCovariate`

will create a vector(s) of random variables from a specified R probability distribution. The distribution can be specified by entering the name or the name of the R function; partial matching is performed. For example, specifying a distribution as runif, 'runif', uniform, or u can be be used to generate random samples from a uniform distribution, in which case R's `runif`

function is called. Additional arguments to the `runif`

function are separated by commas. The function can be parameterized so that multiple covariates can be simulated from either the same distribution or from different distributions.

A data frame of random numbers from the specified distribution, with number of columns equal to the the number of cov.names (ncol=length(cov.names)).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ```
# We can specify the distribution using a function, function name,
# or distribution name. Partial matching is performed. The examples
# below generate data for a single covariate; random seeds are not
# provided.
# All four examples provide same results and generate 10 random numbers
# from a uniform distribution. In some examples the results are rounded;
# in other examples add.yr is set to TRUE to add a covariate called yr (year);
# in other examples a random seed is provided to ensure reproducibility.
simCovariate(u1 =list(dist= runif), n=10, add.yr=FALSE)
simCovariate(u2=list(dist = 'runif', round=2), n = 10, add.yr=TRUE)
simCovariate(u3=list(dist ='uniform', seed=302), n=10, add.yr=TRUE)
simCovariate(u4 = list(dist ='u', seed=302, round=3, min=0, max=10), n=10, add.yr=TRUE)
# If multiple covariates are to be simulated, create a list of covariates
# and then pass this covariate list as the argument, cov.list. Here, create
# a dataframe with seven covariates from five distributions, and
# add a covariate called yr.
cov.list <- list(
unif1 = list(dist = 'runif', min=0, max=10, seed=334, round=0),
unif2 = list(dist = 'runif', min=0, max=10, seed=668, round=0),
norm1=list(dist = 'normal', mean = 10,sd = 2, seed=10, round=1),
norm2=list(dist = 'normal', mean = 50, sd = 10, seed=15, round=2),
beta1=list(dist = rbeta, shape1=2, shape2=1, seed=1002),
binom1=list(dist = 'bin', size=20, prob=0.5, seed=561),
bern1=list(dist='bernoulli', size = 1, prob = 0.5, seed = 6)
)
simCovariate(cov.list, n = 10, add.yr = TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.