The make_1way_data, make_1way_rb_data, make_2way_data and make_2way_rb_data functions generate independent or randomised block (rb) design data of one-way or two-way designs.

make_2way_rb_data(Group1_means, Group2_means, Num_exp, Exp_SD, Residual_SD)

Arguments

Group1_means

a vector with means of each level of the first fixed factor (FixFac_X1) measured within Group 1.

Group2_means

only for make_2way_data and make_2way_rb_data: a vector with mean(s) of each level of FactorX2 measured within Group 2.

Num_exp

a single numeric value indicating the number of independent measurements, i.e. levels within the random factor RandFac.

Exp_SD

a single numeric value indicating the standard deviation (SD) between experiment, i.e. within RandFac.

Residual_SD

a single numeric value indicating residual SD in the model.

Value

This function produces a data.frame object containing simulated data.

Details

Random variates from the normal distribution based on user provided mean and SD provided are generated. For independent designs, the Residual_SD argument is used to set expected residual SD from the linear model. Exp_SD is used to set experiment-to-experiment SD, that will be assigned to the random factor (RandFac) for rb designs.

Num_exp sets the number of independent measurements per group.

For one-way designs, the user provides Group_means as a vector. Number of levels are recognised based on number of means. For two-way designs, two vectors are to be provided by the user containing means of levels of a second factor. Number of means in both vectors should be the same. These functions can only handle balanced designs, i.e. same number of observations in all groups.

The output is a data frame with one or two columns denoting the fixed factor with levels that match the number of means entered. For rb data, the column for RandFac denotes levels of the blocking factor. The quantitative response variables are in the numeric Values column.

Examples

#Basic usage with two levels within FactorX2, 
#20 experiments with inter-experiment SD 20, and residual SD 15

two_rb_tab <- make_2way_rb_data(c(100, 20), c(200, 300), 20, 20, 15)

str(two_rb_tab)
#> 'data.frame':	80 obs. of  4 variables:
#>  $ RandFac : Factor w/ 20 levels "Exp_1","Exp_10",..: 1 1 1 1 12 12 12 12 14 14 ...
#>  $ FixFac_1: Factor w/ 2 levels "Fx1Lev_1","Fx1Lev_2": 1 1 2 2 1 1 2 2 1 1 ...
#>  $ FixFac_2: Factor w/ 2 levels "Fx2Lev_1","Fx2Lev_2": 1 2 1 2 1 2 1 2 1 2 ...
#>  $ Values  : num  119.2 46.2 203.4 296.2 99 ...
head(two_rb_tab)
#>   RandFac FixFac_1 FixFac_2      Values
#> 1   Exp_1 Fx1Lev_1 Fx2Lev_1 119.1791237
#> 2   Exp_1 Fx1Lev_1 Fx2Lev_2  46.2178741
#> 3   Exp_1 Fx1Lev_2 Fx2Lev_1 203.3521137
#> 4   Exp_1 Fx1Lev_2 Fx2Lev_2 296.1597129
#> 5   Exp_2 Fx1Lev_1 Fx2Lev_1  99.0431957
#> 6   Exp_2 Fx1Lev_1 Fx2Lev_2   0.9698832