Learn R Programming

babsim.hospital (version 11.5.14)

getExpCoeff: getExpCoeff

Description

Get coeff from an exponential fit

Usage

getExpCoeff(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

Run this code
# NOT RUN {
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 <- getExpCoeff(x=age, y=risk, a0 = 1, b0 = 0)
y <- ab[1] * exp( ab[2] * age)
lines(age, y)

# }

Run the code above in your browser using DataLab