View source: R/independent_twoway_generation.R
twoway_simulation_independent | R Documentation |
Both regular and internal function.
As regular function takes input generated by the calculate_mean_matrix
function and iteratively simulates independent measures two-way factorial experiments.
Outcome may be normally distributed, have a skewed normal distribution or a truncated normal distribution.
twoway_simulation_independent(
group_size,
matrices_obj,
distribution = "normal",
skewness = 1,
inferior_limit = -Inf,
superior_limit = Inf,
balanced = TRUE,
nsims = 200
)
group_size |
Integer or matrix - Sample size for each condition (combination of factor levels). If |
matrices_obj |
List - Output generated by |
distribution |
Character - Type of distribution to simulate. Possible values are 'normal', 'skewed' or 'truncated.normal'. |
skewness |
Numeric - Momentum of distribution skewness |
inferior_limit |
Numeric - Value of the lower bound for the truncated distribution, defaults to '-Inf'. Ignored if |
superior_limit |
Numeric - Value of the upper bound for the truncated distribution, defaults to 'Inf'. Ignored if |
balanced |
Logical - Whether the study will be performed with the same number of subjects in all groups. Default is |
nsims |
Integer - Number of iterations. |
As internal function runs with a single iteration inside graph_twoway_assumptions
, which in itself is inside calculate_mean_matrix
to generate data for the cell mean and standard deviation plot.
For unbalanced independent measures designs, this function generates a simulation with max(group_size)
for all factors combinations and then eliminates observations
at random in those factor combinations that have less participants or study subjects. This may not sound like the most efficient way to proceed, is quite fast anyhow.
The 'n' column in the output will reflect how many observations each factor combination has. This should match the input matrix.
data.frame with modeled outcome values, factor level labels, iteration number and sample size.
refmean <- 1
treatgroups <- 4
timepoints <- 5
treateff <- 1.5
timeeff <- 0.85
factors_levels_names <- list(treatment=letters[1:treatgroups], time=1:timepoints)
## Independent design
effects_treat_time <- calculate_mean_matrix(refmean = refmean,
fAeffect = treateff, fBeffect = timeeff,
nlfA = treatgroups, nlfB = timepoints,
label_list = factors_levels_names)
## Inspect plot to check if matrices correspond to design
n <- 20
independent_experiment <- twoway_simulation_independent(group_size = n,
matrices_obj = effects_treat_time)
head(independent_experiment, 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.