fitExponential: Fit a exponential function to data.

Description Usage Arguments Value Examples

View source: R/fitExponential.R

Description

Fit the model $y = a e^bx$ to the provided data.

Usage

1
fitExponential(x, y, a0 = 0, b0 = 0)

Arguments

x

x data

y

y data

a0

start value (default: 1)

b0

start value (default: 1)

Value

Named vector of coefficients ('a', 'b')

Examples

1
2
3
4
5
6
age <- c(2, 10, 25, 47, 70, 90)
risk <- c(0.01, 0.07, 0.15, 0.65, 3, 12.64)
plot(age, risk)
ab <- fitExponential(x = age, y = risk, a0 = 1, b0 = 0)
y <- ab[1] * exp(ab[2] * age)
lines(age, y)

babsim.hospital documentation built on Nov. 11, 2021, 1:06 a.m.