Description Usage Arguments Value Author(s) Examples
sim_model
simulate a database based on common models. The structure
used to create the data is similar as the bamlss.formula
.
1 2 3 4 |
formula |
List of the parameters, indicating how they should be computed.
similar to formula for |
link_inv |
A list of function representing the inverse link function for the parameters. |
generator |
Function to generate the response variables given the parameters |
n |
Number of observations to be simulated |
responses |
a numeric value indicating the number of response or a character vector indicating the names of the response variables |
init_data |
Initial data including some variables to not been simulated. |
lm_syntax |
Optional logical argument to indicate if the usual syntax of
|
effects_save |
Optional logical argument to save or not generated random effects |
seed |
Seed to be defined with function |
A tibble
containing the simulated predictors, parameters and response
variable
Erick A. Chacon-Montalvan
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 31 32 33 34 | f <- list(
mean ~ I(5 + 0.5 * x1 + 0.1 * x2 + 0.7 * id1),
sd ~ exp(x1)
)
(model_frame(f, n = 10))
(data <- sim_model(f, n = 100))
# Structure of the model
formula <- list(
mean ~ I(age ^ 2) + fa(sex, beta = c(-1, 1)),
sd ~ fa(sex, beta = c(1, 2))
)
idata <- data.frame(s1 = 1:10)
(datasim <- model_frame(formula, idata = idata))
(datasim <- model_frame(formula, n = 10))
(data <- model_frame(formula, n = 10))
(model_response(data))
(datasim2 <- sim_model(formula, n = 10))
library(magrittr)
model_frame(formula, n = 10) %>% model_response()
f <- list(
mean ~ gp(list(s1), "exp_cor", list(phi = 0.05)),
sd ~ I(1.6)
)
(data <- sim_model(f, n = 400))
plot(mean ~ s1, data)
plot(response ~ s1, data)
formula <- list(
mean ~ I(0.5 * x1) : I(x2) + re(city, 1, 2),
sd ~ I(1)
)
data <- sim_model(formula, n = 10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.