fitExponential: Fit a exponential function to data.

View source: R/fitExponential.R

fitExponentialR Documentation

Fit a exponential function to data.

Description

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

Usage

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

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 May 30, 2022, 9:05 a.m.