comparison_test_treatment: Performs between- or within-individual experiments comparing...

View source: R/experiments.R

comparison_test_treatmentR Documentation

Performs between- or within-individual experiments comparing melatonin suppression for treated and untreated subgroups at a single lux

Description

For a between-individual comparison, a t-test comparing the melatonin suppression level at a single lux is conducted on two subgroups (untreated and treated) comprising different sets of individuals.

Usage

comparison_test_treatment(
  is_between,
  lux,
  n,
  population_treated_df,
  is_treated_higher,
  nreps = 1
)

Arguments

is_between

a Boolean indicating whether experiment is within or between type

lux

the lux value at which to conduct the comparison

n

number of individuals in sample

population_treated_df

a virtual population data frame with individual who have been treated and those who have been untreated (where treatment is indicated by a Boolean column named "treated")

is_treated_higher

Boolean indicating whether treated group has a higher response

nreps

integer indicating number of test replicates (which defaults to 1)

Details

For a within-individual comparison, a paired t-test comparing the melatonin suppression level at a single lux level for a set of individuals before and after they are treated is conducted.

This function requires based an (ideally large) simulated population of individual dose-response data.

Value

a dataframe where each row corresponds to a test result in a replicate; note that 'result' indicates that the difference was of the correct sign

Examples

library(melluxdrc)
library(purrr)
library(dplyr)

# create a population where half are treated; half not
n <- 200
population_df <- virtual_treatment_experiment(n, treated_ed50_multiplier=0.5)

# carry out a within-study test at 10 lux for 30 people
# note that, because the ed50 multiplier for the treated group was
# <1, this group should have a higher response
is_treated_higher <- TRUE
comparison_test_treatment(FALSE, 10, 30, population_df, is_treated_higher)

mellux-project/melluxdrc documentation built on March 25, 2022, 8:09 p.m.