`R/make_1way_rb_data.R`

`make_1way_rb_data.Rd`

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_1way_rb_data(Group_means, Num_exp, Exp_SD, Residual_SD)`

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

- 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 experiments, i.e. within RandFac.

- Residual_SD
a single numeric value indicating residual SD in the model.

This function produces a `data.frame`

object containing simulated data.

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 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.

```
#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 112 13.4 205.1 269.6 74.7 ...
head(two_rb_tab)
#> RandFac FixFac_1 FixFac_2 Values
#> 1 Exp_1 Fx1Lev_1 Fx2Lev_1 112.005786
#> 2 Exp_1 Fx1Lev_1 Fx2Lev_2 13.430954
#> 3 Exp_1 Fx1Lev_2 Fx2Lev_1 205.062886
#> 4 Exp_1 Fx1Lev_2 Fx2Lev_2 269.565860
#> 5 Exp_2 Fx1Lev_1 Fx2Lev_1 74.738934
#> 6 Exp_2 Fx1Lev_1 Fx2Lev_2 1.829118
```