Description Usage Arguments Details Value See Also Examples
Simulates data with categorial covariates/categorial effect modifiers
1 2 | simulation(n, covariates, correlation = NULL, formula, coefficients,
family, sd = 1, seed = rpois(1, 2348) * rnorm(1))
|
n |
number of observations; must be large enough, so that all categories of all factor variables exist and therefore vector |
covariates |
description of the covariates and effect modifiers included in the model; format: |
correlation |
optional matrix, specifies the correlation of Gaussian covariates |
formula |
formula like in |
coefficients |
true parameter vector |
family |
a |
sd |
if |
seed |
specifies the to be used seed |
Remarks on covariates:
all parameterizations like default in Distributions
.
possible distributions of covariates (required as characters), their parameters (required as vectors) and constraints (in parentheses):
beta
: shape1 (>0), shape2 (>0)
exp
: rate (>0)
gamma
: shape (>0)
lnorm
: mean , sd (>0)
multinom
: vector of the categories' probabilities (all elements must be >0, sum over all elements must be 1)
norm
: mean, sd (>0)
pois
: lambda (>0)
unif
: min, max
level of measurement
is only needed for distribution = "multinom"
, must be "nominal"
or "ordinal"
.
If any, the covariates' correlation is specified by argument correlation
.
Correlations are defined for Gaussian covariates only.
Matrix correlation
refers to these covariates according to the order they are listed in covariates
. So that the dimensions of correlation
must fit to the number of normal distributed variables in covariates
.
A data frame containing all specified covariates (even if they are not included in formula
) and the response (named y
)
Function gvcm.cat
1 2 3 4 5 6 7 8 9 | ## example function simulation
covariates <- list(x1=list("unif", c(0,2)),
x2=list("unif", c(0,2)),
x3=list("unif", c(0,2)),
u=list("multinom",c(0.3,0.4,0.3), "nominal")
)
true.f <- y ~ 1 + v(x1,u) + x2
true.coefs <- c(0.2, 0.3,.7,.7, -.5)
data <- simulation(400, covariates, NULL, true.f, true.coefs , binomial(), seed=456)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.