Skip to contents

Predictor variables can have any marginal distribution as long as a function is provided to sample from the distribution. Multivariate distributions are also supported: if the random generation function returns multiple columns, multiple random variables will be created, successively numbered.


predictor(dist, ...)



Name (as character vector) of the function to generate draws from this predictor's distribution.


Additional arguments to pass to dist when generating draws.


A predictor_dist object, to be used in population() to specify a population distribution


The random generation function must take an argument named n specifying the number of draws. For univariate distributions, it should return a vector of length n; for multivariate distributions, it should return an array or matrix with n rows and a column per variable.

Multivariate predictors are successively numbered. For instance, if predictor X is specified with

predictor(dist = "rmvnorm", mean = c(0, 1),
          sigma = matrix(c(1, 0.5, 0.5, 1), nrow = 2))

then the population predictors will be named X1 and X2, and will have covariance 0.5.


# Univariate normal distribution
predictor(dist = "rnorm", mean = 10, sd = 2.5)
#> rnorm(list(mean = 10, sd = 2.5))

# Multivariate normal distribution
predictor(dist = "rmvnorm", mean = c(0, 1, 7))
#> rmvnorm(list(mean = c(0, 1, 7)))