simlindr: Simulate dose-response data

Description Usage Arguments Value Examples

View source: R/simlindr.R

Description

A sandbox to create and plot replicate dose-response data with random normal error. Enter a linear scaled predictor variable and additional parameter arguments. Derived from the general hyperbolic function: y/ymax=x^h/(x^h+k^h), where ymax = yhi - ylo. Errors in geom_smooth fitting will occasionally happen. Just re-simulate or modify parameters. The data generating equation is: 'y = ylo + (yhi - ylo)*x^h/(x^h + k^h) + rnorm(length(x), 0, sd)' The regression formula is 'y ~ ylo + (yhi - ylo)*x^h/(x^h + k^h)“

Usage

1
simlindr(x, k, ylo, yhi, h, sd, reps)

Arguments

x

a vector of linear scale values, usually dose or concentration.

k

the value of x that yields y/ymax = 0.5, usually EC50 or ED50.

ylo

the lowest expected y value, in response units.

yhi

the highest expected y value, in response units.

h

the Hill slope, a unitless slope factor; -1 > h > 1 is steeper, -1 < h < 1 is shallower. Use negative value for downward sloping response.

sd

the standard deviation of residual error, in response units.

reps

an integer value for number of replicates.

Value

ggplot, data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# example of x-axis units in nM

Up <- simlindr(x = c(1, 3, 30, 100, 300), k = 30,
ylo = 300, yhi = 3000,
h = 1.0,
sd = 100, reps = 5); Up

# use data for other purposes

Up$data

# negative h values simulate downward sloping response
conc <- c(1e-9, 3e-9, 1e-8, 3e-8, 1e-7, 3e-7)
Down <- simlindr(x = conc, k = 30,
ylo = 300, yhi = 3000,
h = -1.0,
sd = 100, reps = 5); Down

TJMurphy/nlfitr documentation built on March 18, 2021, 12:33 p.m.