Append simulated continuous covariates
Source:R/brm_simulate_continuous.R
brm_simulate_continuous.Rd
Simulate and append non-time-varying continuous
covariates to an existing brm_data()
dataset.
Arguments
- data
Classed
tibble
as frombrm_data()
orbrm_simulate_outline()
.- names
Character vector with the names of the new covariates to simulate and append. Names must all be unique and must not already be column names of
data
.- mean
Numeric of length 1, mean of the normal distribution for simulating each covariate.
- sd
Positive numeric of length 1, standard deviation of the normal distribution for simulating each covariate.
Value
A classed tibble
, like from brm_data()
or
brm_simulate_outline()
, but with new numeric covariate columns
and with the names of the new covariates appended to the
brm_covariates
attribute.
Details
Each covariate is a new column of the dataset with one independent random univariate normal draw for each patient. All covariates simulated this way are independent of everything else in the data, including other covariates (to the extent that the random number generators in R work as intended).
See also
Other simulation:
brm_simulate_categorical()
,
brm_simulate_outline()
,
brm_simulate_prior()
,
brm_simulate_simple()
Examples
data <- brm_simulate_outline()
brm_simulate_continuous(
data = data,
names = c("age", "biomarker")
)
#> # A tibble: 800 × 7
#> response missing group time patient age biomarker
#> <dbl> <lgl> <chr> <chr> <chr> <dbl> <dbl>
#> 1 NA FALSE group_1 time_1 patient_001 -0.0499 -1.30
#> 2 NA FALSE group_1 time_2 patient_001 -0.0499 -1.30
#> 3 NA FALSE group_1 time_3 patient_001 -0.0499 -1.30
#> 4 NA FALSE group_1 time_4 patient_001 -0.0499 -1.30
#> 5 NA FALSE group_1 time_1 patient_002 1.75 0.592
#> 6 NA FALSE group_1 time_2 patient_002 1.75 0.592
#> 7 NA FALSE group_1 time_3 patient_002 1.75 0.592
#> 8 NA FALSE group_1 time_4 patient_002 1.75 0.592
#> 9 NA FALSE group_1 time_1 patient_003 0.400 1.05
#> 10 NA FALSE group_1 time_2 patient_003 0.400 1.05
#> # ℹ 790 more rows
brm_simulate_continuous(
data = data,
names = c("biomarker1", "biomarker2"),
mean = 1000,
sd = 100
)
#> # A tibble: 800 × 7
#> response missing group time patient biomarker1 biomarker2
#> <dbl> <lgl> <chr> <chr> <chr> <dbl> <dbl>
#> 1 NA FALSE group_1 time_1 patient_001 1154. 1066.
#> 2 NA FALSE group_1 time_2 patient_001 1154. 1066.
#> 3 NA FALSE group_1 time_3 patient_001 1154. 1066.
#> 4 NA FALSE group_1 time_4 patient_001 1154. 1066.
#> 5 NA FALSE group_1 time_1 patient_002 1108. 1084.
#> 6 NA FALSE group_1 time_2 patient_002 1108. 1084.
#> 7 NA FALSE group_1 time_3 patient_002 1108. 1084.
#> 8 NA FALSE group_1 time_4 patient_002 1108. 1084.
#> 9 NA FALSE group_1 time_1 patient_003 714. 1111.
#> 10 NA FALSE group_1 time_2 patient_003 714. 1111.
#> # ℹ 790 more rows