## ----echo = FALSE, message = FALSE-------------------------------------------- knitr::opts_chunk$set( collapse = TRUE ) ## ----example-0.1-------------------------------------------------------------- set.seed(333) # Generate data with a medium effect data <- sprtt::draw_sample_normal( k = 3, # number of groups f = 0.25, # effect size (Cohen's f) max_n = 22 # maximum sample size per group ) ## ----example-0.1b------------------------------------------------------------- # View the first few rows head(data) # Check the sample sizes per group for the first 6 (2*k) data points table(data$x[1:6]) ## ----example-0.2-------------------------------------------------------------- # Calculate the sequential ANOVA anova_results <- sprtt::seq_anova( y ~ x, f = 0.25, data = data[1:6, ], verbose = FALSE ) # View results anova_results # Access the decision anova_results@decision ## ----example-0.3-------------------------------------------------------------- # Calculate sequential ANOVA with larger sample anova_results <- sprtt::seq_anova( y ~ x, f = 0.25, data = data[1:20, ], verbose = FALSE ) # View results anova_results # Check decision anova_results@decision ## ----example-0.4-------------------------------------------------------------- # Calculate sequential ANOVA with complete dataset anova_results <- sprtt::seq_anova( y ~ x, f = 0.25, data = data, verbose = TRUE ) # View full results anova_results ## ----example-0.5-------------------------------------------------------------- # Access the decision anova_results@decision # Access the likelihood ratio anova_results@likelihood_ratio # Access the total sample size anova_results@total_sample_size ## ----example-1---------------------------------------------------------------- set.seed(333) data <- sprtt::draw_sample_normal(3, f = 0.25, max_n = 22) # calculate the SPRT ----------------------------------------------------------- # Default: plot = TRUE with seq_steps = "single" anova_results <- sprtt::seq_anova(y~x, f = 0.25, data = data, plot = TRUE) # Explicitly specify seq_steps = "single" anova_results <- sprtt::seq_anova(y~x, f = 0.25, data = data, plot = TRUE, seq_steps = "single") # Use balanced sequential steps anova_results <- sprtt::seq_anova(y~x, f = 0.25, data = data, plot = TRUE, seq_steps = "balanced") # plot the results ------------------------------------------------------------- sprtt::plot_anova(anova_results) ## ----example-2---------------------------------------------------------------- set.seed(333) # Generate unbalanced data with a 1:1:2 sampling ratio ------------------------- data <- sprtt::draw_sample_normal(3, f = 0.25, max_n = 37, sample_ratio = c(1,1,2)) # Randomize the order to get a more realistic data collection data <- data[sample(nrow(data)),] # Calculate the SPRT with custom sequential steps ------------------------------ anova_results <- sprtt::seq_anova( y~x, f = 0.25, data = data, plot = TRUE, # Start at n=12, then test after each observation seq_steps = 12:nrow(data)) # Plot the results with custom styling ----------------------------------------- sprtt::plot_anova(anova_results, labels = TRUE, position_labels_x = 0.2, position_labels_y = 0.2, position_lr_x = 100, position_lr_y = 1.8, font_size = 20, line_size = 1, highlight_color = "steelblue" )