simdecay1: Simulate one phase exponential decay data

Description Usage Arguments Value Examples

View source: R/simdecay1.R

Description

A sandbox to simulate and visualize random normal data for a nonlinear decaying response. The data generating formula is derived from the general model: "y = y0*e^-kx". This model simulates response systems where the rate at which the response decreases is proportional to the level of remaining response. Failure errors can happen in the plot fitting subfunction even though random data is produced. These may be more frequent with higher sd values and/or lower range or replicates. Just re-simulate with modified parameter values. The regression formula is: 'y ~ (yhi-ylo)*exp(-1*k*x) + ylo'

Usage

1
simdecay1(x, k, ylo, yhi, sd, reps)

Arguments

x

a vector of non-exponential linear scale values representing time.

k

the rate constant, expressed in reciprocal of the X axis time units. The half-life is 0.6932/k.

ylo

the lowest expected y value, or the value at infinite times, expressed in the same units as Y.

yhi

the highest expected y value, or the starting value, expressed in the same units as Y.

sd

the standard deviation in y.

reps

an integer value for number of replicates

Value

ggplot, data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Note: exponential or log-transformed x scale values will not work
# do not use x = c(1e-9, 3e-9, ...) or c(-9, -8.523, ...)

time <- c(1, 5, 10, 15, 20, 25) # eg, in mins

set.seed(2345)

decayOnedat <- simdecay1(time, k=0.15, ylo=1, yhi=100, sd = 10, reps=5)


decayOnedat$data

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