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

View source: R/experiments.R

comparison_testR Documentation

Performs between- or within-individual experiments comparing melatonin suppression at two lux levels using t tests

Description

For a between-individual experiment, a t-test is used to compare the melatonin suppression level at two lux values for two different samples of individuals. This function requires based an (ideally large) simulated population of individual dose-response data.

Usage

comparison_test(is_between, lux_1, lux_2, n, population_df, nreps = 1)

Arguments

is_between

a Boolean indicating whether experiment is within or between type

lux_1

first measured lux value

lux_2

second measured lux value

n

number of individuals in sample

population_df

a tibble representing a virtual experiment

nreps

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

Details

For a within-individual, a paired t-test is used to compare the melatonin suppression level at two lux values for a sample of individuals measured at each of those values. 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)

# generate virtual data for 200 individuals
population_df <- virtual_experiment(200)

# carry out between-individual experiment comparing lux_1=10 with lux_2=30
# for a test sample size of 20
is_between <- TRUE
comparison_test(is_between, 10, 30, 20, population_df)

# carry out within-individual experiments comparing lux_1=10 with lux_2=30
# for a test sample size of 20
is_between <- FALSE
comparison_test(is_between, 10, 30, 20, population_df)

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